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 |
unless (issue = Issue.find_by(:id => issue_id))
|
|
221 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent issue"
|
|
222 |
return nil
|
|
223 |
end
|
|
224 |
|
222 |
225 |
# check permission
|
223 |
226 |
unless handler_options[:no_permission_check]
|
224 |
227 |
unless user.allowed_to?(:add_issue_notes, issue.project) ||
|
... | ... | |
231 |
234 |
handler_options[:issue] = {}
|
232 |
235 |
|
233 |
236 |
journal = issue.init_journal(user)
|
234 |
|
if from_journal && from_journal.private_notes?
|
|
237 |
if from_journal&.private_notes?
|
235 |
238 |
# If the received email was a reply to a private note, make the added note private
|
236 |
239 |
issue.private_notes = true
|
237 |
240 |
end
|
... | ... | |
257 |
260 |
|
258 |
261 |
# Receives a reply to a forum message
|
259 |
262 |
def receive_message_reply(message_id)
|
260 |
|
message = Message.find_by_id(message_id)
|
261 |
|
if message
|
262 |
|
message = message.root
|
|
263 |
unless (message = Message.find_by(:id => message_id))
|
|
264 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent message"
|
|
265 |
return
|
|
266 |
end
|
263 |
267 |
|
264 |
|
unless handler_options[:no_permission_check]
|
265 |
|
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
|
266 |
|
end
|
|
268 |
message = message.root
|
267 |
269 |
|
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
|
|
270 |
unless handler_options[:no_permission_check]
|
|
271 |
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
|
|
272 |
end
|
|
273 |
|
|
274 |
if !message.locked?
|
|
275 |
reply = Message.new(:subject => cleaned_up_subject.gsub(/^.*msg\d+\]/, '').strip,
|
|
276 |
:content => cleaned_up_text_body)
|
|
277 |
reply.author = user
|
|
278 |
reply.board = message.board
|
|
279 |
message.children << reply
|
|
280 |
add_attachments(reply)
|
|
281 |
reply
|
|
282 |
else
|
|
283 |
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a locked topic"
|
279 |
284 |
end
|
280 |
285 |
end
|
281 |
286 |
|