diff options
author | 2025-01-23 16:47:30 -0800 | |
---|---|---|
committer | 2025-01-23 16:47:30 -0800 | |
commit | 5b765d734ee70f0a8a0790444d60969a727567f8 (patch) | |
tree | f76e05a6e5b22df17160be595c40e964bdbe5f22 /testrig/testmodels.go | |
parent | [feature] Serve bot accounts over AP as Service instead of Person (#3672) (diff) | |
download | gotosocial-5b765d734ee70f0a8a0790444d60969a727567f8.tar.xz |
[feature] Push notifications (#3587)
* Update push subscription API model to be Mastodon 4.0 compatible
* Add webpush-go dependency
# Conflicts:
# go.sum
* Single-row table for storing instance's VAPID key pair
* Generate VAPID key pair during startup
* Add VAPID public key to instance info API
* Return VAPID public key when registering an app
* Store Web Push subscriptions in DB
* Add Web Push sender (similar to email sender)
* Add no-op push senders to most processor tests
* Test Web Push notifications from workers
* Delete Web Push subscriptions when account is deleted
* Implement push subscription API
* Linter fixes
* Update Swagger
* Fix enum to int migration
* Fix GetVAPIDKeyPair
* Create web push subscriptions table with indexes
* Log Web Push server error messages
* Send instance URL as Web Push JWT subject
* Accept any 2xx code as a success
* Fix malformed VAPID sub claim
* Use packed notification flags
* Remove unused date columns
* Add notification type for update notifications
Not used yet
* Make GetVAPIDKeyPair idempotent
and remove PutVAPIDKeyPair
* Post-rebase fixes
* go mod tidy
* Special-case 400 errors other than 408/429
Most client errors should remove the subscription.
* Improve titles, trim body to reasonable length
* Disallow cleartext HTTP for Web Push servers
* Fix lint
* Remove redundant index on unique column
Also removes redundant unique and notnull tags on ID column since these are implied by pk
* Make realsender.go more readable
* Use Tobi's style for wrapping errors
* Restore treating all 5xx codes as temporary problems
* Always load target account settings
* Stub `policy` and `standard`
* webpush.Sender: take type converter as ctor param
* Move webpush.MockSender and noopSender into testrig
Diffstat (limited to 'testrig/testmodels.go')
-rw-r--r-- | testrig/testmodels.go | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/testrig/testmodels.go b/testrig/testmodels.go index da4202eed..9a54aba70 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -2585,7 +2585,7 @@ func NewTestNotifications() map[string]*gtsmodel.Notification { return map[string]*gtsmodel.Notification{ "local_account_1_like": { ID: "01F8Q0ANPTWW10DAKTX7BRPBJP", - NotificationType: gtsmodel.NotificationFave, + NotificationType: gtsmodel.NotificationFavourite, CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"), TargetAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", OriginAccountID: "01F8MH17FWEB39HZJ76B6VXSKF", @@ -2594,7 +2594,7 @@ func NewTestNotifications() map[string]*gtsmodel.Notification { }, "local_account_2_like": { ID: "01GTS6PRPXJYZBPFFQ56PP0XR8", - NotificationType: gtsmodel.NotificationFave, + NotificationType: gtsmodel.NotificationFavourite, CreatedAt: TimeMustParse("2022-01-13T12:45:01+02:00"), TargetAccountID: "01F8MH17FWEB39HZJ76B6VXSKF", OriginAccountID: "01F8MH5NBDF2MV7CTC4Q5128HF", @@ -2603,7 +2603,7 @@ func NewTestNotifications() map[string]*gtsmodel.Notification { }, "new_signup": { ID: "01HTM9TETMB3YQCBKZ7KD4KV02", - NotificationType: gtsmodel.NotificationSignup, + NotificationType: gtsmodel.NotificationAdminSignup, CreatedAt: TimeMustParse("2022-06-04T13:12:00Z"), TargetAccountID: "01F8MH17FWEB39HZJ76B6VXSKF", OriginAccountID: "01F8MH0BBE4FHXPH513MBVFHB0", @@ -3586,6 +3586,34 @@ func NewTestUserMutes() map[string]*gtsmodel.UserMute { return map[string]*gtsmodel.UserMute{} } +func NewTestWebPushSubscriptions() map[string]*gtsmodel.WebPushSubscription { + return map[string]*gtsmodel.WebPushSubscription{ + "local_account_1_token_1": { + ID: "01G65Z755AFWAKHE12NY0CQ9FH", + AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", + TokenID: "01F8MGTQW4DKTDF8SW5CT9HYGA", + Endpoint: "https://example.test/push", + Auth: "cgna/fzrYLDQyPf5hD7IsA==", + P256dh: "BMYVItYVOX+AHBdtA62Q0i6c+F7MV2Gia3aoDr8mvHkuPBNIOuTLDfmFcnBqoZcQk6BtLcIONbxhHpy2R+mYIUY=", + NotificationFlags: gtsmodel.WebPushSubscriptionNotificationFlagsFromSlice([]gtsmodel.NotificationType{ + gtsmodel.NotificationFollow, + gtsmodel.NotificationFollowRequest, + gtsmodel.NotificationFavourite, + gtsmodel.NotificationMention, + gtsmodel.NotificationReblog, + gtsmodel.NotificationPoll, + gtsmodel.NotificationStatus, + gtsmodel.NotificationUpdate, + gtsmodel.NotificationAdminSignup, + gtsmodel.NotificationAdminReport, + gtsmodel.NotificationPendingFave, + gtsmodel.NotificationPendingReply, + gtsmodel.NotificationPendingReblog, + }), + }, + } +} + func NewTestInteractionRequests() map[string]*gtsmodel.InteractionRequest { return map[string]*gtsmodel.InteractionRequest{ "admin_account_reply_turtle": { |