Fix new post read/unread handling

This commit is contained in:
2024-08-31 13:49:03 -07:00
parent a9e6120f81
commit e73f70af8f
5 changed files with 21 additions and 3 deletions

View File

@@ -41,6 +41,7 @@ pub enum Thread {
#[derive(Debug, SimpleObject)]
pub struct NewsPost {
pub thread_id: String,
pub is_read: bool,
pub slug: String,
pub site: String,
pub title: String,

View File

@@ -207,6 +207,7 @@ pub async fn thread(pool: &PgPool, thread_id: String) -> Result<Thread, ServerEr
}
}
let title = clean_title(&r.title.unwrap_or("NO TITLE".to_string())).await?;
let is_read = r.is_read.unwrap_or(false);
let timestamp = r
.date
.expect("post missing date")
@@ -214,6 +215,7 @@ pub async fn thread(pool: &PgPool, thread_id: String) -> Result<Thread, ServerEr
.unix_timestamp();
Ok(Thread::News(NewsPost {
thread_id,
is_read,
slug,
site,
title,