2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 get_local_user_view_from_jwt,
7 site::{ListRegistrationApplications, ListRegistrationApplicationsResponse},
9 use lemmy_db_schema::source::site::Site;
10 use lemmy_db_views::registration_application_view::RegistrationApplicationQueryBuilder;
11 use lemmy_utils::{ConnectionId, LemmyError};
12 use lemmy_websocket::LemmyContext;
14 /// Lists registration applications, filterable by undenied only.
15 #[async_trait::async_trait(?Send)]
16 impl Perform for ListRegistrationApplications {
17 type Response = ListRegistrationApplicationsResponse;
21 context: &Data<LemmyContext>,
22 _websocket_id: Option<ConnectionId>,
23 ) -> Result<Self::Response, LemmyError> {
26 get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
28 // Make sure user is an admin
29 is_admin(&local_user_view)?;
31 let unread_only = data.unread_only;
32 let verified_email_only = blocking(context.pool(), Site::read_local_site)
34 .require_email_verification;
37 let limit = data.limit;
38 let registration_applications = blocking(context.pool(), move |conn| {
39 RegistrationApplicationQueryBuilder::create(conn)
40 .unread_only(unread_only)
41 .verified_email_only(verified_email_only)
48 let res = Self::Response {
49 registration_applications,