From aa10200e58ccb340b6384532ccdba6b7fbac037a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 12 Nov 2020 23:05:24 +0100 Subject: Fix streaming API allowing connections to persist after access token invalidation (#15111) Fix #14816 --- app/lib/access_token_extension.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/lib/access_token_extension.rb (limited to 'app/lib') diff --git a/app/lib/access_token_extension.rb b/app/lib/access_token_extension.rb new file mode 100644 index 000000000..3e184e775 --- /dev/null +++ b/app/lib/access_token_extension.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module AccessTokenExtension + extend ActiveSupport::Concern + + included do + after_commit :push_to_streaming_api + end + + def revoke(clock = Time) + update(revoked_at: clock.now.utc) + end + + def push_to_streaming_api + Redis.current.publish("timeline:access_token:#{id}", Oj.dump(event: :kill)) if revoked? || destroyed? + end +end -- cgit