1 class MessageController < ApplicationController
4 before_filter :authorize_web
5 before_filter :require_user
8 @title = 'send message'
10 @message = Message.new(params[:message])
11 @message.to_user_id = params[:user_id]
12 @message.from_user_id = @user.id
13 @message.sent_on = Time.now
16 flash[:notice] = 'Message sent'
17 Notifier::deliver_message_notification(@message)
18 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
24 @title = 'read message'
25 @message = Message.find(params[:message_id], :conditions => ["to_user_id = ?", @user.id])
26 @message.message_read = 1
28 rescue ActiveRecord::RecordNotFound
29 render :nothing => true, :status => :not_found
34 if @user and params[:display_name] == @user.display_name
36 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
41 if params[:message_id]
42 id = params[:message_id]
43 message = Message.find_by_id(id)
44 if params[:mark] == 'unread'
51 message.message_read = message_read
53 flash[:notice] = "Message marked as #{mark_type}"
54 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name