217 |
217 |
|
218 |
218 |
# Adds a note to an existing issue
|
219 |
219 |
def receive_issue_reply(issue_id, from_journal=nil)
|
220 |
|
issue = Issue.find_by_id(issue_id)
|
221 |
|
return unless issue
|
|
220 |
issue = Issue.find_by(:id => issue_id)
|
|
221 |
if issue.nil?
|
|
222 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent issue"
|
|
223 |
return nil
|
|
224 |
end
|
|
225 |
|
222 |
226 |
# check permission
|
223 |
227 |
unless handler_options[:no_permission_check]
|
224 |
228 |
unless user.allowed_to?(:add_issue_notes, issue.project) ||
|
... | ... | |
249 |
253 |
|
250 |
254 |
# Reply will be added to the issue
|
251 |
255 |
def receive_journal_reply(journal_id)
|
252 |
|
journal = Journal.find_by_id(journal_id)
|
253 |
|
if journal && journal.journalized_type == 'Issue'
|
|
256 |
journal = Journal.find_by(:id => journal_id)
|
|
257 |
if journal.nil?
|
|
258 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent journal"
|
|
259 |
return nil
|
|
260 |
end
|
|
261 |
|
|
262 |
if journal.journalized_type == 'Issue'
|
254 |
263 |
receive_issue_reply(journal.journalized_id, journal)
|
|
264 |
else
|
|
265 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a journal whose journalized_type is not Issue"
|
|
266 |
return nil
|
255 |
267 |
end
|
256 |
268 |
end
|
257 |
269 |
|
258 |
270 |
# Receives a reply to a forum message
|
259 |
271 |
def receive_message_reply(message_id)
|
260 |
|
message = Message.find_by_id(message_id)
|
261 |
|
if message
|
262 |
|
message = message.root
|
|
272 |
message = Message.find_by(:id => message_id)&.root
|
|
273 |
if message.nil?
|
|
274 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent message"
|
|
275 |
return nil
|
|
276 |
end
|
263 |
277 |
|
264 |
|
unless handler_options[:no_permission_check]
|
265 |
|
raise UnauthorizedAction, "not allowed to add messages to project [#{project.name}]" unless user.allowed_to?(:add_messages, message.project)
|
266 |
|
end
|
|
278 |
unless handler_options[:no_permission_check]
|
|
279 |
raise UnauthorizedAction, "not allowed to add messages to project [#{project.name}]" unless user.allowed_to?(:add_messages, message.project)
|
|
280 |
end
|
267 |
281 |
|
268 |
|
if !message.locked?
|
269 |
|
reply = Message.new(:subject => cleaned_up_subject.gsub(%r{^.*msg\d+\]}, '').strip,
|
270 |
|
:content => cleaned_up_text_body)
|
271 |
|
reply.author = user
|
272 |
|
reply.board = message.board
|
273 |
|
message.children << reply
|
274 |
|
add_attachments(reply)
|
275 |
|
reply
|
276 |
|
else
|
277 |
|
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a locked topic"
|
278 |
|
end
|
|
282 |
if !message.locked?
|
|
283 |
reply = Message.new(:subject => cleaned_up_subject.gsub(%r{^.*msg\d+\]}, '').strip,
|
|
284 |
:content => cleaned_up_text_body)
|
|
285 |
reply.author = user
|
|
286 |
reply.board = message.board
|
|
287 |
message.children << reply
|
|
288 |
add_attachments(reply)
|
|
289 |
reply
|
|
290 |
else
|
|
291 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a locked topic"
|
279 |
292 |
end
|
280 |
293 |
end
|
281 |
294 |
|