Project

General

Profile

Patch #12813 » redmine-issue-reply-match-by-subject.patch

mark burdett, 2016-01-28 03:14

View differences:

app/models/mail_handler.rb (working copy)
155 155
  MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
156 156
  ISSUE_REPLY_SUBJECT_RE = %r{\[(?:[^\]]*\s+)?#(\d+)\]}
157 157
  MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
158
  ISSUE_REPLY_MATCH_ISSUE_SUBJECT_RE = %r{^Re: (.+)$}
158 159

  
159 160
  def dispatch
160 161
    headers = [email.in_reply_to, email.references].flatten.compact
......
171 172
      receive_issue_reply(m[1].to_i)
172 173
    elsif m = subject.match(MESSAGE_REPLY_SUBJECT_RE)
173 174
      receive_message_reply(m[1].to_i)
175
    elsif m = subject.match(ISSUE_REPLY_MATCH_ISSUE_SUBJECT_RE)
176
      receive_issue_reply_subject(m[1].to_s, m[0].to_s)
174 177
    else
175 178
      dispatch_to_default
176 179
    end
......
251 254
    journal
252 255
  end
253 256

  
257
  # Adds a note to an existing issue, matched by subject
258
  def receive_issue_reply_subject(issue_subject, re_issue_subject)
259
    if issue = Issue.where(subject: issue_subject).last
260
      receive_issue_reply(issue.id)
261
    elsif issue = Issue.where(subject: re_issue_subject).last
262
      receive_issue_reply(issue.id)
263
    else
264
      receive_issue
265
    end
266
  end
267

  
254 268
  # Reply will be added to the issue
255 269
  def receive_journal_reply(journal_id)
256 270
    journal = Journal.find_by_id(journal_id)
(5-5/5)