Files
sure/app/models/push_subscription.rb
T
0aa43de10a Add experimental Swift-native Sure Insights app (#3134)
* Add Swift-native Sure app

* Fix push subscriptions schema for CI

* Address native app review feedback

* Address remaining native app review feedback

* Use Flutter app logo for native icon

* Honor insight notification preferences and locale

---------

Co-authored-by: Juan Jose Mata <2v8shcb6pz@privaterelay.appleid.com>
Co-authored-by: sure-admin <sure-admin@splashblot.com>
2026-08-25 04:16:24 +02:00

15 lines
516 B
Ruby

class PushSubscription < ApplicationRecord
belongs_to :user
enum :environment, { sandbox: "sandbox", production: "production" }, validate: true
normalizes :token, with: ->(token) { token.downcase }
validates :token, presence: true, uniqueness: { case_sensitive: false },
format: { with: /\A[0-9a-f]{64,200}\z/i }
validates :platform, inclusion: { in: %w[ios] }
validates :last_registered_at, presence: true
scope :recent, -> { where("last_registered_at > ?", 90.days.ago) }
end