mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add modifiers for plugins to customize push notification translation arguments (#25889)
This commit is contained in:
committed by
GitHub
parent
eea7af09fd
commit
b426f85a81
@@ -60,6 +60,11 @@ module Jobs
|
||||
|
||||
translation_args = { username: @creator.username }
|
||||
translation_args[:channel] = @chat_channel.title(user) unless @is_direct_message_channel
|
||||
translation_args =
|
||||
DiscoursePluginRegistry.apply_modifier(
|
||||
:chat_notification_translation_args,
|
||||
translation_args,
|
||||
)
|
||||
|
||||
payload = {
|
||||
username: @creator.username,
|
||||
|
||||
@@ -62,6 +62,29 @@ RSpec.describe Jobs::Chat::NotifyWatching do
|
||||
)
|
||||
end
|
||||
|
||||
context "with chat_notification_translation_args plugin_modifier" do
|
||||
let(:modifier_block) do
|
||||
Proc.new do |args|
|
||||
args[:username] = "Hijacked"
|
||||
args
|
||||
end
|
||||
end
|
||||
it "Allows for changes to the translation args" do
|
||||
plugin_instance = Plugin::Instance.new
|
||||
plugin_instance.register_modifier(:chat_notification_translation_args, &modifier_block)
|
||||
|
||||
messages = notification_messages_for(user2)
|
||||
|
||||
expect(messages.first.data[:translated_title]).to start_with("Hijacked")
|
||||
ensure
|
||||
DiscoursePluginRegistry.unregister_modifier(
|
||||
plugin_instance,
|
||||
:chat_notification_translation_args,
|
||||
&modifier_block
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when the channel is muted via membership preferences" do
|
||||
before { membership2.update!(muted: true) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user