Project

General

Profile

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

mark burdett, 2013-08-16 03:09

View differences:

mail_handler.rb (working copy)
139 139
  MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
140 140
  ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
141 141
  MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
142
  ISSUE_REPLY_MATCH_ISSUE_SUBJECT_RE = %r{^Re: (.+)$}
142 143

  
143 144
  def dispatch
144 145
    headers = [email.in_reply_to, email.references].flatten.compact
......
155 156
      receive_issue_reply(m[1].to_i)
156 157
    elsif m = subject.match(MESSAGE_REPLY_SUBJECT_RE)
157 158
      receive_message_reply(m[1].to_i)
159
    elsif m = subject.match(ISSUE_REPLY_MATCH_ISSUE_SUBJECT_RE)
160
      receive_issue_reply_subject(m[1].to_s, m[0].to_s)
158 161
    else
159 162
      dispatch_to_default
160 163
    end
......
230 233
    journal
231 234
  end
232 235

  
236
  # Adds a note to an existing issue, matched by subject
237
  def receive_issue_reply_subject(issue_subject, re_issue_subject)
238
    if issue = Issue.find_last_by_subject(issue_subject)
239
      receive_issue_reply(issue.id)
240
    elsif issue = Issue.find_last_by_subject(re_issue_subject)
241
      receive_issue_reply(issue.id)
242
    else
243
      receive_issue
244
    end
245
  end
246

  
233 247
  # Reply will be added to the issue
234 248
  def receive_journal_reply(journal_id)
235 249
    journal = Journal.find_by_id(journal_id)
(3-3/5)