chore: Migrate PubSub Token to contact inbox (#3434)

At present, the websocket pubsub tokens are present at the contact objects in chatwoot. A better approach would be to have these tokens at the contact_inbox object instead. This helps chatwoot to deliver the websocket events targetted to the specific widget connection, stop contact events from leaking into other chat sessions from the same contact.

Fixes #1682
Fixes #1664

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Sojan Jose
2021-11-22 23:32:17 +05:30
committed by GitHub
parent 01577acb2e
commit 791d90c6b7
38 changed files with 211 additions and 95 deletions

View File

@@ -13,6 +13,7 @@ json.meta do
json.partial! 'api/v1/models/team.json.jbuilder', resource: conversation.team
end
end
json.hmac_verified conversation.contact_inbox&.hmac_verified
end
json.id conversation.display_id

View File

@@ -22,7 +22,7 @@ json.chatwoot_widget_defaults do
json.use_inbox_avatar_for_bot ActiveModel::Type::Boolean.new.cast(ENV.fetch('USE_INBOX_AVATAR_FOR_BOT', false))
end
json.contact do
json.pubsub_token @contact.pubsub_token
json.pubsub_token @contact_inbox.pubsub_token
end
json.auth_token @token
json.global_config @global_config