Feature #32545
openPlugin API for adding a new notification
0%
Description
In lib/redmine/notifiable.rb, there is a TODO: Plugin API for adding a new notification?.
I found out that, one can provide this API via Redmine Hooks, although I dont know if this is the correct approach.
The patch below seems to be working at least for me (Redmine 4.0.5, ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]).
diff --git a/lib/redmine/notifiable.rb b/lib/redmine/notifiable.rb index 41fd736..822d216 100644 --- a/lib/redmine/notifiable.rb +++ b/lib/redmine/notifiable.rb @@ -21,6 +21,9 @@ module Redmine notifications << Notifiable.new('message_posted') notifications << Notifiable.new('wiki_content_added') notifications << Notifiable.new('wiki_content_updated') + Redmine::Hook.call_hook(:add_notifiable).each do |notifiable| + notifications += notifiable + end notifications end end
In any plugin
# In plugins/my_plugin/lib/hooks.rb module MyPluginHooks class MyPluginHooks < Redmine::Hook::Listener def add_notifiable(_context) [Redmine::Notifiable.new('my_plugin_new_notifiable')] end end end # In plugins/my_plugin/init.rb ... require_relative 'lib/hooks.rb' ... # Now we can use Setting.notified_events.include?('my_plugin_new_notifiable')
Updated by Go MAEDA almost 4 years ago
- Category changed from Email notifications to Plugin API
Updated by Vasiliy Gagarskiy over 1 year ago
Hong Cheu Lim wrote:
In lib/redmine/notifiable.rb, there is a TODO: Plugin API for adding a new notification?.
I found out that, one can provide this API via Redmine Hooks, although I dont know if this is the correct approach.
The patch below seems to be working at least for me (Redmine 4.0.5, ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]).[...]
In any plugin
[...]
Go MAEDA Do you have any thoughts about plugin API, maybe ROADMAP?
Updated by Go MAEDA over 1 year ago
- Target version set to Candidate for next major release