Compare commits
24 commits
develop
...
chore/rena
Author | SHA1 | Date | |
---|---|---|---|
|
4af3884e35 | ||
|
d773978b67 | ||
|
69077770ac | ||
|
31e3979dff | ||
|
2414b19835 | ||
|
b7c031f615 | ||
|
124b100643 | ||
|
da90e2b4d9 | ||
|
aa2cafa6a8 | ||
|
b062f01407 | ||
|
94ae007541 | ||
|
49ca3b09ca | ||
|
74c2aed657 | ||
|
6ebb2250e4 | ||
|
dc9b3db9b1 | ||
|
f8f0d36636 | ||
|
bedec53f0f | ||
|
41e3b9184c | ||
|
f2d03eff29 | ||
|
234ab021f8 | ||
|
8a9cde641a | ||
|
51deccfadd | ||
|
90e68c51f3 | ||
|
853b7db562 |
24 changed files with 39 additions and 30 deletions
|
@ -4,7 +4,7 @@ class Messages::MessageBuilder
|
|||
|
||||
def initialize(user, conversation, params)
|
||||
@params = params
|
||||
@private = params[:private] || false
|
||||
@is_private_note = params[:is_private_note] || params[:private] || false
|
||||
@conversation = conversation
|
||||
@user = user
|
||||
@message_type = params[:message_type] || 'outgoing'
|
||||
|
@ -58,7 +58,7 @@ class Messages::MessageBuilder
|
|||
inbox_id: @conversation.inbox_id,
|
||||
message_type: message_type,
|
||||
content: @params[:content],
|
||||
private: @private,
|
||||
is_private_note: @is_private_note,
|
||||
sender: sender,
|
||||
content_type: @params[:content_type],
|
||||
items: @items,
|
||||
|
|
|
@ -17,7 +17,7 @@ class MessageFinder
|
|||
def messages
|
||||
return conversation_messages if @params[:filter_internal_messages].blank?
|
||||
|
||||
conversation_messages.where.not('private = ? OR message_type = ?', true, 2)
|
||||
conversation_messages.where.not('is_private_note = ? OR message_type = ?', true, 2)
|
||||
end
|
||||
|
||||
def current_messages
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
:sender="data.sender"
|
||||
:is-a-tweet="isATweet"
|
||||
:is-email="isEmailContentType"
|
||||
:is-private="data.private"
|
||||
:is-private="data.is_private_note"
|
||||
:message-type="data.message_type"
|
||||
:readable-time="readableTime"
|
||||
:source-id="data.source_id"
|
||||
|
@ -197,7 +197,7 @@ export default {
|
|||
bubbleClass() {
|
||||
return {
|
||||
bubble: this.isBubble,
|
||||
'is-private': this.data.private,
|
||||
'is-private': this.data.is_private_note,
|
||||
'is-image': this.hasImageAttachment,
|
||||
'is-text': this.hasText,
|
||||
'is-from-bot': this.isSentByBot,
|
||||
|
|
|
@ -12,7 +12,7 @@ export default {
|
|||
chat =>
|
||||
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
|
||||
chat.message_type === 0 &&
|
||||
chat.private !== true
|
||||
chat.is_private_note !== true
|
||||
).length;
|
||||
},
|
||||
readMessages(m) {
|
||||
|
|
|
@ -58,7 +58,7 @@ const getters = {
|
|||
chatMessage =>
|
||||
chatMessage.created_at * 1000 > chat.agent_last_seen_at * 1000 &&
|
||||
chatMessage.message_type === 0 &&
|
||||
chatMessage.private !== true
|
||||
chatMessage.is_private_note !== true
|
||||
).length;
|
||||
},
|
||||
getChatStatusFilter: ({ chatStatusFilter }) => chatStatusFilter,
|
||||
|
|
|
@ -117,7 +117,7 @@ class ActionCableListener < BaseListener
|
|||
end
|
||||
|
||||
def contact_token(contact, message)
|
||||
return [] if message.private?
|
||||
return [] if message.is_private_note?
|
||||
return [] if message.activity?
|
||||
return [] if contact.nil?
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class NotificationListener < BaseListener
|
|||
end
|
||||
|
||||
def generate_notifications_for_mentions(message, account)
|
||||
return unless message.private?
|
||||
return unless message.is_private_note?
|
||||
|
||||
return if message.content.blank?
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
# content_attributes :json
|
||||
# content_type :integer default("text")
|
||||
# external_source_ids :jsonb
|
||||
# is_private_note :boolean default(FALSE)
|
||||
# message_type :integer not null
|
||||
# private :boolean default(FALSE)
|
||||
# sender_type :string
|
||||
# status :integer default("sent")
|
||||
# created_at :datetime not null
|
||||
|
@ -64,7 +64,7 @@ class Message < ApplicationRecord
|
|||
|
||||
# .succ is a hack to avoid https://makandracards.com/makandra/1057-why-two-ruby-time-objects-are-not-equal-although-they-appear-to-be
|
||||
scope :unread_since, ->(datetime) { where('EXTRACT(EPOCH FROM created_at) > (?)', datetime.to_i.succ) }
|
||||
scope :chat, -> { where.not(message_type: :activity).where(private: false) }
|
||||
scope :chat, -> { where.not(message_type: :activity).where(is_private_note: false) }
|
||||
scope :today, -> { where("date_trunc('day', created_at) = ?", Date.current) }
|
||||
default_scope { order(created_at: :asc) }
|
||||
|
||||
|
@ -118,7 +118,8 @@ class Message < ApplicationRecord
|
|||
created_at: created_at,
|
||||
message_type: message_type,
|
||||
content_type: content_type,
|
||||
private: private,
|
||||
private: is_private_note, # TODO: deprecate in future
|
||||
is_private_note: is_private_note,
|
||||
content_attributes: content_attributes,
|
||||
source_id: source_id,
|
||||
sender: sender.try(:webhook_data),
|
||||
|
@ -171,7 +172,7 @@ class Message < ApplicationRecord
|
|||
|
||||
def email_notifiable_message?
|
||||
return false unless outgoing?
|
||||
return false if private?
|
||||
return false if is_private_note?
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ class Base::SendOnChannelService
|
|||
def invalid_message?
|
||||
# private notes aren't send to the channels
|
||||
# we should also avoid the case of message loops, when outgoing messages are created from channel
|
||||
message.private? || outgoing_message_originated_from_channel?
|
||||
message.is_private_note? || outgoing_message_originated_from_channel?
|
||||
end
|
||||
|
||||
def validate_target_channel
|
||||
|
|
|
@ -7,7 +7,9 @@ json.message_type message.message_type_before_type_cast
|
|||
json.content_type message.content_type
|
||||
json.content_attributes message.content_attributes
|
||||
json.created_at message.created_at.to_i
|
||||
json.private message.private
|
||||
# to be deprecated
|
||||
json.private message.is_private_note
|
||||
json.is_private_note message.is_private_note
|
||||
json.source_id message.source_id
|
||||
json.sender message.sender.push_event_data if message.sender
|
||||
json.attachments message.attachments.map(&:push_event_data) if message.attachments.present?
|
||||
|
|
|
@ -4,7 +4,8 @@ json.inbox_id @message.inbox_id
|
|||
json.conversation_id @message.conversation.display_id
|
||||
json.message_type @message.message_type_before_type_cast
|
||||
json.created_at @message.created_at.to_i
|
||||
json.private @message.private
|
||||
json.private @message.is_private_note # TODO: Remove in future
|
||||
json.is_private_note @message.is_private_note
|
||||
json.source_id @message.source_id
|
||||
json.attachments @message.attachments.map(&:push_event_data) if @message.attachments.present?
|
||||
json.sender @message.sender.push_event_data if @message.sender
|
||||
|
|
5
db/migrate/20200903111035_rename_message_private.rb
Normal file
5
db/migrate/20200903111035_rename_message_private.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class RenameMessagePrivate < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
rename_column :messages, :private, :is_private_note
|
||||
end
|
||||
end
|
|
@ -415,7 +415,7 @@ ActiveRecord::Schema.define(version: 2021_05_27_173755) do
|
|||
t.integer "message_type", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "private", default: false
|
||||
t.boolean "is_private_note", default: false
|
||||
t.integer "status", default: 0
|
||||
t.string "source_id"
|
||||
t.integer "content_type", default: 0
|
||||
|
|
|
@ -3,7 +3,7 @@ class Integrations::Dialogflow::ProcessorService
|
|||
|
||||
def perform
|
||||
message = event_data[:message]
|
||||
return if message.private?
|
||||
return if message.is_private_note?
|
||||
return unless processable_message?(message)
|
||||
return unless message.conversation.bot?
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Integrations::Slack::IncomingMessageBuilder
|
|||
inbox_id: conversation.inbox_id,
|
||||
content: params[:event][:text],
|
||||
external_source_id_slack: params[:event][:ts],
|
||||
private: private_note?,
|
||||
is_private_note: private_note?,
|
||||
sender: sender
|
||||
)
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
|||
end
|
||||
|
||||
def message_content
|
||||
private_indicator = message.private? ? 'private: ' : ''
|
||||
private_indicator = message.is_private_note? ? 'private: ' : ''
|
||||
if conversation.identifier.present?
|
||||
"#{private_indicator}#{message.content}"
|
||||
else
|
||||
|
|
|
@ -19,7 +19,7 @@ RSpec.describe 'Conversation Messages API', type: :request do
|
|||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
|
||||
it 'creates a new outgoing message' do
|
||||
params = { content: 'test-message', private: true }
|
||||
params = { content: 'test-message', is_private_note: true }
|
||||
|
||||
post api_v1_account_conversation_messages_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
params: params,
|
||||
|
|
|
@ -63,7 +63,7 @@ describe Integrations::Dialogflow::ProcessorService do
|
|||
end
|
||||
|
||||
context 'when message is private' do
|
||||
let(:message) { create(:message, account: account, conversation: conversation, private: true) }
|
||||
let(:message) { create(:message, account: account, conversation: conversation, is_private_note: true) }
|
||||
|
||||
it 'returns nil' do
|
||||
expect(processor.perform).to be(nil)
|
||||
|
|
|
@ -68,7 +68,7 @@ describe NotificationListener do
|
|||
conversation: conversation,
|
||||
account: account,
|
||||
content: "hi [#{agent_with_notification.name}](mention://user/#{agent_with_notification.id}/#{agent_with_notification.name})",
|
||||
private: true
|
||||
is_private_note: true
|
||||
)
|
||||
|
||||
event = Events::Base.new(event_name, Time.zone.now, message: message)
|
||||
|
@ -95,7 +95,7 @@ describe NotificationListener do
|
|||
conversation: conversation,
|
||||
account: account,
|
||||
content: nil,
|
||||
private: true
|
||||
is_private_note: true
|
||||
)
|
||||
|
||||
event = Events::Base.new(event_name, Time.zone.now, message: message)
|
||||
|
|
|
@ -25,7 +25,7 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
|||
|
||||
it 'not have private notes' do
|
||||
# make the message private
|
||||
private_message.private = true
|
||||
private_message.is_private_note = true
|
||||
private_message.save
|
||||
|
||||
expect(mail.body.decoded).not_to include(private_message.content)
|
||||
|
@ -72,7 +72,7 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
|||
|
||||
it 'not have private notes' do
|
||||
# make the message private
|
||||
private_message.private = true
|
||||
private_message.is_private_note = true
|
||||
private_message.save
|
||||
expect(mail.body.decoded).not_to include(private_message.content)
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ RSpec.describe Message, type: :model do
|
|||
end
|
||||
|
||||
it 'wont call notify email method for private notes' do
|
||||
message.private = true
|
||||
message.is_private_note = true
|
||||
allow(ConversationReplyEmailWorker).to receive(:perform_in).and_return(true)
|
||||
message.save!
|
||||
expect(ConversationReplyEmailWorker).not_to have_received(:perform_in)
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Facebook::SendOnFacebookService do
|
|||
describe '#perform' do
|
||||
context 'without reply' do
|
||||
it 'if message is private' do
|
||||
message = create(:message, message_type: 'outgoing', private: true, inbox: facebook_inbox, account: account)
|
||||
message = create(:message, message_type: 'outgoing', is_private_note: true, inbox: facebook_inbox, account: account)
|
||||
::Facebook::SendOnFacebookService.new(message: message).perform
|
||||
expect(bot).not_to have_received(:deliver)
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ describe Twilio::SendOnTwilioService do
|
|||
describe '#perform' do
|
||||
context 'without reply' do
|
||||
it 'if message is private' do
|
||||
message = create(:message, message_type: 'outgoing', private: true, inbox: twilio_inbox, account: account)
|
||||
message = create(:message, message_type: 'outgoing', is_private_note: true, inbox: twilio_inbox, account: account)
|
||||
::Twilio::SendOnTwilioService.new(message: message).perform
|
||||
expect(twilio_client).not_to have_received(:messages)
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ describe Twitter::SendOnTwitterService do
|
|||
end
|
||||
|
||||
it 'if message is private' do
|
||||
message = create(:message, message_type: 'outgoing', private: true, inbox: twitter_inbox, account: account)
|
||||
message = create(:message, message_type: 'outgoing', is_private_note: true, inbox: twitter_inbox, account: account)
|
||||
::Twitter::SendOnTwitterService.new(message: message).perform
|
||||
expect(twitter_client).not_to have_received(:send_direct_message)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue