Class: CustomerServiceIm::MessagesController
Instance Method Summary
collapse
#render_200, #render_401, #render_422, #render_500
Instance Method Details
#create ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/customer_service_im/messages_controller.rb', line 11
def create
@message = Message.new(message_params.merge( user: logged_user, receiver_type: "Staff" ))
if @message.save
render_200 message: @message
else
render_422 errors: @message.errors
end
end
|
#index ⇒ Object
7
8
9
|
# File 'app/controllers/customer_service_im/messages_controller.rb', line 7
def index
@messages = @conversation.messages.order("created_at desc")
end
|
#read ⇒ Object
40
41
42
43
44
45
46
|
# File 'app/controllers/customer_service_im/messages_controller.rb', line 40
def read
if @message.read!
render_200 message: @message
else
render_422 errors: @message.errors
end
end
|
#receive ⇒ Object
32
33
34
35
36
37
38
|
# File 'app/controllers/customer_service_im/messages_controller.rb', line 32
def receive
if @message.received!
render_200 message: @message
else
render_422 @message.errors
end
end
|
#reply ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/customer_service_im/messages_controller.rb', line 22
def reply
@message = Message.new(message_params.merge( staff: logged_user, receiver_type: "User" ))
if @message.save
render_200 message: @message
else
render_422 errors: @message.errors
end
end
|