DEV: Add hooks to allow overriding notify_user behavior (#23850)

Adds new plugin registry `:post_action_notify_user_handlers` and more!
This commit is contained in:
Mark VanLandingham
2023-10-10 12:21:57 -05:00
committed by GitHub
parent 38e7960082
commit f29c476521
5 changed files with 111 additions and 8 deletions

View File

@@ -58,7 +58,19 @@ module PostGuardian
if action_key == :notify_user &&
!@user.in_any_groups?(SiteSetting.personal_message_enabled_groups_map)
return false
# The modifier below is used to add additional permissions for notifying users.
# In core the only method of notifying a user is personal messages so we check if the
# user can PM. Plugins can extend the behavior of how users are notifier via `notify_user`
# post action, and this allows extension for that use case.
can_notify = false
can_notify =
DiscoursePluginRegistry.apply_modifier(
:post_guardian_can_notify_user,
can_notify,
self,
post,
)
return can_notify
end
# we allow flagging for trust level 1 and higher