From b9f759d922acb87a8ddc317a98e18b3e3c6f1653 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Wed, 22 Jan 2025 11:18:55 -0800 Subject: [PATCH] Stub `policy` and `standard` --- docs/api/swagger.yaml | 12 ++++++++++++ internal/api/model/webpushsubscription.go | 15 +++++++++++++++ internal/typeutils/internaltofrontend.go | 2 ++ 3 files changed, 29 insertions(+) diff --git a/docs/api/swagger.yaml b/docs/api/swagger.yaml index c6a76ebdf..5165f8c9e 100644 --- a/docs/api/swagger.yaml +++ b/docs/api/swagger.yaml @@ -186,6 +186,10 @@ definitions: title: TimelineMarker contains information about a user's progress through a specific timeline. type: object x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model + WebPushNotificationPolicy: + title: WebPushNotificationPolicy names sets of accounts that can generate notifications. + type: string + x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model account: description: The modelled account can be either a remote account, or one on this instance. properties: @@ -3452,10 +3456,18 @@ definitions: description: The id of the push subscription in the database. type: string x-go-name: ID + policy: + $ref: '#/definitions/WebPushNotificationPolicy' server_key: description: The streaming server's VAPID public key. type: string x-go-name: ServerKey + standard: + description: |- + Whether the subscription uses RFC or pre-RFC Web Push standards. + For GotoSocial, this is always true. + type: boolean + x-go-name: Standard title: WebPushSubscription represents a subscription to a Web Push server. type: object x-go-name: WebPushSubscription diff --git a/internal/api/model/webpushsubscription.go b/internal/api/model/webpushsubscription.go index 96f86963c..a28bb7294 100644 --- a/internal/api/model/webpushsubscription.go +++ b/internal/api/model/webpushsubscription.go @@ -32,6 +32,13 @@ type WebPushSubscription struct { // Which alerts should be delivered to the endpoint. Alerts WebPushSubscriptionAlerts `json:"alerts"` + + // Which accounts should generate notifications. + Policy WebPushNotificationPolicy `json:"policy"` + + // Whether the subscription uses RFC or pre-RFC Web Push standards. + // For GotoSocial, this is always true. + Standard bool `json:"standard"` } // WebPushSubscriptionAlerts represents the specific events that this Web Push subscription will receive. @@ -140,3 +147,11 @@ type WebPushSubscriptionRequestData struct { // Alerts selects the specific events that this Web Push subscription will receive. Alerts *WebPushSubscriptionAlerts `form:"-" json:"alerts"` } + +// WebPushNotificationPolicy names sets of accounts that can generate notifications. +type WebPushNotificationPolicy string + +const ( + // WebPushNotificationPolicyAll allows all accounts to send notifications to the subscribing user. + WebPushNotificationPolicyAll WebPushNotificationPolicy = "all" +) diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index f24c0933e..6739d0540 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -3026,5 +3026,7 @@ func (c *Converter) WebPushSubscriptionToAPIWebPushSubscription( PendingReply: subscription.NotificationFlags.Get(gtsmodel.NotificationPendingReply), PendingReblog: subscription.NotificationFlags.Get(gtsmodel.NotificationPendingReblog), }, + Policy: apimodel.WebPushNotificationPolicyAll, + Standard: true, }, nil }