Skip to content

Commit

Permalink
Flags: Allow moderators to see flags on their own posts.
Browse files Browse the repository at this point in the history
If someone is abusing it they shouldn't be a mod.
  • Loading branch information
nottalulah committed Jun 15, 2024
1 parent 1a59ebc commit 1da316b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/policies/post_flag_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def can_search_flagger?
end

def can_view_flagger?
record.creator_id == user.id || (user.is_moderator? && record.post&.uploader_id != user.id)
record.creator_id == user.id || user.is_moderator?
end

def permitted_attributes_for_create
Expand All @@ -33,9 +33,7 @@ def api_attributes

def visible_for_search(relation, attribute)
case attribute
in :creator | :creator_id if can_search_flagger?
relation.where(creator: user).or(relation.where.not(post: user.posts))
in :creator | :creator_id
in :creator | :creator_id if !can_search_flagger?
relation.where(creator: user)
else
relation
Expand Down

0 comments on commit 1da316b

Please sign in to comment.