chore: apn jwt
This commit is contained in:
@@ -45,6 +45,15 @@ func NewPushSender(repo *repository.PushRepo, publicKey, privateKey, subject str
|
|||||||
if publicKey == "" || privateKey == "" || repo == nil {
|
if publicKey == "" || privateKey == "" || repo == nil {
|
||||||
return 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}
|
return &PushSender{repo: repo, pub: publicKey, priv: privateKey, subject: subject, logger: logger}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user