Chatwoot/app/models/concerns/pubsubable.rb
Sojan Jose 791d90c6b7
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>
2021-11-22 23:32:17 +05:30

16 lines
374 B
Ruby

# frozen_string_literal: true
module Pubsubable
extend ActiveSupport::Concern
included do
# Used by the actionCable/PubSub Service we use for real time communications
has_secure_token :pubsub_token
end
def pubsub_token
# backfills tokens for existing records
regenerate_pubsub_token if self[:pubsub_token].blank?
self[:pubsub_token]
end
end