Class: ConversationsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



34
35
36
# File 'app/controllers/conversations_controller.rb', line 34

def create

end

#destroyObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/conversations_controller.rb', line 58

def destroy

  @conversation.move_to_trash(@actor)

  if params[:location].present?
    case params[:location]
    when 'conversation'
      redirect_to conversations_path(:box => :trash)
      return
    else
    redirect_to conversations_path(:box => @box,:page => params[:page])
    return
    end
  end
  redirect_to conversations_path(:box => @box,:page => params[:page])
end

#editObject



30
31
32
# File 'app/controllers/conversations_controller.rb', line 30

def edit

end

#indexObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/conversations_controller.rb', line 6

def index
  if @box.eql?"inbox"
    @conversations = Kaminari.paginate_array(@mailbox.inbox).page(params[:page]).per(9)
  elsif @box.eql?"sentbox"
    @conversations = Kaminari.paginate_array(@mailbox.sentbox).page(params[:page]).per(9)
  else
    @conversations = Kaminari.paginate_array(@mailbox.trash).page(params[:page]).per(9)
  end
end

#newObject



26
27
28
# File 'app/controllers/conversations_controller.rb', line 26

def new

end

#showObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/conversations_controller.rb', line 16

def show
  if @box.eql? 'trash'
    @receipts = @mailbox.receipts_for(@conversation).trash
  else
    @receipts = @mailbox.receipts_for(@conversation).not_trash
  end
  render :action => :show
  @receipts.mark_as_read
end

#updateObject



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

def update
  if params[:untrash].present?
  @conversation.untrash(@actor)
  end

  if params[:reply_all].present?
    last_receipt = @mailbox.receipts_for(@conversation).last
    @receipt = @actor.reply_to_all(last_receipt, params[:body])
  end

  if @box.eql? 'trash'
    @receipts = @mailbox.receipts_for(@conversation).trash
  else
    @receipts = @mailbox.receipts_for(@conversation).not_trash
  end
  redirect_to :action => :show
  @receipts.mark_as_read

end