Project

General

Profile

Feature #13919 » 0002-Prevent-multiple-emails-from-being-sent-to-a-user.patch

Mizuki ISHIKAWA, 2020-04-16 04:47

View differences:

app/models/mailer.rb
93 93
  # Example:
94 94
  #   Mailer.deliver_issue_add(issue)
95 95
  def self.deliver_issue_add(issue)
96
    users = issue.notified_users | issue.notified_watchers
97

  
98
    users.each do |user|
99
      issue_add(user, issue).deliver_later
96
    notified_mentions = issue.notified_mentions
97
    notified_mentions.each do |user|
98
      issue_add(user, issue, 'mentioned').deliver_later
100 99
    end
101 100

  
102
    mentions = issue.notified_mentions
101
    users = (issue.notified_users | issue.notified_watchers) - notified_mentions
103 102
    users.each do |user|
104
      issue_add(user, issue, 'mentioned').deliver_later
103
      issue_add(user, issue).deliver_later
105 104
    end
106 105
  end
107 106

  
......
135 134
  # Example:
136 135
  #   Mailer.deliver_issue_edit(journal)
137 136
  def self.deliver_issue_edit(journal)
138
    users  = journal.notified_users | journal.notified_watchers
137
    notified_mentions = journal.journalized.notified_mentions | journal.notified_mentions
138
    notified_mentions.select! do |user|
139
      journal.notes? || journal.visible_details(user).any?
140
    end
141
    notified_mentions.each do |user|
142
      issue_edit(user, journal, 'mentioned').deliver_later
143
    end
139 144

  
145
    users  = (journal.notified_users | journal.notified_watchers) - notified_mentions
140 146
    users.select! do |user|
141 147
      journal.notes? || journal.visible_details(user).any?
142 148
    end
143 149
    users.each do |user|
144 150
      issue_edit(user, journal).deliver_later
145 151
    end
146

  
147
    notified_mentions = journal.journalized.notified_mentions | journal.notified_mentions
148
    notified_mentions.each do |user|
149
      issue_edit(user, journal, 'mentioned').deliver_later
150
    end
151 152
  end
152 153

  
153 154
  # Builds a mail to user about a new document.
(8-8/12)