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 = ? or from_user_id = ?", @user.id, @user.id ])
26 @message.message_read = 1 if @message.to_user_id == @user.id
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
42 if @user and params[:display_name] == @user.display_name
44 redirect_to :controller => 'message', :action => 'outbox', :display_name => @user.display_name
49 if params[:message_id]
50 id = params[:message_id]
51 message = Message.find_by_id(id)
52 if params[:mark] == 'unread'
59 message.message_read = message_read
61 flash[:notice] = "Message marked as #{mark_type}"
62 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name