Project

General

Profile

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

mark burdett, 2015-06-26 05:35

View differences:

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

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

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

  
252 266
  # Reply will be added to the issue
253 267
  def receive_journal_reply(journal_id)
254 268
    journal = Journal.find_by_id(journal_id)
(4-4/5)