Class: MessagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /messages POST /messages.xml



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/messages_controller.rb', line 38

def create
  @recipients = 
    if params[:_recipients].present?
      @recipients = params[:_recipients].split(',').map{ |r| Actor.find(r) }
    else
      []
    end

  @receipt = @actor.send_message(@recipients, params[:body], params[:subject])
  if (@receipt.errors.blank?)
    @conversation = @receipt.conversation
    flash[:success]= t('mailboxer.sent')
    redirect_to conversation_path(@conversation, :box => :sentbox)
  else
    render :action => :new
  end
end

#destroyObject

DELETE /messages/1 DELETE /messages/1.xml



64
65
66
# File 'app/controllers/messages_controller.rb', line 64

def destroy

end

#editObject

GET /messages/1/edit



32
33
34
# File 'app/controllers/messages_controller.rb', line 32

def edit

end

#indexObject



5
6
7
# File 'app/controllers/messages_controller.rb', line 5

def index
  redirect_to conversations_path(:box => @box)
end

#newObject

GET /messages/new GET /messages/new.xml



23
24
25
26
27
28
29
# File 'app/controllers/messages_controller.rb', line 23

def new
  if params[:receiver].present?
    @recipient = Actor.find_by_slug(params[:receiver])
    return if @recipient.nil?
    @recipient = nil if Actor.normalize(@recipient)==Actor.normalize(current_subject)
  end
end

#showObject

GET /messages/1 GET /messages/1.xml



11
12
13
14
15
16
17
18
19
# File 'app/controllers/messages_controller.rb', line 11

def show
  if @message = Message.find_by_id(params[:id]) and @conversation = @message.conversation
    if @conversation.is_participant?(@actor)
      redirect_to conversation_path(@conversation, :box => @box, :anchor => "message_" + @message.id.to_s)
    return
    end
  end
  redirect_to conversations_path(:box => @box)
end

#updateObject

PUT /messages/1 PUT /messages/1.xml



58
59
60
# File 'app/controllers/messages_controller.rb', line 58

def update

end