Files
redux-scraper/app/models/bluesky/monitored_did.rb
2025-08-05 20:51:40 +00:00

26 lines
650 B
Ruby

# typed: strict
class Bluesky::MonitoredDid < ReduxApplicationRecord
self.table_name = "bluesky_monitored_dids"
validates :did, presence: true, uniqueness: true
ADDED_NOTIFY_CHANNEL = "bluesky_did_added"
REMOVED_NOTIFY_CHANNEL = "bluesky_did_removed"
after_create_commit :notify_monitor_added
after_destroy_commit :notify_monitor_removed
sig { void }
def notify_monitor_added
self.class.connection.execute(
"NOTIFY #{ADDED_NOTIFY_CHANNEL}, '#{self.did}'",
)
end
sig { void }
def notify_monitor_removed
self.class.connection.execute(
"NOTIFY #{REMOVED_NOTIFY_CHANNEL}, '#{self.did}'",
)
end
end