Class: API::V1::ConversationsController
Instance Method Summary
collapse
allow_query_on, #allowed_fields, #authenticate_filter, #load_resource_by_query, #set_csrf_cookie_for_ng
#set_locale
Instance Method Details
#create ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'app/controllers/faalis/api/v1/conversations_controller.rb', line 8
def create
recipient_emails = message_params(:recipients).split(',')
recipients = User.where(email: recipient_emails).all
@conversation = current_user.
send_message(recipients, *message_params(:body, :subject)).conversation
respond_with(@conversation)
end
|
#destroy ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/faalis/api/v1/conversations_controller.rb', line 41
def destroy
ids = params[:id].split(",")
ids.each do |id|
conversation = current_user.mailbox.conversations.find(params[:id])
current_user.mark_as_deleted conversation
end
respond_with
end
|
#index ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/faalis/api/v1/conversations_controller.rb', line 51
def index
if params[:box] == "inbox"
box = "inbox"
elsif params[:box] == "sentbox"
box = "sentbox"
elsif params[:box] == "trash"
box = "trash"
else
respond_to do |f|
f.any { head :not_found }
end
returng
end
@mailbox ||= current_user.mailbox.send(box.to_sym)
respond_with @mailbox
end
|
#reply ⇒ Object
19
20
21
22
|
# File 'app/controllers/faalis/api/v1/conversations_controller.rb', line 19
def reply
@conversation = current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
respond_with(@conversation)
end
|
#show ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'app/controllers/faalis/api/v1/conversations_controller.rb', line 70
def show
@conversations ||= current_user.mailbox.conversations.find(params[:id])
@current_user = current_user
end
|
#trash ⇒ Object
24
25
26
27
28
29
30
|
# File 'app/controllers/faalis/api/v1/conversations_controller.rb', line 24
def trash
ids = params[:id].split(",")
ids.each do |id|
conversation = current_user.mailbox.conversations.find(params[:id])
conversation.move_to_trash(current_user)
end
end
|
#untrash ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'app/controllers/faalis/api/v1/conversations_controller.rb', line 32
def untrash
ids = params[:id].split(",")
ids.each do |id|
conversation = current_user.mailbox.conversations.find(params[:id])
conversation.untrash(current_user)
end
end
|