2020-06-07 08:28:05 +00:00
|
|
|
class Api::V1::Accounts::Conversations::MessagesController < Api::V1::Accounts::Conversations::BaseController
|
2020-03-08 16:38:25 +00:00
|
|
|
def index
|
|
|
|
@messages = message_finder.perform
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
|
|
|
|
def create
|
2020-06-27 16:04:53 +00:00
|
|
|
user = current_user || @resource
|
2020-07-21 06:45:24 +00:00
|
|
|
mb = Messages::MessageBuilder.new(user, @conversation, params)
|
2019-08-14 09:48:44 +00:00
|
|
|
@message = mb.perform
|
2020-07-21 06:45:24 +00:00
|
|
|
rescue StandardError => e
|
|
|
|
render_could_not_create_error(e.message)
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
2020-03-08 16:38:25 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def message_finder
|
|
|
|
@message_finder ||= MessageFinder.new(@conversation, params)
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|