diff --git a/README.md b/README.md index 4e06109..dc46470 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,9 @@ These mentioned models are tracked with the corresponding actions. Internally Ra "id": 1, "current_user_id": 1, "member_id": 1, - "role_id": 1 + "role_id": 1, + "project_id": 1, + "user_id": 1 } ``` diff --git a/app/models/redis_notification.rb b/app/models/redis_notification.rb index 1a29000..4a142ef 100644 --- a/app/models/redis_notification.rb +++ b/app/models/redis_notification.rb @@ -45,10 +45,9 @@ def self.track(action, subject) current_user_id: User&.current&.id } - ['project_id', 'issue_id', 'user_id', 'member_id', 'role_id'].each do |attribute| - if subject.has_attribute?(attribute) - attributes[:additional_data] = Hash(attributes[:additional_data]).merge({attribute.to_sym => subject.send(attribute)}) - end + attributes[:additional_data] = get_additional_data(subject, attributes[:additional_data]) + if attributes[:additional_data] && attributes[:additional_data].key?(:member_id) + attributes[:additional_data] = Hash(attributes[:additional_data]).merge(get_additional_data(subject.member, attributes[:additional_data])) end create(attributes) @@ -68,4 +67,16 @@ def self.notification_table_exists? def publish RedmineRedisNotifier::Publisher.new(self).publish end + + private + + def self.get_additional_data(subject, additional_data) + ["project_id", "issue_id", "user_id", "member_id", "role_id"].each do |attribute| + if subject.has_attribute?(attribute) + additional_data = Hash(additional_data).merge({attribute.to_sym => subject.send(attribute)}) + end + end + + additional_data + end end diff --git a/app/views/redis_notifications/index.html.erb b/app/views/redis_notifications/index.html.erb index db3b226..c44612a 100644 --- a/app/views/redis_notifications/index.html.erb +++ b/app/views/redis_notifications/index.html.erb @@ -29,7 +29,7 @@ <% when "Member" %> <%= link_to redis_notification.subject.project.name, settings_project_path(redis_notification.subject.project, tab: "members") %> <% when "MemberRole" %> - <%= link_to redis_notification.subject.member.user.login, user_path(redis_notification.subject.member.user) %> + <%= link_to redis_notification.subject.member.project.name, settings_project_path(redis_notification.subject.member.project, tab: "members") %> <% when "Issue" %> <%= link_to redis_notification.subject.subject, issue_path(redis_notification.subject) %> <% when "User" %>