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 message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
25 title = message.title.sub(/^Re:\s*/, "Re: ")
26 redirect_to :action => 'new', :user_id => message.from_user_id, :title => title
27 rescue ActiveRecord::RecordNotFound
28 render :nothing => true, :status => :not_found
32 @title = 'read message'
33 @message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
34 @message.message_read = 1 if @message.to_user_id == @user.id
36 rescue ActiveRecord::RecordNotFound
37 render :nothing => true, :status => :not_found
42 if @user and params[:display_name] == @user.display_name
44 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
50 if @user and params[:display_name] == @user.display_name
52 redirect_to :controller => 'message', :action => 'outbox', :display_name => @user.display_name
57 if params[:message_id]
58 id = params[:message_id]
59 message = Message.find_by_id(id)
60 if params[:mark] == 'unread'
67 message.message_read = message_read
69 flash[:notice] = "Message marked as #{mark_type}"
70 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name