Store Web Push subscriptions in DB

This commit is contained in:
Vyr Cossont 2024-11-30 12:24:13 -08:00
commit 0cffb8784e
25 changed files with 546 additions and 69 deletions

View file

@ -66,6 +66,14 @@ you'll make society more equitable for all if you're not careful! :hammer_sickle
// be a serialized string of almost any type, so we pick a
// nice serialized key size on the upper end of normal.
sizeofResultKey = 2 * sizeofIDStr
// exampleWebPushAuth is a Base64-encoded 16-byte random auth secret.
// This secret is consumed as Base64 by webpush-go.
exampleWebPushAuth = "ZVxqlt5fzVgmSz2aqiA2XQ=="
// exampleWebPushP256dh is a Base64-encoded DH P-256 public key.
// This secret is consumed as Base64 by webpush-go.
exampleWebPushP256dh = "OrpejO16gV97uBXew/T0I7YoUv/CX8fz0z4g8RrQ+edXJqQPjX3XVSo2P0HhcCpCOR1+Dzj5LFcK9jYNqX7SBg=="
)
var (
@ -576,7 +584,7 @@ func sizeofMove() uintptr {
func sizeofNotification() uintptr {
return uintptr(size.Of(&gtsmodel.Notification{
ID: exampleID,
NotificationType: gtsmodel.NotificationFave,
NotificationType: gtsmodel.NotificationFavourite,
CreatedAt: exampleTime,
TargetAccountID: exampleID,
OriginAccountID: exampleID,
@ -821,3 +829,11 @@ func sizeofUserMute() uintptr {
Notifications: util.Ptr(false),
}))
}
func sizeofWebPushSubscription() uintptr {
return uintptr(size.Of(&gtsmodel.WebPushSubscription{
TokenID: exampleID,
Auth: exampleWebPushAuth,
P256dh: exampleWebPushP256dh,
}))
}