Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double notifications if redmine mention sent. #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require_dependency 'redmine_mentions/hooks'
require_dependency 'journal'
Journal.send(:include, RedmineMentions::JournalPatch)
Journal.prepend JournalNotifyPatch

end
Redmine::Plugin.register :redmine_mentions do
name 'Redmine Mentions'
Expand Down
12 changes: 12 additions & 0 deletions lib/redmine_mentions/journal_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def self.included(base)
after_create :send_mail

def send_mail
RequestStore.store[:redmine_mentions_notified] = false
if self.journalized.is_a?(Issue) && self.notes.present?
issue = self.journalized
project=self.journalized.project
Expand All @@ -17,11 +18,22 @@ def send_mail
username = mentioned_user.first[1..-1]
if user = User.find_by_login(username)
MentionMailer.notify_mentioning(issue, self, user).deliver
RequestStore.store[:redmine_mentions_notified] = true
end
end
end
end

end
end
end
end

# Patch Journal notify to avoid double emails
module JournalNotifyPatch
def send_notification
unless RequestStore.store[:redmine_mentions_notified]
super
end
end
end