b2d5cc7b05
Co-authored-by: Pranav Raj S <pranavrajs@gmail.com> Co-authored-by: Sojan Jose <sojan@pepalo.com>
29 lines
618 B
Ruby
29 lines
618 B
Ruby
class Messages::Outgoing::NormalBuilder
|
|
attr_reader :message
|
|
|
|
def initialize(user, conversation, params)
|
|
@content = params[:message]
|
|
@private = params[:private] || false
|
|
@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
|