about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-11-14 17:40:46 -0600
committerFire Demon <firedemon@creature.cafe>2020-11-14 17:40:46 -0600
commitb423ac926497367b418c31f65fec69bb3a193170 (patch)
tree1ba44da45b7f15cc8dbd888b0ed7e92373ec5a54 /app/lib
parent34b02a74b4a68f62e2a7c0cbee06edfe2aa92edd (diff)
parentdb01f8b942b72eaa2eacbb144261b002f8079c9c (diff)
Merge remote-tracking branch 'upstream/master' into merge-glitch
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/access_token_extension.rb17
1 files changed, 17 insertions, 0 deletions
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