ab6bc256eb
When a session is destroyed (user logs out), all devices registered to that session are automatically destroyed, preventing push notifications from being sent to logged-out devices. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
10 lines
333 B
Ruby
10 lines
333 B
Ruby
class ApplicationPushDevice < ActionPushNative::Device
|
|
belongs_to :session, optional: true
|
|
|
|
def self.register(session:, token:, platform:, name: nil)
|
|
session.identity.devices.find_or_initialize_by(token: token).tap do |device|
|
|
device.update!(session: session, platform: platform.downcase, name: name)
|
|
end
|
|
end
|
|
end
|