fix: stacks manage page when user deletes profile
add: allow moderators to view deleted posts
This commit is contained in:
parent
4c26879d00
commit
81307752c2
14 changed files with 211 additions and 29 deletions
|
@ -138,7 +138,7 @@ pub async fn update_title_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_channel_title(id, user, &req.title).await {
|
||||
match data.update_channel_title(id, &user, &req.title).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Channel updated".to_string(),
|
||||
|
@ -160,7 +160,7 @@ pub async fn update_position_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_channel_position(id, user, req.position).await {
|
||||
match data.update_channel_position(id, &user, req.position).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Channel updated".to_string(),
|
||||
|
|
|
@ -117,7 +117,7 @@ pub async fn update_context_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_community_context(id, user, req.context).await {
|
||||
match data.update_community_context(id, &user, req.context).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Community updated".to_string(),
|
||||
|
@ -140,7 +140,7 @@ pub async fn update_read_access_request(
|
|||
};
|
||||
|
||||
match data
|
||||
.update_community_read_access(id, user, req.access)
|
||||
.update_community_read_access(id, &user, req.access)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Json(ApiReturn {
|
||||
|
@ -165,7 +165,7 @@ pub async fn update_write_access_request(
|
|||
};
|
||||
|
||||
match data
|
||||
.update_community_write_access(id, user, req.access)
|
||||
.update_community_write_access(id, &user, req.access)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Json(ApiReturn {
|
||||
|
@ -190,7 +190,7 @@ pub async fn update_join_access_request(
|
|||
};
|
||||
|
||||
match data
|
||||
.update_community_join_access(id, user, req.access)
|
||||
.update_community_join_access(id, &user, req.access)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Json(ApiReturn {
|
||||
|
|
|
@ -183,7 +183,7 @@ pub async fn update_name_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_emoji_name(id, user, &req.name).await {
|
||||
match data.update_emoji_name(id, &user, &req.name).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Emoji updated".to_string(),
|
||||
|
|
|
@ -173,6 +173,31 @@ pub async fn delete_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.fake_delete_post(id, user, true).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Post deleted".to_string(),
|
||||
payload: (),
|
||||
}),
|
||||
Err(e) => Json(e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn real_delete_request(
|
||||
jar: CookieJar,
|
||||
Extension(data): Extension<State>,
|
||||
Path(id): Path<usize>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
if !user.permissions.check(FinePermission::MANAGE_POSTS) {
|
||||
return Json(Error::NotAllowed.into());
|
||||
}
|
||||
|
||||
match data.delete_post(id, user).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
|
|
|
@ -93,6 +93,10 @@ pub fn routes() -> Router {
|
|||
// posts
|
||||
.route("/posts", post(communities::posts::create_request))
|
||||
.route("/posts/{id}", delete(communities::posts::delete_request))
|
||||
.route(
|
||||
"/posts/{id}/real_delete",
|
||||
delete(communities::posts::real_delete_request),
|
||||
)
|
||||
.route(
|
||||
"/posts/{id}/repost",
|
||||
post(communities::posts::create_repost_request),
|
||||
|
|
|
@ -43,7 +43,7 @@ pub async fn update_name_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_stack_name(id, user, &req.name).await {
|
||||
match data.update_stack_name(id, &user, &req.name).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Stack updated".to_string(),
|
||||
|
@ -65,7 +65,7 @@ pub async fn update_privacy_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_stack_privacy(id, user, req.privacy).await {
|
||||
match data.update_stack_privacy(id, &user, req.privacy).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Stack updated".to_string(),
|
||||
|
@ -87,7 +87,7 @@ pub async fn update_mode_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_stack_mode(id, user, req.mode).await {
|
||||
match data.update_stack_mode(id, &user, req.mode).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Stack updated".to_string(),
|
||||
|
@ -109,7 +109,7 @@ pub async fn update_sort_request(
|
|||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.update_stack_sort(id, user, req.sort).await {
|
||||
match data.update_stack_sort(id, &user, req.sort).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Stack updated".to_string(),
|
||||
|
@ -152,7 +152,7 @@ pub async fn add_user_request(
|
|||
};
|
||||
|
||||
stack.users.push(other_user.id);
|
||||
match data.update_stack_users(id, user, stack.users).await {
|
||||
match data.update_stack_users(id, &user, stack.users).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "User added".to_string(),
|
||||
|
@ -191,7 +191,7 @@ pub async fn remove_user_request(
|
|||
None => return Json(Error::GeneralNotFound("user".to_string()).into()),
|
||||
});
|
||||
|
||||
match data.update_stack_users(id, user, stack.users).await {
|
||||
match data.update_stack_users(id, &user, stack.users).await {
|
||||
Ok(_) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "User removed".to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue