Chatwoot/app/builders/messages/outgoing/normal_builder.rb
Pranav Raj S 272c481464
Feature: Create conversations from Tweets (#470)
* Feature: Add tweets to conversations
2020-02-09 15:47:48 +05:30

29 lines
641 B
Ruby

class Messages::Outgoing::NormalBuilder
attr_reader :message
def initialize(user, conversation, params)
@content = params[:message]
@private = ['1', 'true', 1, true].include? params[:private]
@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,
source_id: @fb_id
}
end
end