|
|
|
@ -47,9 +47,10 @@ use lemmy_db_schema::{
|
|
|
|
|
};
|
|
|
|
|
use lemmy_db_views::{
|
|
|
|
|
comment_report_view::CommentReportView,
|
|
|
|
|
comment_view::CommentQueryBuilder,
|
|
|
|
|
comment_view::{CommentQueryBuilder, CommentView},
|
|
|
|
|
local_user_view::LocalUserView,
|
|
|
|
|
post_report_view::PostReportView,
|
|
|
|
|
private_message_view::PrivateMessageView,
|
|
|
|
|
};
|
|
|
|
|
use lemmy_db_views_actor::{
|
|
|
|
|
community_moderator_view::CommunityModeratorView,
|
|
|
|
@ -831,3 +832,43 @@ impl Perform for GetReportCount {
|
|
|
|
|
Ok(res)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
|
|
|
impl Perform for GetUnreadCount {
|
|
|
|
|
type Response = GetUnreadCountResponse;
|
|
|
|
|
|
|
|
|
|
async fn perform(
|
|
|
|
|
&self,
|
|
|
|
|
context: &Data<LemmyContext>,
|
|
|
|
|
_websocket_id: Option<ConnectionId>,
|
|
|
|
|
) -> Result<Self::Response, LemmyError> {
|
|
|
|
|
let data = self;
|
|
|
|
|
let local_user_view =
|
|
|
|
|
get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
|
|
|
|
|
|
|
|
|
|
let person_id = local_user_view.person.id;
|
|
|
|
|
|
|
|
|
|
let replies = blocking(context.pool(), move |conn| {
|
|
|
|
|
CommentView::get_unread_replies(conn, person_id)
|
|
|
|
|
})
|
|
|
|
|
.await??;
|
|
|
|
|
|
|
|
|
|
let mentions = blocking(context.pool(), move |conn| {
|
|
|
|
|
PersonMentionView::get_unread_mentions(conn, person_id)
|
|
|
|
|
})
|
|
|
|
|
.await??;
|
|
|
|
|
|
|
|
|
|
let private_messages = blocking(context.pool(), move |conn| {
|
|
|
|
|
PrivateMessageView::get_unread_messages(conn, person_id)
|
|
|
|
|
})
|
|
|
|
|
.await??;
|
|
|
|
|
|
|
|
|
|
let res = Self::Response {
|
|
|
|
|
replies,
|
|
|
|
|
mentions,
|
|
|
|
|
private_messages,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Ok(res)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|