mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE - SiteSetting to disable user option to hide their profiles and presences (#10885)
* FEATURE - SiteSetting to disable user option to hide their profiles and presences
This commit is contained in:
@ -102,7 +102,18 @@ const Presence = EmberObject.extend({
|
||||
},
|
||||
|
||||
publish(state, whisper, postId, staffOnly) {
|
||||
if (this.get("currentUser.hide_profile_and_presence")) {
|
||||
// NOTE: `user_option` is the correct place to get this value from, but
|
||||
// it may not have been set yet. It will always have been set directly
|
||||
// on the currentUser, via the preloaded_json payload.
|
||||
// TODO: Remove this when preloaded_json is refactored.
|
||||
let hiddenProfile = this.get(
|
||||
"currentUser.user_option.hide_profile_and_presence"
|
||||
);
|
||||
if (hiddenProfile === undefined) {
|
||||
hiddenProfile = this.get("currentUser.hide_profile_and_presence");
|
||||
}
|
||||
|
||||
if (hiddenProfile && this.get("siteSettings.allow_users_to_hide_profile")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,8 @@ after_initialize do
|
||||
|
||||
def ensure_presence_enabled
|
||||
if !SiteSetting.presence_enabled ||
|
||||
current_user.user_option.hide_profile_and_presence?
|
||||
(SiteSetting.allow_users_to_hide_profile &&
|
||||
current_user.user_option.hide_profile_and_presence?)
|
||||
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
|
@ -45,6 +45,15 @@ describe ::Presence::PresencesController do
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it 'returns the right response when user disables the presence feature and allow_users_to_hide_profile is disabled' do
|
||||
user.user_option.update_column(:hide_profile_and_presence, true)
|
||||
SiteSetting.allow_users_to_hide_profile = false
|
||||
|
||||
post '/presence/publish.json', params: { topic_id: public_topic.id, state: 'replying' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it 'returns the right response when the presence site settings is disabled' do
|
||||
SiteSetting.presence_enabled = false
|
||||
|
||||
|
Reference in New Issue
Block a user