-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Implement only allow post voting topics in this category
- Loading branch information
1 parent
3f70825
commit e1e9afe
Showing
7 changed files
with
108 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
module PostVoting | ||
module GuardianExtension | ||
def can_edit_comment?(comment) | ||
return false if !self.user | ||
return true if comment.user_id == self.user.id | ||
return true if self.is_admin? | ||
return true if self.is_moderator? | ||
false | ||
end | ||
|
||
def can_delete_comment?(comment) | ||
can_edit_comment?(comment) | ||
end | ||
|
||
def can_flag_post_voting_comments? | ||
return false if self.user.silenced? | ||
return true if self.user.staff? | ||
|
||
self.user.trust_level >= (SiteSetting.min_trust_to_flag_posts_voting_comments) | ||
true | ||
end | ||
|
||
def can_flag_post_voting_comment?(comment) | ||
if !authenticated? || !comment || comment.trashed? || !comment.user | ||
return false | ||
end | ||
return false if comment.user.staff? && !SiteSetting.allow_flagging_staff | ||
return false if comment.user_id == @user.id | ||
|
||
can_flag_post_voting_comments? | ||
end | ||
|
||
def can_flag_post_voting_comment_as?(comment, flag_type_id, opts) | ||
return false if !is_staff? && (opts[:take_action] || opts[:queue_for_review]) | ||
|
||
if flag_type_id == ReviewableScore.types[:notify_user] | ||
is_warning = ActiveRecord::Type::Boolean.new.deserialize(opts[:is_warning]) | ||
|
||
return false if is_warning && !is_staff? | ||
end | ||
|
||
true | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters