155 |
155 |
# the subject may contains alien issue IDs. Let's check if one of the issue IDs is proper
|
156 |
156 |
issue_id = get_issue_id_from_subject(subject)
|
157 |
157 |
receive_issue_reply(issue_id)
|
|
158 |
elsif m = subject.match(ISSUE_REPLY_SUBJECT_RE_ISSUE_ID)
|
|
159 |
# the subject may contains alien issue IDs. Let's check if one of the issue IDs is proper
|
|
160 |
logger.info "vmn Analyze the subject" if logger
|
|
161 |
issue = get_issue_from_subject_issue_id(subject)
|
|
162 |
logger.info "vmn issue found: " + issue.to_yaml if logger
|
|
163 |
receive_issue_reply(issue)
|
158 |
164 |
elsif m = subject.match(MESSAGE_REPLY_SUBJECT_RE)
|
159 |
165 |
receive_message_reply(m[1].to_i)
|
160 |
166 |
else
|
... | ... | |
186 |
192 |
return
|
187 |
193 |
end
|
188 |
194 |
|
|
195 |
ISSUE_REPLY_SUBJECT_RE_ISSUE_ID = %r{\[[^\]]*#([A-Z][A-Z0-9]*-\d+)\]}
|
|
196 |
def get_issue_from_subject_issue_id(subject)
|
|
197 |
scan_result = subject.scan(ISSUE_REPLY_SUBJECT_RE_ISSUE_ID)
|
|
198 |
scan_result.each do |match|
|
|
199 |
issue_id = match[0]
|
|
200 |
issue = Issue.find(issue_id)
|
|
201 |
if issue
|
|
202 |
# we can get an email with more than 1 proper issue ID. Let's return 1-st as it was in the original code.
|
|
203 |
return issue
|
|
204 |
end
|
|
205 |
end
|
|
206 |
# no matches
|
|
207 |
return
|
|
208 |
end
|
|
209 |
|
189 |
210 |
def dispatch_to_default
|
190 |
211 |
receive_issue
|
191 |
212 |
end
|
... | ... | |
217 |
238 |
|
218 |
239 |
# Adds a note to an existing issue
|
219 |
240 |
def receive_issue_reply(issue_id, from_journal=nil)
|
220 |
|
issue = Issue.find_by_id(issue_id)
|
|
241 |
if issue_id.is_a?(Issue)
|
|
242 |
issue = issue_id
|
|
243 |
else
|
|
244 |
issue = Issue.find_by_id(issue_id)
|
|
245 |
end
|
221 |
246 |
return unless issue
|
222 |
247 |
# check permission
|
223 |
248 |
unless @@handler_options[:no_permission_check]
|
... | ... | |
449 |
474 |
#Loofah works bad with nested div contains br, so let's help to it and preparse the body
|
450 |
475 |
body.gsub! /<[bB][rR]>/, "\n"
|
451 |
476 |
# convert html parts to text
|
|
477 |
require 'loofah/helpers'
|
452 |
478 |
p.mime_type == 'text/html' ? Loofah.document(body).to_text : body
|
453 |
479 |
end.join("\r\n")
|
454 |
480 |
|
455 |
|
-
|