You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
369 B

  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