mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Implement SiteSetting to Allow Anonymous Likes (#22131)
Allow anonymous users (logged-in, but set to anonymous posting) to like posts --------- Co-authored-by: Emmett Ling <eling@zendesk.com> Co-authored-by: Nat <natalie.tay@discourse.org>
This commit is contained in:
@@ -620,10 +620,14 @@ class Guardian
|
||||
private
|
||||
|
||||
def is_my_own?(obj)
|
||||
unless anonymous?
|
||||
return obj.user_id == @user.id if obj.respond_to?(:user_id) && obj.user_id && @user.id
|
||||
return obj.user == @user if obj.respond_to?(:user)
|
||||
if anonymous?
|
||||
return(
|
||||
SiteSetting.allow_anonymous_likes? && obj.class == PostAction && obj.is_like? &&
|
||||
obj.user_id == @user.id
|
||||
)
|
||||
end
|
||||
return obj.user_id == @user.id if obj.respond_to?(:user_id) && obj.user_id && @user.id
|
||||
return obj.user == @user if obj.respond_to?(:user)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
@@ -43,7 +43,10 @@ module PostGuardian
|
||||
already_did_flagging = taken.any? && (taken & PostActionType.notify_flag_types.values).any?
|
||||
|
||||
result =
|
||||
if authenticated? && post && !@user.anonymous?
|
||||
if authenticated? && post
|
||||
# Allow anonymous users to like if feature is enabled and short-circuit otherwise
|
||||
return SiteSetting.allow_anonymous_likes? && (action_key == :like) if @user.anonymous?
|
||||
|
||||
# Silenced users can't flag
|
||||
return false if is_flag && @user.silenced?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user