fix: fallback to current time for rich activity

This commit is contained in:
əlemi 2024-08-14 02:19:36 +02:00
parent 660e5cf127
commit 0a98934a7e
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -44,10 +44,13 @@ impl FromQueryResult for RichActivity {
fn from_query_result(res: &QueryResult, _pre: &str) -> Result<Self, DbErr> { fn from_query_result(res: &QueryResult, _pre: &str) -> Result<Self, DbErr> {
Ok(RichActivity { Ok(RichActivity {
attachments: None, hashtags: None, mentions: None, attachments: None, hashtags: None, mentions: None,
discovered: res.try_get(crate::model::addressing::Entity.table_name(), &crate::model::addressing::Column::Published.to_string())?,
liked: res.try_get(crate::model::like::Entity.table_name(), &crate::model::like::Column::Actor.to_string()).ok(), liked: res.try_get(crate::model::like::Entity.table_name(), &crate::model::like::Column::Actor.to_string()).ok(),
object: crate::model::object::Model::from_query_result(res, crate::model::object::Entity.table_name()).ok(), object: crate::model::object::Model::from_query_result(res, crate::model::object::Entity.table_name()).ok(),
activity: crate::model::activity::Model::from_query_result(res, crate::model::activity::Entity.table_name()).ok(), activity: crate::model::activity::Model::from_query_result(res, crate::model::activity::Entity.table_name()).ok(),
discovered: res.try_get(
crate::model::addressing::Entity.table_name(),
&crate::model::addressing::Column::Published.to_string()
).unwrap_or(chrono::Utc::now()),
}) })
} }
} }