Compare commits

...

24 commits

Author SHA1 Message Date
Sojan
4af3884e35 chore: spec fixes 2021-06-09 16:45:06 +05:30
Sojan Jose
d773978b67
Merge branch 'develop' into chore/rename_private 2021-06-09 16:42:43 +05:30
Sojan Jose
69077770ac
Merge branch 'develop' into chore/rename_private 2021-06-04 13:17:45 +05:30
Sojan Jose
31e3979dff
Merge branch 'develop' into chore/rename_private 2021-05-28 10:23:05 +05:30
Sojan Jose
2414b19835
Merge branch 'develop' into chore/rename_private 2021-05-24 12:50:18 +05:30
Sojan Jose
b7c031f615
Merge branch 'develop' into chore/rename_private 2021-04-30 18:16:21 +05:30
Sojan Jose
124b100643
Merge branch 'develop' into chore/rename_private 2021-04-29 22:28:20 +05:30
Sojan Jose
da90e2b4d9
Merge branch 'develop' into chore/rename_private 2021-04-29 14:01:52 +05:30
Sojan Jose
aa2cafa6a8
Merge branch 'develop' into chore/rename_private 2021-04-27 00:44:38 +05:30
Sojan
b062f01407 chore: Fix spec 2021-04-27 00:44:09 +05:30
Sojan
94ae007541 chore: Fix Specs 2021-04-27 00:16:11 +05:30
Sojan Jose
49ca3b09ca
Merge branch 'develop' into chore/rename_private 2021-04-26 22:49:11 +05:30
Sojan Jose
74c2aed657
Merge branch 'develop' into chore/rename_private 2021-04-19 18:54:14 +05:30
Sojan Jose
6ebb2250e4
Merge branch 'develop' into chore/rename_private 2021-03-17 17:53:28 +05:30
Sojan Jose
dc9b3db9b1
Merge branch 'develop' into chore/rename_private 2021-03-06 16:38:55 +05:30
Sojan
f8f0d36636 chore: more fixes 2021-03-06 16:37:46 +05:30
Sojan
bedec53f0f chore: fix rubocop 2021-03-06 16:35:28 +05:30
Sojan Jose
41e3b9184c
Merge branch 'develop' into chore/rename_private 2021-03-03 17:51:55 +05:30
Sojan Jose
f2d03eff29
Merge branch 'develop' into chore/rename_private 2021-02-10 20:23:03 +05:30
Sojan
234ab021f8 chore: add is_private_note attribute 2021-01-22 20:25:53 +05:30
Sojan Jose
8a9cde641a
Merge branch 'develop' into chore/rename_private 2021-01-22 20:24:28 +05:30
Sojan
51deccfadd chore: more fixes 2020-12-21 18:12:02 +05:30
Sojan
90e68c51f3 Merge branch 'develop' into chore/rename_private 2020-12-19 22:43:41 +05:30
Sojan
853b7db562 Chore: Rename private attribute in messages 2020-09-03 17:17:00 +05:30
24 changed files with 39 additions and 30 deletions

View file

@ -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,

View file

@ -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

View file

@ -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,

View file

@ -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) {

View file

@ -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,

View file

@ -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?

View file

@ -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?

View file

@ -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

View file

@ -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

View file

@ -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?

View file

@ -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

View file

@ -0,0 +1,5 @@
class RenameMessagePrivate < ActiveRecord::Migration[6.0]
def change
rename_column :messages, :private, :is_private_note
end
end

View file

@ -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

View file

@ -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?

View file

@ -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
)

View file

@ -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

View file

@ -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,

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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