Treat email and news posts as distinct types on the frontend and backend

This commit is contained in:
2024-08-31 11:40:06 -07:00
parent 760cec01a8
commit a8d5617cf2
12 changed files with 324 additions and 72 deletions

View File

@@ -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?)
}
}
}