2023-09-05 09:33:46 +00:00
|
|
|
use actix_web::web::{Data, Json, Query};
|
2022-04-13 18:12:25 +00:00
|
|
|
use lemmy_api_common::{
|
2022-11-28 14:29:33 +00:00
|
|
|
context::LemmyContext,
|
2022-04-13 18:12:25 +00:00
|
|
|
person::{GetPersonMentions, GetPersonMentionsResponse},
|
|
|
|
};
|
2023-09-21 10:42:28 +00:00
|
|
|
use lemmy_db_views::structs::LocalUserView;
|
2022-08-04 19:30:17 +00:00
|
|
|
use lemmy_db_views_actor::person_mention_view::PersonMentionQuery;
|
2024-04-10 14:14:11 +00:00
|
|
|
use lemmy_utils::error::LemmyResult;
|
2022-04-13 18:12:25 +00:00
|
|
|
|
2023-09-05 09:33:46 +00:00
|
|
|
#[tracing::instrument(skip(context))]
|
|
|
|
pub async fn list_mentions(
|
|
|
|
data: Query<GetPersonMentions>,
|
|
|
|
context: Data<LemmyContext>,
|
2023-09-21 10:42:28 +00:00
|
|
|
local_user_view: LocalUserView,
|
2024-04-10 14:14:11 +00:00
|
|
|
) -> LemmyResult<Json<GetPersonMentionsResponse>> {
|
2023-09-05 09:33:46 +00:00
|
|
|
let sort = data.sort;
|
|
|
|
let page = data.page;
|
|
|
|
let limit = data.limit;
|
|
|
|
let unread_only = data.unread_only.unwrap_or_default();
|
|
|
|
let person_id = Some(local_user_view.person.id);
|
|
|
|
let show_bot_accounts = local_user_view.local_user.show_bot_accounts;
|
2022-04-13 18:12:25 +00:00
|
|
|
|
2023-09-05 09:33:46 +00:00
|
|
|
let mentions = PersonMentionQuery {
|
|
|
|
recipient_id: person_id,
|
|
|
|
my_person_id: person_id,
|
|
|
|
sort,
|
|
|
|
unread_only,
|
|
|
|
show_bot_accounts,
|
|
|
|
page,
|
|
|
|
limit,
|
2022-04-13 18:12:25 +00:00
|
|
|
}
|
2023-09-05 09:33:46 +00:00
|
|
|
.list(&mut context.pool())
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(Json(GetPersonMentionsResponse { mentions }))
|
2022-04-13 18:12:25 +00:00
|
|
|
}
|