summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar Vyr Cossont <VyrCossont@users.noreply.github.com>2025-02-03 02:25:53 -0800
committerLibravatar GitHub <noreply@github.com>2025-02-03 10:25:53 +0000
commit27844b7da2567491661f9ddd2d4662f9f1b3ce40 (patch)
tree1832fe4ec4d3a0fbf6d01bcb5f39acf6885cc1f5 /internal/processing
parent[chore]: Bump github.com/tdewolff/minify/v2 from 2.21.2 to 2.21.3 (#3727) (diff)
downloadgotosocial-27844b7da2567491661f9ddd2d4662f9f1b3ce40.tar.xz
[feature] Implement Web Push notification policy (#3721)
* Web Push: add policy column to subscriptions * Web Push: add policy to API * Web Push: test notification policy * go-fmt unrelated file (how did this get thru?)
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/push/create.go2
-rw-r--r--internal/processing/push/update.go4
2 files changed, 6 insertions, 0 deletions
diff --git a/internal/processing/push/create.go b/internal/processing/push/create.go
index 42a67dc19..dc15ccf12 100644
--- a/internal/processing/push/create.go
+++ b/internal/processing/push/create.go
@@ -24,6 +24,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
// CreateOrReplace creates a Web Push subscription for the given access token,
@@ -54,6 +55,7 @@ func (p *Processor) CreateOrReplace(
Auth: request.Subscription.Keys.Auth,
P256dh: request.Subscription.Keys.P256dh,
NotificationFlags: alertsToNotificationFlags(request.Data.Alerts),
+ Policy: typeutils.APIWebPushNotificationPolicyToWebPushNotificationPolicy(*request.Data.Policy),
}
if err := p.state.DB.PutWebPushSubscription(ctx, subscription); err != nil {
diff --git a/internal/processing/push/update.go b/internal/processing/push/update.go
index 370536f9b..94529455a 100644
--- a/internal/processing/push/update.go
+++ b/internal/processing/push/update.go
@@ -24,6 +24,7 @@ import (
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
+ "github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
// Update updates the Web Push subscription for the given access token.
@@ -50,10 +51,13 @@ func (p *Processor) Update(
// Update it.
subscription.NotificationFlags = alertsToNotificationFlags(request.Data.Alerts)
+ subscription.Policy = typeutils.APIWebPushNotificationPolicyToWebPushNotificationPolicy(*request.Data.Policy)
+
if err = p.state.DB.UpdateWebPushSubscription(
ctx,
subscription,
"notification_flags",
+ "policy",
); err != nil {
err := gtserror.Newf("couldn't update Web Push subscription for token ID %s: %w", tokenID, err)
return nil, gtserror.NewErrorInternalError(err)