mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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>
This commit is contained in:
1 parent
3f314a13bb
commit
d4b71d17a1
21 files changed
+234
-96
No files matched your search
@@ -4,20 +4,32 @@ class PushNotificationJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(user_ids, key, path, tag, vars)
|
||||
vars = vars.symbolize_keys
|
||||
message = JSON.generate(title: I18n.t("push.#{key}.title", **vars), body: I18n.t("push.#{key}.body", **vars), path: path, tag: tag)
|
||||
PushSubscription.where(user_id: user_ids).find_each { deliver(_1, message) }
|
||||
message = self.class.message(key, path, tag, vars)
|
||||
PushSubscription.where(user_id: user_ids).find_each { self.class.deliver(_1, message) }
|
||||
end
|
||||
|
||||
private
|
||||
def self.message(key, path, tag, vars = {})
|
||||
vars = vars.symbolize_keys
|
||||
JSON.generate(title: I18n.t("push.#{key}.title", **vars), body: I18n.t("push.#{key}.body", **vars), path: path, tag: tag)
|
||||
end
|
||||
|
||||
def deliver(subscription, message)
|
||||
# Sends to one device: nil when the push service took it, else why not.
|
||||
def self.deliver(subscription, message)
|
||||
WebPush.payload_send(message: message, endpoint: subscription.endpoint, p256dh: subscription.p256dh, auth: subscription.auth,
|
||||
ttl: 1.day.to_i, urgency: "high",
|
||||
vapid: { subject: PushKeys.subject, public_key: PushKeys.public_key, private_key: PushKeys.private_key })
|
||||
rescue WebPush::ExpiredSubscription, WebPush::InvalidSubscription, WebPush::Unauthorized
|
||||
nil
|
||||
rescue WebPush::ExpiredSubscription, WebPush::InvalidSubscription, WebPush::Unauthorized => e
|
||||
subscription.destroy
|
||||
failure(subscription, e)
|
||||
rescue WebPush::Error, SocketError, SystemCallError, Net::OpenTimeout, Net::ReadTimeout, OpenSSL::SSL::SSLError => e
|
||||
Rails.logger.warn("[push] #{subscription.endpoint.truncate(60)}: #{e.class}: #{e.message.truncate(200)}")
|
||||
failure(subscription, e)
|
||||
end
|
||||
|
||||
def self.failure(subscription, error)
|
||||
reason = "#{error.class.name.demodulize}: #{error.message.truncate(200)}"
|
||||
Rails.logger.warn("[push] #{subscription.endpoint.truncate(60)}: #{reason}")
|
||||
reason
|
||||
end
|
||||
private_class_method :failure
|
||||
end
|
||||
Reference in new issue
Block a user