parent
913172c688
commit
ded8f33fc8
4 changed files with 13 additions and 12 deletions
|
@ -1,10 +1,6 @@
|
|||
<template>
|
||||
<UserMessage v-if="isUserMessage" :message="message.content" />
|
||||
<AgentMessage
|
||||
v-else
|
||||
:agent-name="message.sender_name"
|
||||
:message="message.content"
|
||||
/>
|
||||
<AgentMessage v-else :agent-name="agentName" :message="message.content" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -24,6 +20,9 @@ export default {
|
|||
isUserMessage() {
|
||||
return this.message.message_type === MESSAGE_TYPE.INCOMING;
|
||||
},
|
||||
agentName() {
|
||||
return this.message.sender ? this.message.sender.name : '';
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ class ActionCableListener < BaseListener
|
|||
contact = conversation.contact
|
||||
members = conversation.inbox.members.pluck(:pubsub_token)
|
||||
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
|
||||
|
||||
def conversation_reopened(event)
|
||||
|
@ -50,10 +50,12 @@ class ActionCableListener < BaseListener
|
|||
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?
|
||||
|
||||
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
|
||||
|
||||
def push(pubsub_token, data)
|
||||
|
|
|
@ -5,5 +5,5 @@ json.array! @messages do |message|
|
|||
json.created_at message.created_at.to_i
|
||||
json.conversation_id message. conversation_id
|
||||
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
|
||||
|
|
|
@ -6,9 +6,9 @@ default: &default
|
|||
|
||||
development:
|
||||
<<: *default
|
||||
database: chatwoot_dev
|
||||
username: postgres
|
||||
password:
|
||||
database: <%= ENV.fetch('POSTGRES_DATABASE', 'chatwoot_dev') %>
|
||||
username: <%= ENV.fetch('POSTGRES_USERNAME', 'postgres') %>
|
||||
password: <%= ENV.fetch('POSTGRES_PASSWORD', '') %>
|
||||
|
||||
test:
|
||||
<<: *default
|
||||
|
|
Loading…
Reference in a new issue