2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 person::{GetPersonMentions, GetPersonMentionsResponse},
6 utils::get_local_user_view_from_jwt,
8 use lemmy_db_views_actor::person_mention_view::PersonMentionQuery;
9 use lemmy_utils::{error::LemmyError, ConnectionId};
11 #[async_trait::async_trait(?Send)]
12 impl Perform for GetPersonMentions {
13 type Response = GetPersonMentionsResponse;
15 #[tracing::instrument(skip(context, _websocket_id))]
18 context: &Data<LemmyContext>,
19 _websocket_id: Option<ConnectionId>,
20 ) -> Result<GetPersonMentionsResponse, LemmyError> {
21 let data: &GetPersonMentions = self;
23 get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
27 let limit = data.limit;
28 let unread_only = data.unread_only;
29 let person_id = Some(local_user_view.person.id);
30 let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
32 let mentions = PersonMentionQuery::builder()
34 .recipient_id(person_id)
35 .my_person_id(person_id)
37 .unread_only(unread_only)
38 .show_bot_accounts(show_bot_accounts)
45 Ok(GetPersonMentionsResponse { mentions })