From 27844b7da2567491661f9ddd2d4662f9f1b3ce40 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Mon, 3 Feb 2025 02:25:53 -0800 Subject: [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?) --- internal/typeutils/internaltofrontend.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'internal/typeutils/internaltofrontend.go') diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 487e8434e..d966c054c 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -3019,6 +3019,20 @@ func (c *Converter) InteractionReqToAPIInteractionReq( }, nil } +func webPushNotificationPolicyToAPIWebPushNotificationPolicy(policy gtsmodel.WebPushNotificationPolicy) apimodel.WebPushNotificationPolicy { + switch policy { + case gtsmodel.WebPushNotificationPolicyAll: + return apimodel.WebPushNotificationPolicyAll + case gtsmodel.WebPushNotificationPolicyFollowed: + return apimodel.WebPushNotificationPolicyFollowed + case gtsmodel.WebPushNotificationPolicyFollower: + return apimodel.WebPushNotificationPolicyFollower + case gtsmodel.WebPushNotificationPolicyNone: + return apimodel.WebPushNotificationPolicyNone + } + return "" +} + func (c *Converter) WebPushSubscriptionToAPIWebPushSubscription( ctx context.Context, subscription *gtsmodel.WebPushSubscription, @@ -3047,7 +3061,7 @@ func (c *Converter) WebPushSubscriptionToAPIWebPushSubscription( PendingReply: subscription.NotificationFlags.Get(gtsmodel.NotificationPendingReply), PendingReblog: subscription.NotificationFlags.Get(gtsmodel.NotificationPendingReblog), }, - Policy: apimodel.WebPushNotificationPolicyAll, + Policy: webPushNotificationPolicyToAPIWebPushNotificationPolicy(subscription.Policy), Standard: true, }, nil } -- cgit v1.2.3