46 |
46 |
options[:no_account_notice] = (options[:no_account_notice].to_s == '1')
|
47 |
47 |
options[:no_notification] = (options[:no_notification].to_s == '1')
|
48 |
48 |
options[:no_permission_check] = (options[:no_permission_check].to_s == '1')
|
|
49 |
options[:find_by_subject] = (options[:find_by_subject].to_s == '1')
|
49 |
50 |
|
50 |
51 |
ActiveSupport::Notifications.instrument("receive.action_mailer") do |payload|
|
51 |
52 |
mail = Mail.new(raw_mail.b)
|
... | ... | |
69 |
70 |
%w(project status tracker category priority assigned_to fixed_version).each do |option|
|
70 |
71 |
options[:issue][option.to_sym] = env[option] if env[option]
|
71 |
72 |
end
|
72 |
|
%w(allow_override unknown_user no_permission_check no_account_notice no_notification default_group project_from_subaddress).each do |option|
|
|
73 |
%w(allow_override unknown_user no_permission_check no_account_notice no_notification default_group project_from_subaddress find_by_subject).each do |option|
|
73 |
74 |
options[option.to_sym] = env[option] if env[option]
|
74 |
75 |
end
|
75 |
76 |
if env['private']
|
... | ... | |
147 |
148 |
|
148 |
149 |
MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+(\.[a-f0-9]+)?@}
|
149 |
150 |
ISSUE_REPLY_SUBJECT_RE = %r{\[(?:[^\]]*\s+)?#(\d+)\]}
|
|
151 |
ISSUE_REPLY_SUBJECT_RE2 = %r{^(?:Re:\s*)*(.*)$}i
|
150 |
152 |
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
|
151 |
153 |
|
152 |
154 |
def dispatch
|
... | ... | |
164 |
166 |
receive_issue_reply(m[1].to_i)
|
165 |
167 |
elsif m = subject.match(MESSAGE_REPLY_SUBJECT_RE)
|
166 |
168 |
receive_message_reply(m[1].to_i)
|
|
169 |
elsif handler_options[:find_by_subject]
|
|
170 |
logger&.info("MailHandler: trying to find issue by subject")
|
|
171 |
if issue = Issue.find_by(:subject => subject)
|
|
172 |
logger&.info("MailHandler: found issue #{issue.id} using the full subject")
|
|
173 |
receive_issue_reply(issue.id)
|
|
174 |
elsif m = subject.match(ISSUE_REPLY_SUBJECT_RE2)
|
|
175 |
if issue = Issue.find_by(:subject => m[1])
|
|
176 |
logger&.info("MailHandler: found issue #{issue.id} using the subject regex")
|
|
177 |
receive_issue_reply(issue.id)
|
|
178 |
end
|
|
179 |
else
|
|
180 |
dispatch_to_default
|
|
181 |
end
|
167 |
182 |
else
|
168 |
183 |
dispatch_to_default
|
169 |
184 |
end
|