Fix private note shown to user in widget (#308)

fixes #306
This commit is contained in:
Pranav Raj S 2019-11-27 10:12:57 +05:30 committed by Sojan Jose
parent 913172c688
commit ded8f33fc8
4 changed files with 13 additions and 12 deletions

View file

@ -1,10 +1,6 @@
<template> <template>
<UserMessage v-if="isUserMessage" :message="message.content" /> <UserMessage v-if="isUserMessage" :message="message.content" />
<AgentMessage <AgentMessage v-else :agent-name="agentName" :message="message.content" />
v-else
:agent-name="message.sender_name"
:message="message.content"
/>
</template> </template>
<script> <script>
@ -24,6 +20,9 @@ export default {
isUserMessage() { isUserMessage() {
return this.message.message_type === MESSAGE_TYPE.INCOMING; return this.message.message_type === MESSAGE_TYPE.INCOMING;
}, },
agentName() {
return this.message.sender ? this.message.sender.name : '';
},
}, },
}; };
</script> </script>

View file

@ -19,7 +19,7 @@ class ActionCableListener < BaseListener
contact = conversation.contact contact = conversation.contact
members = conversation.inbox.members.pluck(:pubsub_token) members = conversation.inbox.members.pluck(:pubsub_token)
send_to_members(members, MESSAGE_CREATED, message.push_event_data) send_to_members(members, MESSAGE_CREATED, message.push_event_data)
send_to_contact(contact, MESSAGE_CREATED, message.push_event_data) send_to_contact(contact, MESSAGE_CREATED, message)
end end
def conversation_reopened(event) def conversation_reopened(event)
@ -50,10 +50,12 @@ class ActionCableListener < BaseListener
end end
end end
def send_to_contact(contact, event_name, data) def send_to_contact(contact, event_name, message)
return if message.private?
return if message.activity?
return if contact.nil? return if contact.nil?
ActionCable.server.broadcast(contact.pubsub_token, event: event_name, data: data) ActionCable.server.broadcast(contact.pubsub_token, event: event_name, data: message.push_event_data)
end end
def push(pubsub_token, data) def push(pubsub_token, data)

View file

@ -5,5 +5,5 @@ json.array! @messages do |message|
json.created_at message.created_at.to_i json.created_at message.created_at.to_i
json.conversation_id message. conversation_id json.conversation_id message. conversation_id
json.attachment message.attachment.push_event_data if message.attachment json.attachment message.attachment.push_event_data if message.attachment
json.sender_name message.user.name if message.user json.sender message.user.push_event_data if message.user
end end

View file

@ -6,9 +6,9 @@ default: &default
development: development:
<<: *default <<: *default
database: chatwoot_dev database: <%= ENV.fetch('POSTGRES_DATABASE', 'chatwoot_dev') %>
username: postgres username: <%= ENV.fetch('POSTGRES_USERNAME', 'postgres') %>
password: password: <%= ENV.fetch('POSTGRES_PASSWORD', '') %>
test: test:
<<: *default <<: *default