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

@@ -14,8 +14,8 @@ use crate::{
compute_offset_limit,
error::ServerError,
graphql::{
Attachment, Body, DispositionType, Email, Header, Html, Message, PlainText, Tag, Thread,
ThreadSummary, UnhandledContentType,
Attachment, Body, DispositionType, Email, EmailThread, Header, Html, Message, PlainText,
Tag, ThreadSummary, UnhandledContentType,
},
linkify_html, sanitize_html,
};
@@ -125,7 +125,7 @@ pub async fn thread(
nm: &Notmuch,
thread_id: String,
debug_content_tree: bool,
) -> Result<Thread, ServerError> {
) -> Result<EmailThread, ServerError> {
// TODO(wathiede): normalize all email addresses through an address book with preferred
// display names (that default to the most commonly seen name).
let mut messages = Vec::new();
@@ -246,7 +246,7 @@ pub async fn thread(
.next()
.and_then(|m| m.subject.clone())
.unwrap_or("(NO SUBJECT)".to_string());
Ok(Thread {
Ok(EmailThread {
thread_id,
subject,
messages,