mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-02-04 20:05:05 +00:00
[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 464d920cfd
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:
parent
8a9422aa78
commit
fc895ade02
|
@ -81,18 +81,6 @@ func(subscription *gtsmodel.WebPushSubscription) bool {
|
||||||
return gtserror.Newf("error getting VAPID key pair: %w", err)
|
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.
|
// Get target account settings.
|
||||||
targetAccountSettings, err := r.state.DB.GetAccountSettings(ctx, notification.TargetAccountID)
|
targetAccountSettings, err := r.state.DB.GetAccountSettings(ctx, notification.TargetAccountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -111,7 +99,6 @@ func(subscription *gtsmodel.WebPushSubscription) bool {
|
||||||
if err := r.sendToSubscription(
|
if err := r.sendToSubscription(
|
||||||
ctx,
|
ctx,
|
||||||
vapidKeyPair,
|
vapidKeyPair,
|
||||||
vapidSubjectEmail,
|
|
||||||
targetAccountSettings,
|
targetAccountSettings,
|
||||||
subscription,
|
subscription,
|
||||||
notification,
|
notification,
|
||||||
|
@ -134,7 +121,6 @@ func(subscription *gtsmodel.WebPushSubscription) bool {
|
||||||
func (r *realSender) sendToSubscription(
|
func (r *realSender) sendToSubscription(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
vapidKeyPair *gtsmodel.VAPIDKeyPair,
|
vapidKeyPair *gtsmodel.VAPIDKeyPair,
|
||||||
vapidSubjectEmail string,
|
|
||||||
targetAccountSettings *gtsmodel.AccountSettings,
|
targetAccountSettings *gtsmodel.AccountSettings,
|
||||||
subscription *gtsmodel.WebPushSubscription,
|
subscription *gtsmodel.WebPushSubscription,
|
||||||
notification *gtsmodel.Notification,
|
notification *gtsmodel.Notification,
|
||||||
|
@ -185,7 +171,7 @@ func (r *realSender) sendToSubscription(
|
||||||
},
|
},
|
||||||
&webpushgo.Options{
|
&webpushgo.Options{
|
||||||
HTTPClient: r.httpClient,
|
HTTPClient: r.httpClient,
|
||||||
Subscriber: vapidSubjectEmail,
|
Subscriber: "https://" + config.GetHost(),
|
||||||
VAPIDPublicKey: vapidKeyPair.Public,
|
VAPIDPublicKey: vapidKeyPair.Public,
|
||||||
VAPIDPrivateKey: vapidKeyPair.Private,
|
VAPIDPrivateKey: vapidKeyPair.Private,
|
||||||
TTL: int(TTL.Seconds()),
|
TTL: int(TTL.Seconds()),
|
||||||
|
|
Loading…
Reference in a new issue