[chore] Web Push: Use server URL for VAPID sub claim (#3716)

webpush-go now supports sending `https://` as well as `mailto:` URLs for VAPID sub claims, so we can revert 464d920cfd9d6e362afdbe7ebdbf87f90fb50e0d now and save fetching the instance contact email or making up a dummy email if there wasn't one configured.
This commit is contained in:
Vyr Cossont 2025-01-31 06:57:32 -08:00 committed by GitHub
parent 8a9422aa78
commit fc895ade02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,18 +81,6 @@ func (r *realSender) Send(
return gtserror.Newf("error getting VAPID key pair: %w", err)
}
// Get contact email for this instance, if available.
domain := config.GetHost()
instance, err := r.state.DB.GetInstance(ctx, domain)
if err != nil {
return gtserror.Newf("error getting current instance: %w", err)
}
vapidSubjectEmail := instance.ContactEmail
if vapidSubjectEmail == "" {
// Instance contact email not configured. Use a dummy address.
vapidSubjectEmail = "admin@" + domain
}
// Get target account settings.
targetAccountSettings, err := r.state.DB.GetAccountSettings(ctx, notification.TargetAccountID)
if err != nil {
@ -111,7 +99,6 @@ func (r *realSender) Send(
if err := r.sendToSubscription(
ctx,
vapidKeyPair,
vapidSubjectEmail,
targetAccountSettings,
subscription,
notification,
@ -134,7 +121,6 @@ func (r *realSender) Send(
func (r *realSender) sendToSubscription(
ctx context.Context,
vapidKeyPair *gtsmodel.VAPIDKeyPair,
vapidSubjectEmail string,
targetAccountSettings *gtsmodel.AccountSettings,
subscription *gtsmodel.WebPushSubscription,
notification *gtsmodel.Notification,
@ -185,7 +171,7 @@ func (r *realSender) sendToSubscription(
},
&webpushgo.Options{
HTTPClient: r.httpClient,
Subscriber: vapidSubjectEmail,
Subscriber: "https://" + config.GetHost(),
VAPIDPublicKey: vapidKeyPair.Public,
VAPIDPrivateKey: vapidKeyPair.Private,
TTL: int(TTL.Seconds()),