mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Hide user status when user is hiding public profile and presence (#24300)
Users can hide their public profile and presence information by checking
“Hide my public profile and presence features” on the
`u/{username}/preferences/interface` page. In that case, we also don't
want to return user status from the server.
This work has been started in https://github.com/discourse/discourse/pull/23946.
The current PR fixes all the remaining places in Core.
Note that the actual fix is quite simple – a5802f484d.
But we had a fair amount of duplication in the code responsible for
the user status serialization, so I had to dry that up first. The refactoring
as well as adding some additional tests is the main part of this PR.
This commit is contained in:
committed by
GitHub
parent
41790f7739
commit
b3a1199493
@@ -3,6 +3,7 @@
|
||||
class CurrentUserSerializer < BasicUserSerializer
|
||||
include UserTagNotificationsMixin
|
||||
include UserSidebarMixin
|
||||
include UserStatusMixin
|
||||
|
||||
attributes :name,
|
||||
:unread_notifications,
|
||||
@@ -65,7 +66,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
:can_review,
|
||||
:draft_count,
|
||||
:pending_posts_count,
|
||||
:status,
|
||||
:grouped_unread_notifications,
|
||||
:display_sidebar_tags,
|
||||
:sidebar_tags,
|
||||
@@ -82,6 +82,11 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
|
||||
has_one :user_option, embed: :object, serializer: CurrentUserOptionSerializer
|
||||
|
||||
def initialize(object, options = {})
|
||||
super
|
||||
options[:include_status] = true
|
||||
end
|
||||
|
||||
def sidebar_sections
|
||||
SidebarSection
|
||||
.public_sections
|
||||
@@ -304,14 +309,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
Draft.has_topic_draft(object)
|
||||
end
|
||||
|
||||
def include_status?
|
||||
SiteSetting.enable_user_status && object.has_status?
|
||||
end
|
||||
|
||||
def status
|
||||
UserStatusSerializer.new(object.user_status, root: false)
|
||||
end
|
||||
|
||||
def unseen_reviewable_count
|
||||
Reviewable.unseen_reviewable_count(object)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user