Treat email and news posts as distinct types on the frontend and backend
This commit is contained in:
@@ -35,6 +35,18 @@ pub struct ThreadSummary {
|
||||
#[derive(Debug, Union)]
|
||||
pub enum Thread {
|
||||
Email(EmailThread),
|
||||
News(NewsPost),
|
||||
}
|
||||
|
||||
#[derive(Debug, SimpleObject)]
|
||||
pub struct NewsPost {
|
||||
pub thread_id: String,
|
||||
pub slug: String,
|
||||
pub site: String,
|
||||
pub title: String,
|
||||
pub body: String,
|
||||
pub url: String,
|
||||
pub timestamp: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, SimpleObject)]
|
||||
@@ -374,13 +386,11 @@ impl QueryRoot {
|
||||
.field("contentTree")
|
||||
.exists();
|
||||
// TODO: look at thread_id and conditionally load newsreader
|
||||
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?
|
||||
},
|
||||
))
|
||||
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?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user