Feature #38274 » 1-receive_news_comment_reply.patch
app/models/mail_handler.rb | ||
---|---|---|
305 | 305 |
end |
306 | 306 |
end |
307 | 307 | |
308 |
# Receives a reply to a news entry |
|
309 |
def receive_news_reply(news_id) |
|
310 |
news = News.find_by_id(news_id) |
|
311 |
if news.nil? |
|
312 |
raise MissingContainer, "reply to nonexistant news [#{news_id}]" |
|
313 |
end |
|
314 | ||
315 |
# Never receive emails to projects where adding news comments is not possible |
|
316 |
project = news.project |
|
317 |
raise NotAllowedInProject, "not possible to add news comments to project [#{project.name}]" unless project.allows_to?(:comment_news) |
|
318 | ||
319 |
unless handler_options[:no_permission_check] |
|
320 |
unless news.commentable?(user) |
|
321 |
raise InsufficientPermissions, "not allowed to comment on news item [#{news.id} #{news.title}]" |
|
322 |
end |
|
323 |
end |
|
324 | ||
325 |
comment = news.comments.new |
|
326 |
comment.author = user |
|
327 |
comment.comments = cleaned_up_text_body |
|
328 |
comment.save! |
|
329 |
comment |
|
330 |
end |
|
331 | ||
332 |
# Receives a reply to a comment to a news entry |
|
333 |
def receive_comment_reply(comment_id) |
|
334 |
comment = Comment.find_by_id(comment_id) |
|
335 | ||
336 |
if comment && comment.commented_type == 'News' |
|
337 |
receive_news_reply(comment.commented.id) |
|
338 |
else |
|
339 |
raise MissingContainer, "reply to nonexistant comment [#{comment_id}]" |
|
340 |
end |
|
341 |
end |
|
342 | ||
308 | 343 |
def add_attachments(obj) |
309 | 344 |
if email.attachments && email.attachments.any? |
310 | 345 |
email.attachments.each do |attachment| |