-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
43 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
ruby: ['2.7'] | ||
ruby: ['3.1'] | ||
db: ['postgres'] | ||
fail-fast: false | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
module RedmineNotified | ||
|
||
class Hooks < Redmine::Hook::ViewListener | ||
#adds our css on each page | ||
def view_layouts_base_html_head(context) | ||
stylesheet_link_tag('plugin', :plugin => "redmine_notified") | ||
end | ||
end | ||
|
||
class ModelHook < Redmine::Hook::Listener | ||
def after_plugins_loaded(_context = {}) | ||
require_relative 'mail_notifications_subscriber' | ||
require_relative 'notifications_association_patch' | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
ActiveSupport::Notifications.subscribe "deliver.action_mailer" do |name, start, finish, id, payload| | ||
attrs = payload.dup.stringify_keys | ||
%w(from to cc bcc).each do |key| | ||
attrs[key] = attrs[key].join(", ") if attrs.has_key?(key) && attrs[key].is_a?(Enumerable) | ||
end | ||
attrs['mail'] = nil | ||
begin | ||
new_notif = Notification.new(attrs.slice(*Notification.column_names)) | ||
new_notif.infer_object_from_message_id | ||
old_notif = Notification.where(:notificable_type => new_notif.notificable_type, :notificable_id => new_notif.notificable_id).first | ||
if old_notif | ||
bcc = [] | ||
bcc |= old_notif.bcc.split(', ') if old_notif.bcc.present? | ||
bcc |= new_notif.bcc.split(', ') if new_notif.bcc.present? | ||
old_notif.bcc = bcc.join(", ") | ||
old_notif.save | ||
else | ||
new_notif.save | ||
module RedmineNotified | ||
module MailNotificationsSubscriber | ||
ActiveSupport::Notifications.subscribe "deliver.action_mailer" do |name, start, finish, id, payload| | ||
attrs = payload.dup.stringify_keys | ||
%w(from to cc bcc).each do |key| | ||
attrs[key] = attrs[key].join(", ") if attrs.has_key?(key) && attrs[key].is_a?(Enumerable) | ||
end | ||
attrs['mail'] = nil | ||
begin | ||
new_notif = Notification.new(attrs.slice(*Notification.column_names)) | ||
new_notif.infer_object_from_message_id | ||
old_notif = Notification.where(:notificable_type => new_notif.notificable_type, :notificable_id => new_notif.notificable_id).first | ||
if old_notif | ||
bcc = [] | ||
bcc |= old_notif.bcc.split(', ') if old_notif.bcc.present? | ||
bcc |= new_notif.bcc.split(', ') if new_notif.bcc.present? | ||
old_notif.bcc = bcc.join(", ") | ||
old_notif.save | ||
else | ||
new_notif.save | ||
end | ||
rescue | ||
#this shouldn't happen, but hey, we don't want to prevent ticket creation if anything fails | ||
Rails.logger.error("ERROR: redmine_notified plugin, unable to add notification for #{attrs.inspect}") | ||
end | ||
end | ||
rescue | ||
#this shouldn't happen, but hey, we don't want to prevent ticket creation if anything fails | ||
Rails.logger.error("ERROR: redmine_notified plugin, unable to add notification for #{attrs.inspect}") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters