2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 person::{GetRepliesResponse, MarkAllAsRead},
6 utils::local_user_view_from_jwt,
8 use lemmy_db_schema::source::{
9 comment_reply::CommentReply,
10 person_mention::PersonMention,
11 private_message::PrivateMessage,
13 use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
15 #[async_trait::async_trait(?Send)]
16 impl Perform for MarkAllAsRead {
17 type Response = GetRepliesResponse;
19 #[tracing::instrument(skip(context))]
20 async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetRepliesResponse, LemmyError> {
21 let data: &MarkAllAsRead = self;
22 let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
23 let person_id = local_user_view.person.id;
25 // Mark all comment_replies as read
26 CommentReply::mark_all_as_read(context.pool(), person_id)
28 .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
30 // Mark all user mentions as read
31 PersonMention::mark_all_as_read(context.pool(), person_id)
33 .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?;
35 // Mark all private_messages as read
36 PrivateMessage::mark_all_as_read(context.pool(), person_id)
38 .with_lemmy_type(LemmyErrorType::CouldntUpdatePrivateMessage)?;
40 Ok(GetRepliesResponse { replies: vec![] })