2 class RepliesController < ApplicationController
5 before_action :authorize_web
6 before_action :set_locale
8 authorize_resource :class => Message
10 before_action :check_database_readable
11 before_action :check_database_writable
13 allow_thirdparty_images
15 # Allow the user to reply to another message.
17 message = Message.find(params[:message_id])
19 if message.recipient == current_user
20 message.update(:message_read => true)
22 @message = Message.new(
23 :recipient => message.sender,
24 :title => "Re: #{message.title.sub(/^Re:\s*/, '')}",
25 :body => "On #{message.sent_on} #{message.sender.display_name} wrote:\n\n#{message.body.gsub(/^/, '> ')}"
28 @title = @message.title
31 elsif message.sender == current_user
32 @message = Message.new(
33 :recipient => message.recipient,
34 :title => "Re: #{message.title.sub(/^Re:\s*/, '')}",
35 :body => "On #{message.sent_on} #{message.sender.display_name} wrote:\n\n#{message.body.gsub(/^/, '> ')}"
38 @title = @message.title
42 flash[:notice] = t ".wrong_user", :user => current_user.display_name
43 redirect_to login_path(:referer => request.fullpath)
45 rescue ActiveRecord::RecordNotFound
46 @title = t "messages.no_such_message.title"
47 render "messages/no_such_message", :status => :not_found