Refactor thread responses into an enum.

Lays ground work for different types of views, i.e. email, news, docs, etc.
This commit is contained in:
2024-08-26 21:48:53 -07:00
parent 446fcfe37f
commit 760cec01a8
10 changed files with 190 additions and 161 deletions

View File

@@ -32,8 +32,13 @@ pub struct ThreadSummary {
pub tags: Vec<String>,
}
#[derive(Debug, Union)]
pub enum Thread {
Email(EmailThread),
}
#[derive(Debug, SimpleObject)]
pub struct Thread {
pub struct EmailThread {
pub thread_id: String,
pub subject: String,
pub messages: Vec<Message>,
@@ -369,11 +374,13 @@ impl QueryRoot {
.field("contentTree")
.exists();
// TODO: look at thread_id and conditionally load newsreader
if newsreader::is_newsreader_thread(&thread_id) {
Ok(newsreader::thread(pool, thread_id).await?)
} else {
Ok(nm::thread(nm, thread_id, debug_content_tree).await?)
}
Ok(Thread::Email(
if newsreader::is_newsreader_thread(&thread_id) {
newsreader::thread(pool, thread_id).await?
} else {
nm::thread(nm, thread_id, debug_content_tree).await?
},
))
}
}