mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-22 19:01:32 +00:00
Touch up communities
This commit is contained in:
parent
8d91543a13
commit
c506d8e63c
12 changed files with 129 additions and 157 deletions
|
@ -1,5 +1,5 @@
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::{Json, Path};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::{AddModToCommunity, AddModToCommunityResponse},
|
community::{AddModToCommunity, AddModToCommunityResponse},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
|
@ -7,6 +7,7 @@ use lemmy_api_common::{
|
||||||
utils::check_community_mod_action,
|
utils::check_community_mod_action,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
|
@ -23,8 +24,10 @@ pub async fn add_mod_to_community(
|
||||||
data: Json<AddModToCommunity>,
|
data: Json<AddModToCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<AddModToCommunityResponse>> {
|
) -> LemmyResult<Json<AddModToCommunityResponse>> {
|
||||||
let community = Community::read(&mut context.pool(), data.community_id).await?;
|
let community_id = path.into_inner();
|
||||||
|
let community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
// Verify that only mods or admins can add mod
|
// Verify that only mods or admins can add mod
|
||||||
check_community_mod_action(
|
check_community_mod_action(
|
||||||
&local_user_view.person,
|
&local_user_view.person,
|
||||||
|
@ -38,7 +41,7 @@ pub async fn add_mod_to_community(
|
||||||
if !data.added {
|
if !data.added {
|
||||||
LocalUser::is_higher_mod_or_admin_check(
|
LocalUser::is_higher_mod_or_admin_check(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
community.id,
|
community_id,
|
||||||
local_user_view.person.id,
|
local_user_view.person.id,
|
||||||
vec![data.person_id],
|
vec![data.person_id],
|
||||||
)
|
)
|
||||||
|
@ -59,7 +62,7 @@ pub async fn add_mod_to_community(
|
||||||
|
|
||||||
// Update in local database
|
// Update in local database
|
||||||
let community_moderator_form = CommunityModeratorForm {
|
let community_moderator_form = CommunityModeratorForm {
|
||||||
community_id: data.community_id,
|
community_id,
|
||||||
person_id: data.person_id,
|
person_id: data.person_id,
|
||||||
};
|
};
|
||||||
if data.added {
|
if data.added {
|
||||||
|
@ -76,7 +79,7 @@ pub async fn add_mod_to_community(
|
||||||
let form = ModAddCommunityForm {
|
let form = ModAddCommunityForm {
|
||||||
mod_person_id: local_user_view.person.id,
|
mod_person_id: local_user_view.person.id,
|
||||||
other_person_id: data.person_id,
|
other_person_id: data.person_id,
|
||||||
community_id: data.community_id,
|
community_id,
|
||||||
removed: Some(!data.added),
|
removed: Some(!data.added),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,13 +87,12 @@ pub async fn add_mod_to_community(
|
||||||
|
|
||||||
// Note: in case a remote mod is added, this returns the old moderators list, it will only get
|
// Note: in case a remote mod is added, this returns the old moderators list, it will only get
|
||||||
// updated once we receive an activity from the community (like `Announce/Add/Moderator`)
|
// updated once we receive an activity from the community (like `Announce/Add/Moderator`)
|
||||||
let community_id = data.community_id;
|
|
||||||
let moderators = CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
|
let moderators = CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
ActivityChannel::submit_activity(
|
ActivityChannel::submit_activity(
|
||||||
SendActivityData::AddModToCommunity {
|
SendActivityData::AddModToCommunity {
|
||||||
moderator: local_user_view.person,
|
moderator: local_user_view.person,
|
||||||
community_id: data.community_id,
|
community_id,
|
||||||
target: data.person_id,
|
target: data.person_id,
|
||||||
added: data.added,
|
added: data.added,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::{Json, Path};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::{BanFromCommunity, BanFromCommunityResponse},
|
community::{BanFromCommunity, BanFromCommunityResponse},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{
|
utils::{
|
||||||
check_community_mod_action,
|
check_community_mod_action, check_expire_time, remove_or_restore_user_data_in_community,
|
||||||
check_expire_time,
|
|
||||||
remove_or_restore_user_data_in_community,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
community::{
|
community::{
|
||||||
Community,
|
Community, CommunityFollower, CommunityFollowerForm, CommunityPersonBan,
|
||||||
CommunityFollower,
|
|
||||||
CommunityFollowerForm,
|
|
||||||
CommunityPersonBan,
|
|
||||||
CommunityPersonBanForm,
|
CommunityPersonBanForm,
|
||||||
},
|
},
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
|
@ -36,10 +32,12 @@ pub async fn ban_from_community(
|
||||||
data: Json<BanFromCommunity>,
|
data: Json<BanFromCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<BanFromCommunityResponse>> {
|
) -> LemmyResult<Json<BanFromCommunityResponse>> {
|
||||||
|
let community_id = path.into_inner();
|
||||||
let banned_person_id = data.person_id;
|
let banned_person_id = data.person_id;
|
||||||
let expires = check_expire_time(data.expires)?;
|
let expires = check_expire_time(data.expires)?;
|
||||||
let community = Community::read(&mut context.pool(), data.community_id).await?;
|
let community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
// Verify that only mods or admins can ban
|
// Verify that only mods or admins can ban
|
||||||
check_community_mod_action(
|
check_community_mod_action(
|
||||||
|
@ -52,7 +50,7 @@ pub async fn ban_from_community(
|
||||||
|
|
||||||
LocalUser::is_higher_mod_or_admin_check(
|
LocalUser::is_higher_mod_or_admin_check(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
data.community_id,
|
community_id,
|
||||||
local_user_view.person.id,
|
local_user_view.person.id,
|
||||||
vec![data.person_id],
|
vec![data.person_id],
|
||||||
)
|
)
|
||||||
|
@ -63,7 +61,7 @@ pub async fn ban_from_community(
|
||||||
}
|
}
|
||||||
|
|
||||||
let community_user_ban_form = CommunityPersonBanForm {
|
let community_user_ban_form = CommunityPersonBanForm {
|
||||||
community_id: data.community_id,
|
community_id,
|
||||||
person_id: data.person_id,
|
person_id: data.person_id,
|
||||||
expires: Some(expires),
|
expires: Some(expires),
|
||||||
};
|
};
|
||||||
|
@ -74,7 +72,7 @@ pub async fn ban_from_community(
|
||||||
.with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?;
|
.with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?;
|
||||||
|
|
||||||
// Also unsubscribe them from the community, if they are subscribed
|
// Also unsubscribe them from the community, if they are subscribed
|
||||||
let community_follower_form = CommunityFollowerForm::new(data.community_id, banned_person_id);
|
let community_follower_form = CommunityFollowerForm::new(community_id, banned_person_id);
|
||||||
CommunityFollower::unfollow(&mut context.pool(), &community_follower_form)
|
CommunityFollower::unfollow(&mut context.pool(), &community_follower_form)
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
|
@ -88,7 +86,7 @@ pub async fn ban_from_community(
|
||||||
if data.remove_or_restore_data.unwrap_or(false) {
|
if data.remove_or_restore_data.unwrap_or(false) {
|
||||||
let remove_data = data.ban;
|
let remove_data = data.ban;
|
||||||
remove_or_restore_user_data_in_community(
|
remove_or_restore_user_data_in_community(
|
||||||
data.community_id,
|
community_id,
|
||||||
local_user_view.person.id,
|
local_user_view.person.id,
|
||||||
banned_person_id,
|
banned_person_id,
|
||||||
remove_data,
|
remove_data,
|
||||||
|
@ -102,7 +100,7 @@ pub async fn ban_from_community(
|
||||||
let form = ModBanFromCommunityForm {
|
let form = ModBanFromCommunityForm {
|
||||||
mod_person_id: local_user_view.person.id,
|
mod_person_id: local_user_view.person.id,
|
||||||
other_person_id: data.person_id,
|
other_person_id: data.person_id,
|
||||||
community_id: data.community_id,
|
community_id,
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
banned: Some(data.ban),
|
banned: Some(data.ban),
|
||||||
expires,
|
expires,
|
||||||
|
@ -115,7 +113,7 @@ pub async fn ban_from_community(
|
||||||
ActivityChannel::submit_activity(
|
ActivityChannel::submit_activity(
|
||||||
SendActivityData::BanFromCommunity {
|
SendActivityData::BanFromCommunity {
|
||||||
moderator: local_user_view.person,
|
moderator: local_user_view.person,
|
||||||
community_id: data.community_id,
|
community_id,
|
||||||
target: person_view.person.clone(),
|
target: person_view.person.clone(),
|
||||||
data: data.0.clone(),
|
data: data.0.clone(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::{Json, Path};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::{CommunityResponse, FollowCommunity},
|
community::{CommunityResponse, FollowCommunity},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
|
@ -7,6 +7,7 @@ use lemmy_api_common::{
|
||||||
utils::{check_community_deleted_removed, check_user_valid},
|
utils::{check_community_deleted_removed, check_user_valid},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
actor_language::CommunityLanguage,
|
actor_language::CommunityLanguage,
|
||||||
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityFollowerState},
|
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityFollowerState},
|
||||||
|
@ -23,10 +24,12 @@ pub async fn follow_community(
|
||||||
data: Json<FollowCommunity>,
|
data: Json<FollowCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<CommunityResponse>> {
|
) -> LemmyResult<Json<CommunityResponse>> {
|
||||||
|
let community_id = path.into_inner();
|
||||||
check_user_valid(&local_user_view.person)?;
|
check_user_valid(&local_user_view.person)?;
|
||||||
let community = Community::read(&mut context.pool(), data.community_id).await?;
|
let community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
let form = CommunityFollowerForm::new(community.id, local_user_view.person.id);
|
let form = CommunityFollowerForm::new(community_id, local_user_view.person.id);
|
||||||
|
|
||||||
if data.follow {
|
if data.follow {
|
||||||
// Only run these checks for local community, in case of remote community the local
|
// Only run these checks for local community, in case of remote community the local
|
||||||
|
@ -34,7 +37,7 @@ pub async fn follow_community(
|
||||||
// actions from existing followers for private community (so following would be impossible).
|
// actions from existing followers for private community (so following would be impossible).
|
||||||
if community.local {
|
if community.local {
|
||||||
check_community_deleted_removed(&community)?;
|
check_community_deleted_removed(&community)?;
|
||||||
CommunityPersonBanView::check(&mut context.pool(), local_user_view.person.id, community.id)
|
CommunityPersonBanView::check(&mut context.pool(), local_user_view.person.id, community_id)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ pub async fn follow_community(
|
||||||
|
|
||||||
let form = CommunityFollowerForm {
|
let form = CommunityFollowerForm {
|
||||||
state,
|
state,
|
||||||
..CommunityFollowerForm::new(community.id, local_user_view.person.id)
|
..CommunityFollowerForm::new(community_id, local_user_view.person.id)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Write to db
|
// Write to db
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::{Json, Path};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::HideCommunity,
|
community::HideCommunity,
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
|
@ -8,6 +8,7 @@ use lemmy_api_common::{
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
mod_log::moderator::{ModHideCommunity, ModHideCommunityForm},
|
mod_log::moderator::{ModHideCommunity, ModHideCommunityForm},
|
||||||
|
@ -22,7 +23,9 @@ pub async fn hide_community(
|
||||||
data: Json<HideCommunity>,
|
data: Json<HideCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<SuccessResponse>> {
|
) -> LemmyResult<Json<SuccessResponse>> {
|
||||||
|
let community_id = path.into_inner();
|
||||||
// Verify its a admin (only admin can hide or unhide it)
|
// Verify its a admin (only admin can hide or unhide it)
|
||||||
is_admin(&local_user_view)?;
|
is_admin(&local_user_view)?;
|
||||||
|
|
||||||
|
@ -32,13 +35,12 @@ pub async fn hide_community(
|
||||||
};
|
};
|
||||||
|
|
||||||
let mod_hide_community_form = ModHideCommunityForm {
|
let mod_hide_community_form = ModHideCommunityForm {
|
||||||
community_id: data.community_id,
|
community_id: community_id,
|
||||||
mod_person_id: local_user_view.person.id,
|
mod_person_id: local_user_view.person.id,
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
hidden: Some(data.hidden),
|
hidden: Some(data.hidden),
|
||||||
};
|
};
|
||||||
|
|
||||||
let community_id = data.community_id;
|
|
||||||
let community = Community::update(&mut context.pool(), community_id, &community_form)
|
let community = Community::update(&mut context.pool(), community_id, &community_form)
|
||||||
.await
|
.await
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunityHiddenStatus)?;
|
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunityHiddenStatus)?;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use actix_web::web::{Data, Json, Query};
|
use actix_web::web::{Data, Json, Path, Query};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::{ListCommunityPendingFollows, ListCommunityPendingFollowsResponse},
|
community::{ListCommunityPendingFollows, ListCommunityPendingFollowsResponse},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
utils::check_community_mod_of_any_or_admin_action,
|
utils::check_community_mod_of_any_or_admin_action,
|
||||||
};
|
};
|
||||||
|
use lemmy_db_schema::newtypes::CommunityId;
|
||||||
use lemmy_db_views::structs::LocalUserView;
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
use lemmy_db_views_actor::structs::CommunityFollowerView;
|
use lemmy_db_views_actor::structs::CommunityFollowerView;
|
||||||
use lemmy_utils::error::LemmyResult;
|
use lemmy_utils::error::LemmyResult;
|
||||||
|
@ -12,7 +13,9 @@ pub async fn get_pending_follows_list(
|
||||||
data: Query<ListCommunityPendingFollows>,
|
data: Query<ListCommunityPendingFollows>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<ListCommunityPendingFollowsResponse>> {
|
) -> LemmyResult<Json<ListCommunityPendingFollowsResponse>> {
|
||||||
|
let community_id = path.into_inner();
|
||||||
check_community_mod_of_any_or_admin_action(&local_user_view, &mut context.pool()).await?;
|
check_community_mod_of_any_or_admin_action(&local_user_view, &mut context.pool()).await?;
|
||||||
let all_communities =
|
let all_communities =
|
||||||
data.all_communities.unwrap_or_default() && local_user_view.local_user.admin;
|
data.all_communities.unwrap_or_default() && local_user_view.local_user.admin;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use actix_web::web::{Data, Json};
|
use actix_web::web::{Data, Json, Path};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::{GetCommunityResponse, TransferCommunity},
|
community::{GetCommunityResponse, TransferCommunity},
|
||||||
|
@ -6,6 +6,7 @@ use lemmy_api_common::{
|
||||||
utils::{check_community_user_action, is_admin, is_top_mod},
|
utils::{check_community_user_action, is_admin, is_top_mod},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
mod_log::moderator::{ModTransferCommunity, ModTransferCommunityForm},
|
mod_log::moderator::{ModTransferCommunity, ModTransferCommunityForm},
|
||||||
|
@ -26,10 +27,12 @@ pub async fn transfer_community(
|
||||||
data: Json<TransferCommunity>,
|
data: Json<TransferCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<GetCommunityResponse>> {
|
) -> LemmyResult<Json<GetCommunityResponse>> {
|
||||||
let community = Community::read(&mut context.pool(), data.community_id).await?;
|
let community_id = path.into_inner();
|
||||||
|
let community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
let mut community_mods =
|
let mut community_mods =
|
||||||
CommunityModeratorView::for_community(&mut context.pool(), community.id).await?;
|
CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
check_community_user_action(&local_user_view.person, &community, &mut context.pool()).await?;
|
check_community_user_action(&local_user_view.person, &community, &mut context.pool()).await?;
|
||||||
|
|
||||||
|
@ -49,8 +52,6 @@ pub async fn transfer_community(
|
||||||
community_mods.insert(0, creator_person);
|
community_mods.insert(0, creator_person);
|
||||||
|
|
||||||
// Delete all the mods
|
// Delete all the mods
|
||||||
let community_id = data.community_id;
|
|
||||||
|
|
||||||
CommunityModerator::delete_for_community(&mut context.pool(), community_id).await?;
|
CommunityModerator::delete_for_community(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
// TODO: this should probably be a bulk operation
|
// TODO: this should probably be a bulk operation
|
||||||
|
@ -70,12 +71,11 @@ pub async fn transfer_community(
|
||||||
let form = ModTransferCommunityForm {
|
let form = ModTransferCommunityForm {
|
||||||
mod_person_id: local_user_view.person.id,
|
mod_person_id: local_user_view.person.id,
|
||||||
other_person_id: data.person_id,
|
other_person_id: data.person_id,
|
||||||
community_id: data.community_id,
|
community_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
ModTransferCommunity::create(&mut context.pool(), &form).await?;
|
ModTransferCommunity::create(&mut context.pool(), &form).await?;
|
||||||
|
|
||||||
let community_id = data.community_id;
|
|
||||||
let community_view = CommunityView::read(
|
let community_view = CommunityView::read(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
community_id,
|
community_id,
|
||||||
|
@ -84,7 +84,6 @@ pub async fn transfer_community(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let community_id = data.community_id;
|
|
||||||
let moderators = CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
|
let moderators = CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
// Return the jwt
|
// Return the jwt
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::{Json, Path};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
build_response::build_community_response,
|
build_response::build_community_response,
|
||||||
community::{CommunityResponse, DeleteCommunity},
|
community::{CommunityResponse, DeleteCommunity},
|
||||||
|
@ -8,6 +8,7 @@ use lemmy_api_common::{
|
||||||
utils::{check_community_mod_action, is_top_mod},
|
utils::{check_community_mod_action, is_top_mod},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::community::{Community, CommunityUpdateForm},
|
source::community::{Community, CommunityUpdateForm},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
@ -20,12 +21,14 @@ pub async fn delete_community(
|
||||||
data: Json<DeleteCommunity>,
|
data: Json<DeleteCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<CommunityResponse>> {
|
) -> LemmyResult<Json<CommunityResponse>> {
|
||||||
|
let community_id = path.into_inner();
|
||||||
// Fetch the community mods
|
// Fetch the community mods
|
||||||
let community_mods =
|
let community_mods =
|
||||||
CommunityModeratorView::for_community(&mut context.pool(), data.community_id).await?;
|
CommunityModeratorView::for_community(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
let community = Community::read(&mut context.pool(), data.community_id).await?;
|
let community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
check_community_mod_action(
|
check_community_mod_action(
|
||||||
&local_user_view.person,
|
&local_user_view.person,
|
||||||
&community,
|
&community,
|
||||||
|
@ -38,7 +41,6 @@ pub async fn delete_community(
|
||||||
is_top_mod(&local_user_view, &community_mods)?;
|
is_top_mod(&local_user_view, &community_mods)?;
|
||||||
|
|
||||||
// Do the delete
|
// Do the delete
|
||||||
let community_id = data.community_id;
|
|
||||||
let deleted = data.deleted;
|
let deleted = data.deleted;
|
||||||
let community = Community::update(
|
let community = Community::update(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::{Json, Path};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
build_response::build_community_response,
|
build_response::build_community_response,
|
||||||
community::{CommunityResponse, RemoveCommunity},
|
community::{CommunityResponse, RemoveCommunity},
|
||||||
|
@ -8,6 +8,7 @@ use lemmy_api_common::{
|
||||||
utils::{check_community_mod_action, is_admin},
|
utils::{check_community_mod_action, is_admin},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
mod_log::moderator::{ModRemoveCommunity, ModRemoveCommunityForm},
|
mod_log::moderator::{ModRemoveCommunity, ModRemoveCommunityForm},
|
||||||
|
@ -22,8 +23,10 @@ pub async fn remove_community(
|
||||||
data: Json<RemoveCommunity>,
|
data: Json<RemoveCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<CommunityResponse>> {
|
) -> LemmyResult<Json<CommunityResponse>> {
|
||||||
let community = Community::read(&mut context.pool(), data.community_id).await?;
|
let community_id = path.into_inner();
|
||||||
|
let community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
check_community_mod_action(
|
check_community_mod_action(
|
||||||
&local_user_view.person,
|
&local_user_view.person,
|
||||||
&community,
|
&community,
|
||||||
|
@ -36,7 +39,6 @@ pub async fn remove_community(
|
||||||
is_admin(&local_user_view)?;
|
is_admin(&local_user_view)?;
|
||||||
|
|
||||||
// Do the remove
|
// Do the remove
|
||||||
let community_id = data.community_id;
|
|
||||||
let removed = data.removed;
|
let removed = data.removed;
|
||||||
let community = Community::update(
|
let community = Community::update(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::check_community_visibility_allowed;
|
use super::check_community_visibility_allowed;
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::Json;
|
use actix_web::web::{Json, Path};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
build_response::build_community_response,
|
build_response::build_community_response,
|
||||||
|
@ -9,14 +9,12 @@ use lemmy_api_common::{
|
||||||
request::replace_image,
|
request::replace_image,
|
||||||
send_activity::{ActivityChannel, SendActivityData},
|
send_activity::{ActivityChannel, SendActivityData},
|
||||||
utils::{
|
utils::{
|
||||||
check_community_mod_action,
|
check_community_mod_action, get_url_blocklist, local_site_to_slur_regex, process_markdown_opt,
|
||||||
get_url_blocklist,
|
|
||||||
local_site_to_slur_regex,
|
|
||||||
process_markdown_opt,
|
|
||||||
proxy_image_link_opt_api,
|
proxy_image_link_opt_api,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
actor_language::{CommunityLanguage, SiteLanguage},
|
actor_language::{CommunityLanguage, SiteLanguage},
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
|
@ -36,7 +34,9 @@ pub async fn update_community(
|
||||||
data: Json<EditCommunity>,
|
data: Json<EditCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<CommunityResponse>> {
|
) -> LemmyResult<Json<CommunityResponse>> {
|
||||||
|
let community_id = path.into_inner();
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||||
|
|
||||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||||
|
@ -56,7 +56,7 @@ pub async fn update_community(
|
||||||
check_community_visibility_allowed(data.visibility, &local_user_view)?;
|
check_community_visibility_allowed(data.visibility, &local_user_view)?;
|
||||||
let description = diesel_string_update(data.description.as_deref());
|
let description = diesel_string_update(data.description.as_deref());
|
||||||
|
|
||||||
let old_community = Community::read(&mut context.pool(), data.community_id).await?;
|
let old_community = Community::read(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
let icon = diesel_url_update(data.icon.as_deref())?;
|
let icon = diesel_url_update(data.icon.as_deref())?;
|
||||||
replace_image(&icon, &old_community.icon, &context).await?;
|
replace_image(&icon, &old_community.icon, &context).await?;
|
||||||
|
@ -75,7 +75,6 @@ pub async fn update_community(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let community_id = data.community_id;
|
|
||||||
if let Some(languages) = data.discussion_languages.clone() {
|
if let Some(languages) = data.discussion_languages.clone() {
|
||||||
let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;
|
let site_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;
|
||||||
// check that community languages are a subset of site languages
|
// check that community languages are a subset of site languages
|
||||||
|
@ -100,7 +99,6 @@ pub async fn update_community(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let community_id = data.community_id;
|
|
||||||
let community = Community::update(&mut context.pool(), community_id, &community_form)
|
let community = Community::update(&mut context.pool(), community_id, &community_form)
|
||||||
.await
|
.await
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?;
|
.with_lemmy_type(LemmyErrorType::CouldntUpdateCommunity)?;
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
use crate::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity};
|
|
||||||
use activitypub_federation::config::Data;
|
use activitypub_federation::config::Data;
|
||||||
use actix_web::web::{Json, Query};
|
use actix_web::web::{Json, Path, Query};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::{GetCommunity, GetCommunityResponse},
|
community::{GetCommunity, GetCommunityResponse},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
utils::{check_private_instance, is_mod_or_admin_opt, read_site_for_actor},
|
utils::{check_private_instance, is_mod_or_admin_opt, read_site_for_actor},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::{
|
use lemmy_db_schema::{
|
||||||
actor_language::CommunityLanguage,
|
newtypes::CommunityId,
|
||||||
community::Community,
|
source::{actor_language::CommunityLanguage, local_site::LocalSite},
|
||||||
local_site::LocalSite,
|
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::LocalUserView;
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
||||||
|
@ -20,7 +18,9 @@ pub async fn get_community(
|
||||||
data: Query<GetCommunity>,
|
data: Query<GetCommunity>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: Option<LocalUserView>,
|
local_user_view: Option<LocalUserView>,
|
||||||
|
path: Path<CommunityId>,
|
||||||
) -> LemmyResult<Json<GetCommunityResponse>> {
|
) -> LemmyResult<Json<GetCommunityResponse>> {
|
||||||
|
let community_id = path.into_inner();
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
let local_site = LocalSite::read(&mut context.pool()).await?;
|
||||||
|
|
||||||
if data.name.is_none() && data.id.is_none() {
|
if data.name.is_none() && data.id.is_none() {
|
||||||
|
@ -31,15 +31,15 @@ pub async fn get_community(
|
||||||
|
|
||||||
let local_user = local_user_view.as_ref().map(|u| &u.local_user);
|
let local_user = local_user_view.as_ref().map(|u| &u.local_user);
|
||||||
|
|
||||||
let community_id = match data.id {
|
// let community_id = match data.id {
|
||||||
Some(id) => id,
|
// Some(id) => id,
|
||||||
None => {
|
// None => {
|
||||||
let name = data.name.clone().unwrap_or_else(|| "main".to_string());
|
// let name = data.name.clone().unwrap_or_else(|| "main".to_string());
|
||||||
resolve_actor_identifier::<ApubCommunity, Community>(&name, &context, &local_user_view, true)
|
// resolve_actor_identifier::<ApubCommunity, Community>(&name, &context, &local_user_view, true)
|
||||||
.await?
|
// .await?
|
||||||
.id
|
// .id
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
let is_mod_or_admin = is_mod_or_admin_opt(
|
let is_mod_or_admin = is_mod_or_admin_opt(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
|
@ -61,7 +61,6 @@ pub async fn get_community(
|
||||||
|
|
||||||
let site = read_site_for_actor(community_view.community.actor_id.clone(), &context).await?;
|
let site = read_site_for_actor(community_view.community.actor_id.clone(), &context).await?;
|
||||||
|
|
||||||
let community_id = community_view.community.id;
|
|
||||||
let discussion_languages = CommunityLanguage::read(&mut context.pool(), community_id).await?;
|
let discussion_languages = CommunityLanguage::read(&mut context.pool(), community_id).await?;
|
||||||
|
|
||||||
Ok(Json(GetCommunityResponse {
|
Ok(Json(GetCommunityResponse {
|
||||||
|
|
|
@ -23,14 +23,14 @@ services:
|
||||||
|
|
||||||
lemmy:
|
lemmy:
|
||||||
# use "image" to pull down an already compiled lemmy. make sure to comment out "build".
|
# use "image" to pull down an already compiled lemmy. make sure to comment out "build".
|
||||||
# image: dessalines/lemmy:0.19.6
|
image: dessalines/lemmy:0.19.6
|
||||||
# platform: linux/x86_64 # no arm64 support. uncomment platform if using m1.
|
# platform: linux/x86_64 # no arm64 support. uncomment platform if using m1.
|
||||||
# use "build" to build your local lemmy server image for development. make sure to comment out "image".
|
# use "build" to build your local lemmy server image for development. make sure to comment out "image".
|
||||||
# run: docker compose up --build
|
# run: docker compose up --build
|
||||||
|
|
||||||
build:
|
# build:
|
||||||
context: ../
|
# context: ../
|
||||||
dockerfile: docker/Dockerfile
|
# dockerfile: docker/Dockerfile
|
||||||
# args:
|
# args:
|
||||||
# RUST_RELEASE_MODE: release
|
# RUST_RELEASE_MODE: release
|
||||||
# CARGO_BUILD_FEATURES: default
|
# CARGO_BUILD_FEATURES: default
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
use actix_web::{guard, web::*};
|
use actix_web::{guard, web::*};
|
||||||
use lemmy_api::{
|
use lemmy_api::{
|
||||||
comment::{
|
comment::{
|
||||||
distinguish::distinguish_comment,
|
distinguish::distinguish_comment, like::like_comment, list_comment_likes::list_comment_likes,
|
||||||
like::like_comment,
|
|
||||||
list_comment_likes::list_comment_likes,
|
|
||||||
save::save_comment,
|
save::save_comment,
|
||||||
},
|
},
|
||||||
comment_report::{
|
comment_report::{
|
||||||
create::create_comment_report,
|
create::create_comment_report, list::list_comment_reports, resolve::resolve_comment_report,
|
||||||
list::list_comment_reports,
|
|
||||||
resolve::resolve_comment_report,
|
|
||||||
},
|
},
|
||||||
community::{
|
community::{
|
||||||
add_mod::add_mod_to_community,
|
add_mod::add_mod_to_community,
|
||||||
|
@ -18,8 +14,7 @@ use lemmy_api::{
|
||||||
follow::follow_community,
|
follow::follow_community,
|
||||||
hide::hide_community,
|
hide::hide_community,
|
||||||
pending_follows::{
|
pending_follows::{
|
||||||
approve::post_pending_follows_approve,
|
approve::post_pending_follows_approve, count::get_pending_follows_count,
|
||||||
count::get_pending_follows_count,
|
|
||||||
list::get_pending_follows_list,
|
list::get_pending_follows_list,
|
||||||
},
|
},
|
||||||
random::get_random_community,
|
random::get_random_community,
|
||||||
|
@ -39,12 +34,9 @@ use lemmy_api::{
|
||||||
login::login,
|
login::login,
|
||||||
logout::logout,
|
logout::logout,
|
||||||
notifications::{
|
notifications::{
|
||||||
list_mentions::list_mentions,
|
list_mentions::list_mentions, list_replies::list_replies,
|
||||||
list_replies::list_replies,
|
mark_all_read::mark_all_notifications_read, mark_mention_read::mark_person_mention_as_read,
|
||||||
mark_all_read::mark_all_notifications_read,
|
mark_reply_read::mark_reply_as_read, unread_count::unread_count,
|
||||||
mark_mention_read::mark_person_mention_as_read,
|
|
||||||
mark_reply_read::mark_reply_as_read,
|
|
||||||
unread_count::unread_count,
|
|
||||||
},
|
},
|
||||||
report_count::report_count,
|
report_count::report_count,
|
||||||
reset_password::reset_password,
|
reset_password::reset_password,
|
||||||
|
@ -55,26 +47,16 @@ use lemmy_api::{
|
||||||
verify_email::verify_email,
|
verify_email::verify_email,
|
||||||
},
|
},
|
||||||
post::{
|
post::{
|
||||||
feature::feature_post,
|
feature::feature_post, get_link_metadata::get_link_metadata, hide::hide_post, like::like_post,
|
||||||
get_link_metadata::get_link_metadata,
|
list_post_likes::list_post_likes, lock::lock_post, mark_many_read::mark_posts_as_read,
|
||||||
hide::hide_post,
|
mark_read::mark_post_as_read, save::save_post,
|
||||||
like::like_post,
|
|
||||||
list_post_likes::list_post_likes,
|
|
||||||
lock::lock_post,
|
|
||||||
mark_many_read::mark_posts_as_read,
|
|
||||||
mark_read::mark_post_as_read,
|
|
||||||
save::save_post,
|
|
||||||
},
|
},
|
||||||
post_report::{
|
post_report::{
|
||||||
create::create_post_report,
|
create::create_post_report, list::list_post_reports, resolve::resolve_post_report,
|
||||||
list::list_post_reports,
|
|
||||||
resolve::resolve_post_report,
|
|
||||||
},
|
},
|
||||||
private_message::mark_read::mark_pm_as_read,
|
private_message::mark_read::mark_pm_as_read,
|
||||||
private_message_report::{
|
private_message_report::{
|
||||||
create::create_pm_report,
|
create::create_pm_report, list::list_pm_reports, resolve::resolve_pm_report,
|
||||||
list::list_pm_reports,
|
|
||||||
resolve::resolve_pm_report,
|
|
||||||
},
|
},
|
||||||
site::{
|
site::{
|
||||||
admin_allow_instance::admin_allow_instance,
|
admin_allow_instance::admin_allow_instance,
|
||||||
|
@ -84,14 +66,10 @@ use lemmy_api::{
|
||||||
list_all_media::list_all_media,
|
list_all_media::list_all_media,
|
||||||
mod_log::get_mod_log,
|
mod_log::get_mod_log,
|
||||||
purge::{
|
purge::{
|
||||||
comment::purge_comment,
|
comment::purge_comment, community::purge_community, person::purge_person, post::purge_post,
|
||||||
community::purge_community,
|
|
||||||
person::purge_person,
|
|
||||||
post::purge_post,
|
|
||||||
},
|
},
|
||||||
registration_applications::{
|
registration_applications::{
|
||||||
approve::approve_registration_application,
|
approve::approve_registration_application, get::get_registration_application,
|
||||||
get::get_registration_application,
|
|
||||||
list::list_registration_applications,
|
list::list_registration_applications,
|
||||||
unread_count::get_unread_registration_application_count,
|
unread_count::get_unread_registration_application_count,
|
||||||
},
|
},
|
||||||
|
@ -100,49 +78,31 @@ use lemmy_api::{
|
||||||
};
|
};
|
||||||
use lemmy_api_crud::{
|
use lemmy_api_crud::{
|
||||||
comment::{
|
comment::{
|
||||||
create::create_comment,
|
create::create_comment, delete::delete_comment, read::get_comment, remove::remove_comment,
|
||||||
delete::delete_comment,
|
|
||||||
read::get_comment,
|
|
||||||
remove::remove_comment,
|
|
||||||
update::update_comment,
|
update::update_comment,
|
||||||
},
|
},
|
||||||
community::{
|
community::{
|
||||||
create::create_community,
|
create::create_community, delete::delete_community, list::list_communities,
|
||||||
delete::delete_community,
|
remove::remove_community, update::update_community,
|
||||||
list::list_communities,
|
|
||||||
remove::remove_community,
|
|
||||||
update::update_community,
|
|
||||||
},
|
},
|
||||||
custom_emoji::{
|
custom_emoji::{
|
||||||
create::create_custom_emoji,
|
create::create_custom_emoji, delete::delete_custom_emoji, list::list_custom_emojis,
|
||||||
delete::delete_custom_emoji,
|
|
||||||
list::list_custom_emojis,
|
|
||||||
update::update_custom_emoji,
|
update::update_custom_emoji,
|
||||||
},
|
},
|
||||||
oauth_provider::{
|
oauth_provider::{
|
||||||
create::create_oauth_provider,
|
create::create_oauth_provider, delete::delete_oauth_provider, update::update_oauth_provider,
|
||||||
delete::delete_oauth_provider,
|
|
||||||
update::update_oauth_provider,
|
|
||||||
},
|
},
|
||||||
post::{
|
post::{
|
||||||
create::create_post,
|
create::create_post, delete::delete_post, read::get_post, remove::remove_post,
|
||||||
delete::delete_post,
|
|
||||||
read::get_post,
|
|
||||||
remove::remove_post,
|
|
||||||
update::update_post,
|
update::update_post,
|
||||||
},
|
},
|
||||||
private_message::{
|
private_message::{
|
||||||
create::create_private_message,
|
create::create_private_message, delete::delete_private_message, read::get_private_message,
|
||||||
delete::delete_private_message,
|
|
||||||
read::get_private_message,
|
|
||||||
update::update_private_message,
|
update::update_private_message,
|
||||||
},
|
},
|
||||||
site::{create::create_site, read::get_site_v4, update::update_site},
|
site::{create::create_site, read::get_site_v4, update::update_site},
|
||||||
tagline::{
|
tagline::{
|
||||||
create::create_tagline,
|
create::create_tagline, delete::delete_tagline, list::list_taglines, update::update_tagline,
|
||||||
delete::delete_tagline,
|
|
||||||
list::list_taglines,
|
|
||||||
update::update_tagline,
|
|
||||||
},
|
},
|
||||||
user::{
|
user::{
|
||||||
create::{authenticate_with_oauth, register},
|
create::{authenticate_with_oauth, register},
|
||||||
|
@ -183,30 +143,34 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
.route("/resolve_object", get().to(resolve_object))
|
.route("/resolve_object", get().to(resolve_object))
|
||||||
// Community
|
// Community
|
||||||
.service(
|
.service(
|
||||||
resource("/community")
|
scope("/communities")
|
||||||
.guard(guard::Post())
|
.route("", get().to(list_communities))
|
||||||
.wrap(rate_limit.register())
|
|
||||||
.route(post().to(create_community)),
|
|
||||||
)
|
|
||||||
.service(
|
|
||||||
scope("/community")
|
|
||||||
.route("", get().to(get_community))
|
|
||||||
.route("", put().to(update_community))
|
|
||||||
.route("/random", get().to(get_random_community))
|
.route("/random", get().to(get_random_community))
|
||||||
.route("/hide", put().to(hide_community))
|
|
||||||
.route("/list", get().to(list_communities))
|
|
||||||
.route("/follow", post().to(follow_community))
|
|
||||||
.route("/delete", post().to(delete_community))
|
|
||||||
// Mod Actions
|
|
||||||
.route("/remove", post().to(remove_community))
|
|
||||||
.route("/transfer", post().to(transfer_community))
|
|
||||||
.route("/ban_user", post().to(ban_from_community))
|
|
||||||
.route("/mod", post().to(add_mod_to_community))
|
|
||||||
.service(
|
.service(
|
||||||
scope("/pending_follows")
|
resource("")
|
||||||
.route("/count", get().to(get_pending_follows_count))
|
.guard(guard::Post())
|
||||||
.route("/list", get().to(get_pending_follows_list))
|
.wrap(rate_limit.register())
|
||||||
.route("/approve", post().to(post_pending_follows_approve)),
|
.route(post().to(create_community)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
scope("/{community_id}")
|
||||||
|
.route("", put().to(update_community))
|
||||||
|
.route("", get().to(get_community))
|
||||||
|
.route("", delete().to(delete_community))
|
||||||
|
.route("/hide", put().to(hide_community))
|
||||||
|
.route("/follow", post().to(follow_community))
|
||||||
|
// Mod Actions
|
||||||
|
.route("/remove", post().to(remove_community))
|
||||||
|
.route("/transfer", post().to(transfer_community))
|
||||||
|
.route("/ban_user", post().to(ban_from_community))
|
||||||
|
.route("/mod", post().to(add_mod_to_community))
|
||||||
|
.service(
|
||||||
|
// TODO: Not sure what to do with these
|
||||||
|
scope("/pending_follows")
|
||||||
|
.route("", get().to(get_pending_follows_list))
|
||||||
|
.route("/count", get().to(get_pending_follows_count))
|
||||||
|
.route("/approve", post().to(post_pending_follows_approve)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.route("/federated_instances", get().to(get_federated_instances))
|
.route("/federated_instances", get().to(get_federated_instances))
|
||||||
|
|
Loading…
Reference in a new issue