chore: apn jwt

This commit is contained in:
Krispire Admin
2026-06-08 18:22:11 +05:30
parent f2a04ae652
commit 26f0e298b5
+9
View File
@@ -45,6 +45,15 @@ func NewPushSender(repo *repository.PushRepo, publicKey, privateKey, subject str
if publicKey == "" || privateKey == "" || repo == nil {
return nil
}
// webpush-go prepends "mailto:" to any non-https subscriber, so a subject
// already in "mailto:foo@bar" form would become "mailto:mailto:foo@bar" —
// a malformed VAPID `sub` that Apple rejects with BadJwtToken (FCM is
// lenient). Hand the library a bare address (or an https: URL) so it adds
// exactly one prefix.
subject = strings.TrimSpace(subject)
if !strings.HasPrefix(subject, "https:") {
subject = strings.TrimPrefix(subject, "mailto:")
}
return &PushSender{repo: repo, pub: publicKey, priv: privateKey, subject: subject, logger: logger}
}