feat(ntfy): dispatch api_key_revoked from ApiKey#revoke!

This commit is contained in:
Min Zeya Phyo
2026-07-28 02:18:13 +08:00
parent a93c39726a
commit 4236d12a84
2 changed files with 39 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
class ApiKey < ApplicationRecord
include NtfyDispatchable
# Normalize permissions to always be a Hash
attribute :permissions, :jsonb, default: {}
@@ -56,6 +58,12 @@ class ApiKey < ApplicationRecord
# Revoke API key
def revoke!
update!(active: false)
self.class.dispatch_ntfy("api_key_revoked",
title: "API key revoked",
message: "API key '#{name}' (#{key_prefix}...) was revoked",
priority: 3,
tags: ["key", "no_entry"])
end
# Deactivate expired keys