mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-11 09:59:22 +00:00
2ef0f8f5f8
* implement language tags for site/community in db and api * add api checks for valid languages * during db migration, update existing users, sites, communities to have all languages enabled * init new users/communities with site languages (not all languages) * federate site/community languages * fix tests * when updating site languages, limit community languages to this subset also, when making a new post and subset of user lang, community lang contains only one item, use that as post lang * add tests for actor_language db functions * include language list in siteview/communityview * Fix some of the review comments * Some more review changes * Add todo about boxed query * Add default_post_language to GetCommunityResponse
42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
use crate::Perform;
|
|
use actix_web::web::Data;
|
|
use lemmy_api_common::{
|
|
site::{GetUnreadRegistrationApplicationCount, GetUnreadRegistrationApplicationCountResponse},
|
|
utils::{blocking, get_local_user_view_from_jwt, is_admin},
|
|
};
|
|
use lemmy_db_schema::source::site::Site;
|
|
use lemmy_db_views::structs::RegistrationApplicationView;
|
|
use lemmy_utils::{error::LemmyError, ConnectionId};
|
|
use lemmy_websocket::LemmyContext;
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
impl Perform for GetUnreadRegistrationApplicationCount {
|
|
type Response = GetUnreadRegistrationApplicationCountResponse;
|
|
|
|
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?;
|
|
|
|
// Only let admins do this
|
|
is_admin(&local_user_view)?;
|
|
|
|
let verified_email_only = blocking(context.pool(), Site::read_local)
|
|
.await??
|
|
.require_email_verification;
|
|
|
|
let registration_applications = blocking(context.pool(), move |conn| {
|
|
RegistrationApplicationView::get_unread_count(conn, verified_email_only)
|
|
})
|
|
.await??;
|
|
|
|
Ok(Self::Response {
|
|
registration_applications,
|
|
})
|
|
}
|
|
}
|