From 0dbcc54d4bc45d63126970785d3b8d059dc328b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 4 Jul 2024 19:27:26 +0200 Subject: [PATCH] DEV: use new 'ignore allowed groups' site settings (#27670) Instead of the deprecated 'min trust level to allow ignore' in order to reduce the number of deprecation notices in the logs. This tweaks a few serializers so that the 'can_ignore_users?` property is always coming from the server and properly used on the client-side. --- .../app/controllers/preferences/users.js | 17 +--- .../app/templates/preferences/users.hbs | 33 +++---- .../tests/fixtures/session-fixtures.js | 2 + app/serializers/current_user_serializer.rb | 2 +- app/serializers/user_serializer.rb | 10 +++ lib/guardian.rb | 3 +- .../api/schemas/json/user_get_response.json | 6 ++ .../web_hook_user_serializer_spec.rb | 86 ++++++++++--------- 8 files changed, 83 insertions(+), 76 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/users.js b/app/assets/javascripts/discourse/app/controllers/preferences/users.js index 5c5ac48cd3c..4c6719e3f4d 100644 --- a/app/assets/javascripts/discourse/app/controllers/preferences/users.js +++ b/app/assets/javascripts/discourse/app/controllers/preferences/users.js @@ -1,26 +1,11 @@ import Controller from "@ember/controller"; import { action, computed } from "@ember/object"; -import { alias, and } from "@ember/object/computed"; +import { and } from "@ember/object/computed"; import { popupAjaxError } from "discourse/lib/ajax-error"; import { makeArray } from "discourse-common/lib/helpers"; import discourseComputed from "discourse-common/utils/decorators"; export default Controller.extend({ - ignoredUsernames: alias("model.ignored_usernames"), - - @discourseComputed("model.trust_level", "model.groups") - userCanIgnore(trustLevel) { - return ( - trustLevel >= this.siteSettings.min_trust_level_to_allow_ignore || - this.currentUser.can_ignore_users - ); - }, - - @discourseComputed("userCanIgnore", "model.staff") - ignoredEnabled(userCanIgnore, userIsStaff) { - return this.currentUser.staff || userCanIgnore || userIsStaff; - }, - allowPmUsersEnabled: and( "model.user_option.enable_allowed_pm_users", "model.user_option.allow_private_messages" diff --git a/app/assets/javascripts/discourse/app/templates/preferences/users.hbs b/app/assets/javascripts/discourse/app/templates/preferences/users.hbs index 6ffb37ffaaa..37d39f3f93e 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences/users.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences/users.hbs @@ -1,5 +1,6 @@ -{{#if this.ignoredEnabled}} + +{{#if this.model.can_ignore_users}}
{{/if}} -
-
- - +{{#if this.model.can_mute_users}} +
+
+ + +
+
{{i18n "user.muted_users_instructions"}}
-
{{i18n "user.muted_users_instructions"}}
-
+{{/if}} -{{#if this.currentUser.can_send_private_messages}} +{{#if this.model.can_send_private_messages}}