use crate::claims::Claims;
use actix_web::{web, web::Data};
use lemmy_db::{
- source::community::{CommunityModerator_, Community_},
+ source::{
+ community::{CommunityModerator_, Community_},
+ site::Site_,
+ },
views::community::community_user_ban_view::CommunityUserBanView,
Crud,
DbPool,
use lemmy_db_schema::source::{
community::{Community, CommunityModerator},
post::Post,
+ site::Site,
user::User_,
};
use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*};
}
}
+pub(crate) async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), LemmyError> {
+ if score == -1 {
+ let site = blocking(pool, move |conn| Site::read_simple(conn)).await??;
+ if !site.enable_downvotes {
+ return Err(APIError::err("downvotes_disabled").into());
+ }
+ }
+ Ok(())
+}
+
/// Returns a list of communities that the user moderates
/// or if a community_id is supplied validates the user is a moderator
/// of that community and returns the community id in a vec