mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 22:01:19 +00:00
Allow community mods to see votes in addition to admins (#4392)
* Allow community mods to see votes in addition to admins * Use Post instead of PostView --------- Co-authored-by: SleeplessOne1917 <insomnia-void@protonmail.com>
This commit is contained in:
parent
2133bcea4e
commit
4b4b99aa78
3 changed files with 24 additions and 8 deletions
|
@ -2,9 +2,9 @@ use actix_web::web::{Data, Json, Query};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
comment::{ListCommentLikes, ListCommentLikesResponse},
|
comment::{ListCommentLikes, ListCommentLikesResponse},
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
utils::is_admin,
|
utils::is_mod_or_admin,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::{LocalUserView, VoteView};
|
use lemmy_db_views::structs::{CommentView, LocalUserView, VoteView};
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
|
||||||
/// Lists likes for a comment
|
/// Lists likes for a comment
|
||||||
|
@ -14,8 +14,18 @@ pub async fn list_comment_likes(
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
) -> Result<Json<ListCommentLikesResponse>, LemmyError> {
|
) -> Result<Json<ListCommentLikesResponse>, LemmyError> {
|
||||||
// Make sure user is an admin
|
let comment_view = CommentView::read(
|
||||||
is_admin(&local_user_view)?;
|
&mut context.pool(),
|
||||||
|
data.comment_id,
|
||||||
|
Some(local_user_view.person.id),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
is_mod_or_admin(
|
||||||
|
&mut context.pool(),
|
||||||
|
&local_user_view.person,
|
||||||
|
comment_view.community.id,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let comment_likes =
|
let comment_likes =
|
||||||
VoteView::list_for_comment(&mut context.pool(), data.comment_id, data.page, data.limit).await?;
|
VoteView::list_for_comment(&mut context.pool(), data.comment_id, data.page, data.limit).await?;
|
||||||
|
|
|
@ -2,8 +2,9 @@ use actix_web::web::{Data, Json, Query};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
post::{ListPostLikes, ListPostLikesResponse},
|
post::{ListPostLikes, ListPostLikesResponse},
|
||||||
utils::is_admin,
|
utils::is_mod_or_admin,
|
||||||
};
|
};
|
||||||
|
use lemmy_db_schema::{source::post::Post, traits::Crud};
|
||||||
use lemmy_db_views::structs::{LocalUserView, VoteView};
|
use lemmy_db_views::structs::{LocalUserView, VoteView};
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
|
||||||
|
@ -14,8 +15,13 @@ pub async fn list_post_likes(
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
) -> Result<Json<ListPostLikesResponse>, LemmyError> {
|
) -> Result<Json<ListPostLikesResponse>, LemmyError> {
|
||||||
// Make sure user is an admin
|
let post = Post::read(&mut context.pool(), data.post_id).await?;
|
||||||
is_admin(&local_user_view)?;
|
is_mod_or_admin(
|
||||||
|
&mut context.pool(),
|
||||||
|
&local_user_view.person,
|
||||||
|
post.community_id,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let post_likes =
|
let post_likes =
|
||||||
VoteView::list_for_post(&mut context.pool(), data.post_id, data.page, data.limit).await?;
|
VoteView::list_for_post(&mut context.pool(), data.post_id, data.page, data.limit).await?;
|
||||||
|
|
|
@ -296,7 +296,7 @@ impl InstanceWorker {
|
||||||
}
|
}
|
||||||
if let Some(t) = &activity.send_community_followers_of {
|
if let Some(t) = &activity.send_community_followers_of {
|
||||||
if let Some(urls) = self.followed_communities.get(t) {
|
if let Some(urls) = self.followed_communities.get(t) {
|
||||||
inbox_urls.extend(urls.iter().map(std::clone::Clone::clone));
|
inbox_urls.extend(urls.iter().cloned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inbox_urls.extend(
|
inbox_urls.extend(
|
||||||
|
|
Loading…
Reference in a new issue