1
0

access_token_extension.rb 369 B

1234567891011121314151617
  1. # frozen_string_literal: true
  2. module AccessTokenExtension
  3. extend ActiveSupport::Concern
  4. included do
  5. after_commit :push_to_streaming_api
  6. end
  7. def revoke(clock = Time)
  8. update(revoked_at: clock.now.utc)
  9. end
  10. def push_to_streaming_api
  11. Redis.current.publish("timeline:access_token:#{id}", Oj.dump(event: :kill)) if revoked? || destroyed?
  12. end
  13. end