2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 get_local_user_view_from_jwt,
7 site::{GetUnreadRegistrationApplicationCount, GetUnreadRegistrationApplicationCountResponse},
9 use lemmy_db_schema::source::site::Site;
10 use lemmy_db_views::registration_application_view::RegistrationApplicationView;
11 use lemmy_utils::{ConnectionId, LemmyError};
12 use lemmy_websocket::LemmyContext;
14 #[async_trait::async_trait(?Send)]
15 impl Perform for GetUnreadRegistrationApplicationCount {
16 type Response = GetUnreadRegistrationApplicationCountResponse;
20 context: &Data<LemmyContext>,
21 _websocket_id: Option<ConnectionId>,
22 ) -> Result<Self::Response, LemmyError> {
25 get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
27 // Only let admins do this
28 is_admin(&local_user_view)?;
30 let verified_email_only = blocking(context.pool(), Site::read_local_site)
32 .require_email_verification;
34 let registration_applications = blocking(context.pool(), move |conn| {
35 RegistrationApplicationView::get_unread_count(conn, verified_email_only)
40 registration_applications,