mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-25 00:20:32 +00:00
Fix malformed VAPID sub claim
This commit is contained in:
parent
74e30f06d2
commit
86c686b5d6
1 changed files with 15 additions and 1 deletions
|
@ -134,6 +134,18 @@ 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 API representations of notification and accounts involved.
|
||||
// This also loads the target account's settings.
|
||||
apiNotification, err := r.tc.NotificationToAPINotification(ctx, notification, filters, mutes)
|
||||
|
@ -147,6 +159,7 @@ func (r *realSender) Send(
|
|||
if err := r.sendToSubscription(
|
||||
ctx,
|
||||
vapidKeyPair,
|
||||
vapidSubjectEmail,
|
||||
subscription,
|
||||
notification.TargetAccount,
|
||||
apiNotification,
|
||||
|
@ -168,6 +181,7 @@ func (r *realSender) Send(
|
|||
func (r *realSender) sendToSubscription(
|
||||
ctx context.Context,
|
||||
vapidKeyPair *gtsmodel.VAPIDKeyPair,
|
||||
vapidSubjectEmail string,
|
||||
subscription *gtsmodel.WebPushSubscription,
|
||||
targetAccount *gtsmodel.Account,
|
||||
apiNotification *apimodel.Notification,
|
||||
|
@ -226,7 +240,7 @@ func (r *realSender) sendToSubscription(
|
|||
},
|
||||
&webpushgo.Options{
|
||||
HTTPClient: r.httpClient,
|
||||
Subscriber: "https://" + config.GetHost(),
|
||||
Subscriber: vapidSubjectEmail,
|
||||
VAPIDPublicKey: vapidKeyPair.Public,
|
||||
VAPIDPrivateKey: vapidKeyPair.Private,
|
||||
TTL: int(TTL.Seconds()),
|
||||
|
|
Loading…
Reference in a new issue