プロジェクト

全般

プロフィール

Vote #80523

未完了

Plugin API for adding a new notification

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Plugin API_20
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
20
version_id:
0
issue_org_id:
32545
author_id:
346460
assigned_to_id:
0
comments:
1
status_id:
1
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

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')



journals

--------------------------------------------------------------------------------

Admin Redmine さんが約2年前に更新

  • カテゴリPlugin API_20 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0