fix: Agent typing indicator for website widget (#4495)
When we migrated the pubsub tokens from contact to contact inboxes, we missed out on doing this update for the typing indicator events. Hence the agent typing events weren't visible on the widget side. This change fixes that and removes the necessary column contact pubsub token from the model. fixes: #4476
This commit is contained in:
@@ -21,9 +21,6 @@ class DataImportJob < ApplicationJob
|
||||
|
||||
contact.name = params[:name] if params[:name].present?
|
||||
contact.assign_attributes(custom_attributes: contact.custom_attributes.merge(params.except(:identifier, :email, :name)))
|
||||
|
||||
# since callbacks aren't triggered lets ensure a pubsub token
|
||||
contact.pubsub_token ||= SecureRandom.base58(24)
|
||||
contact
|
||||
end
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@ class ActionCableListener < BaseListener
|
||||
private
|
||||
|
||||
def typing_event_listener_tokens(account, conversation, user)
|
||||
(user_tokens(account, conversation.inbox.members) + [conversation.contact.pubsub_token]) - [user&.pubsub_token]
|
||||
current_user_token = user.is_a?(Contact) ? conversation.contact_inbox.pubsub_token : user.pubsub_token
|
||||
(user_tokens(account, conversation.inbox.members) + [conversation.contact_inbox.pubsub_token]) - [current_user_token]
|
||||
end
|
||||
|
||||
def user_tokens(account, agents)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# last_activity_at :datetime
|
||||
# name :string
|
||||
# phone_number :string
|
||||
# pubsub_token :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :integer not null
|
||||
@@ -19,13 +18,11 @@
|
||||
#
|
||||
# index_contacts_on_account_id (account_id)
|
||||
# index_contacts_on_phone_number_and_account_id (phone_number,account_id)
|
||||
# index_contacts_on_pubsub_token (pubsub_token) UNIQUE
|
||||
# uniq_email_per_account_contact (email,account_id) UNIQUE
|
||||
# uniq_identifier_per_account_contact (identifier,account_id) UNIQUE
|
||||
#
|
||||
|
||||
class Contact < ApplicationRecord
|
||||
# TODO: remove the pubsub_token attribute from this model in future.
|
||||
include Avatarable
|
||||
include AvailabilityStatusable
|
||||
include Labelable
|
||||
@@ -117,7 +114,6 @@ class Contact < ApplicationRecord
|
||||
identifier: identifier,
|
||||
name: name,
|
||||
phone_number: phone_number,
|
||||
pubsub_token: pubsub_token,
|
||||
thumbnail: avatar_url,
|
||||
type: 'contact'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user