lemmy/crates/api/src/local_user/notifications/unread_count.rs
Dessalines ba4c9a0c8f
Some site person ban fixes, and code cleanup (#5556)
* Receive and store remote site bans (fixes #3399)

* db schema changes, handly expiration

* partial federation changes

* add column `mod_ban.instance_id`

* remove unused

* wip: remove person.banned

* fix down migration

* fmt, keep banned status

* fixes

* simplify

* update post removed

* fix api tests

* ban from local instance

* banned() helpers

* cleanup undo_block_user

* remove order by

* cache SiteView::read_local, add instance

* use local instance id for PersonView

* add helper function person_with_instance_actions

* use exists

* comments update removed

* remove method is_mod_or_admin

* fix tests

* no unwrap

* change local_instance_person_join

* remove LocalSite::read

* wip: home_instance_actions

* add home_instance_actions to all structs

* fixes

* fix tests

* fmt

* Starting to work on site person ban fixes.

* Starting to work on comment_view

* Adding a few more views.

* Cleaning up a few more views.

* Finishing up a few more.

* Fixing unit tests.

- Also fixes #5502

* Fixing merge 2.

* Adding a creator_banned field

---------

Co-authored-by: Felix Ableitner <me@nutomic.com>
2025-04-03 12:08:52 +02:00

23 lines
753 B
Rust

use actix_web::web::{Data, Json};
use lemmy_api_common::{context::LemmyContext, person::GetUnreadCountResponse};
use lemmy_db_views::structs::{InboxCombinedViewInternal, LocalUserView};
use lemmy_utils::error::LemmyResult;
pub async fn unread_count(
context: Data<LemmyContext>,
local_user_view: LocalUserView,
) -> LemmyResult<Json<GetUnreadCountResponse>> {
let person_id = local_user_view.person.id;
let local_instance_id = local_user_view.person.instance_id;
let show_bot_accounts = local_user_view.local_user.show_bot_accounts;
let count = InboxCombinedViewInternal::get_unread_count(
&mut context.pool(),
person_id,
local_instance_id,
show_bot_accounts,
)
.await?;
Ok(Json(GetUnreadCountResponse { count }))
}