Files
rickyandClaude Opus 5.5 d4b71d17a1 Smaller aircraft photos, one-row-per-item detail cards, push diagnostics
- Aircraft photos get 192px and 960x432 copies made on upload; the header,
  share page and Fleet cards use them (and the offline copies), instead of
  the full original.
- Flight, engine data, component and major record details show one label
  and value per row on phones (wide items no longer add grid columns).
- Profile re-records this device's push subscription on every visit, and
  says why if it can't; Send test delivers now and lists each device's
  result; Google's other push hosts are accepted; turning notifications on
  shows the browser's actual error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 11:55:11 -05:00

22 lines
860 B
Ruby

# A browser or installed app where a user turned notifications on (Profile).
class PushSubscription < ApplicationRecord
# The browsers' push services. The server posts to the endpoint, so only
# these hosts are accepted (not, say, an address inside the network).
PUSH_SERVICES = /\A(([\w-]+\.)*googleapis\.com|([\w-]+\.)*google\.com|updates\.push\.services\.mozilla\.com|([\w-]+\.)*push\.apple\.com|([\w-]+\.)*notify\.windows\.com)\z/
belongs_to :user
validates :endpoint, presence: true, uniqueness: true
validates :p256dh, :auth, presence: true
validate :endpoint_is_a_push_service
private
def endpoint_is_a_push_service
uri = URI.parse(endpoint.to_s)
errors.add(:endpoint, :invalid) unless uri.is_a?(URI::HTTPS) && uri.host.to_s.match?(PUSH_SERVICES)
rescue URI::InvalidURIError
errors.add(:endpoint, :invalid)
end
end