2019-08-14 09:48:44 +00:00
|
|
|
class Messages::Outgoing::NormalBuilder
|
|
|
|
attr_reader :message
|
|
|
|
|
2019-10-20 08:47:26 +00:00
|
|
|
def initialize(user, conversation, params)
|
2019-08-14 09:48:44 +00:00
|
|
|
@content = params[:message]
|
2019-10-20 08:47:26 +00:00
|
|
|
@private = ['1', 'true', 1].include? params[:private]
|
2019-08-14 09:48:44 +00:00
|
|
|
@conversation = conversation
|
|
|
|
@user = user
|
|
|
|
@fb_id = params[:fb_id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform
|
|
|
|
@message = @conversation.messages.create!(message_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def message_params
|
|
|
|
{
|
|
|
|
account_id: @conversation.account_id,
|
|
|
|
inbox_id: @conversation.inbox_id,
|
|
|
|
message_type: :outgoing,
|
|
|
|
content: @content,
|
|
|
|
private: @private,
|
|
|
|
user_id: @user.id,
|
|
|
|
fb_id: @fb_id
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|