Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Push notifications #3587

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2d0dcff
Update push subscription API model to be Mastodon 4.0 compatible
VyrCossont Nov 24, 2024
2566523
Add webpush-go dependency
VyrCossont Nov 24, 2024
875517c
Single-row table for storing instance's VAPID key pair
VyrCossont Nov 24, 2024
1ea57b3
Generate VAPID key pair during startup
VyrCossont Nov 24, 2024
b082e53
Add VAPID public key to instance info API
VyrCossont Nov 24, 2024
5a2e834
Return VAPID public key when registering an app
VyrCossont Nov 24, 2024
17fd356
Store Web Push subscriptions in DB
VyrCossont Nov 30, 2024
ddb21cd
Add Web Push sender (similar to email sender)
VyrCossont Nov 30, 2024
05b8156
Add no-op push senders to most processor tests
VyrCossont Nov 30, 2024
1d0e608
Test Web Push notifications from workers
VyrCossont Nov 30, 2024
4ddfbad
Delete Web Push subscriptions when account is deleted
VyrCossont Dec 1, 2024
b99ea81
Implement push subscription API
VyrCossont Dec 1, 2024
88dddd5
Linter fixes
VyrCossont Dec 1, 2024
f663f56
Update Swagger
VyrCossont Dec 1, 2024
c8d213a
Fix enum to int migration
VyrCossont Dec 2, 2024
74b0541
Fix GetVAPIDKeyPair
VyrCossont Dec 2, 2024
7955993
Create web push subscriptions table with indexes
VyrCossont Dec 2, 2024
dcac7f2
Log Web Push server error messages
VyrCossont Dec 2, 2024
a356c86
Send instance URL as Web Push JWT subject
VyrCossont Dec 2, 2024
74e30f0
Accept any 2xx code as a success
VyrCossont Dec 2, 2024
86c686b
Fix malformed VAPID sub claim
VyrCossont Dec 20, 2024
4bbd76a
Use packed notification flags
VyrCossont Dec 26, 2024
25dc70e
Merge branch 'main' into push-notifications
VyrCossont Dec 26, 2024
9e479fb
Remove unused date columns
VyrCossont Dec 27, 2024
6ed26e0
Merge branch 'main' into push-notifications
VyrCossont Dec 28, 2024
053bad3
Add notification type for update notifications
VyrCossont Dec 28, 2024
81993c6
Make GetVAPIDKeyPair idempotent
VyrCossont Dec 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions cmd/gotosocial/action/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,36 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/api"
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
"github.com/superseriousbusiness/gotosocial/internal/cleaner"
"github.com/superseriousbusiness/gotosocial/internal/filter/interaction"
"github.com/superseriousbusiness/gotosocial/internal/filter/spam"
"github.com/superseriousbusiness/gotosocial/internal/filter/visibility"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/media/ffmpeg"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/metrics"
"github.com/superseriousbusiness/gotosocial/internal/middleware"
tlprocessor "github.com/superseriousbusiness/gotosocial/internal/processing/timeline"
"github.com/superseriousbusiness/gotosocial/internal/timeline"
"github.com/superseriousbusiness/gotosocial/internal/tracing"
"go.uber.org/automaxprocs/maxprocs"

"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db/bundb"
"github.com/superseriousbusiness/gotosocial/internal/email"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/federation/federatingdb"
"github.com/superseriousbusiness/gotosocial/internal/filter/interaction"
"github.com/superseriousbusiness/gotosocial/internal/filter/spam"
"github.com/superseriousbusiness/gotosocial/internal/filter/visibility"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/httpclient"
"github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/media/ffmpeg"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/metrics"
"github.com/superseriousbusiness/gotosocial/internal/middleware"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/oidc"
"github.com/superseriousbusiness/gotosocial/internal/processing"
tlprocessor "github.com/superseriousbusiness/gotosocial/internal/processing/timeline"
"github.com/superseriousbusiness/gotosocial/internal/router"
"github.com/superseriousbusiness/gotosocial/internal/state"
gtsstorage "github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/timeline"
"github.com/superseriousbusiness/gotosocial/internal/tracing"
"github.com/superseriousbusiness/gotosocial/internal/transport"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/web"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"go.uber.org/automaxprocs/maxprocs"
)

// Start creates and starts a gotosocial server
Expand Down Expand Up @@ -242,6 +242,14 @@ var Start action.GTSAction = func(ctx context.Context) error {
}
}

// Get or create a VAPID key pair.
if _, err := dbService.GetVAPIDKeyPair(ctx); err != nil {
return gtserror.Newf("error getting or creating VAPID key pair: %w", err)
}

// Create a Web Push notification sender.
webPushSender := webpush.NewSender(client, state)

// Initialize both home / list timelines.
state.Timelines.Home = timeline.NewManager(
tlprocessor.HomeTimelineGrab(state),
Expand Down Expand Up @@ -298,6 +306,7 @@ var Start action.GTSAction = func(ctx context.Context) error {
mediaManager,
state,
emailSender,
webPushSender,
visFilter,
intFilter,
)
Expand Down
4 changes: 3 additions & 1 deletion cmd/gotosocial/action/testrig/testrig.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/tracing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/web"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)

Expand Down Expand Up @@ -173,6 +174,7 @@ var Start action.GTSAction = func(ctx context.Context) error {
federator := testrig.NewTestFederator(state, transportController, mediaManager)

emailSender := testrig.NewEmailSender("./web/template/", nil)
webPushSender := webpush.NewMockSender()
typeConverter := typeutils.NewConverter(state)
filter := visibility.NewFilter(state)

Expand All @@ -196,7 +198,7 @@ var Start action.GTSAction = func(ctx context.Context) error {
return fmt.Errorf("error starting list timeline: %s", err)
}

processor := testrig.NewTestProcessor(state, federator, emailSender, mediaManager)
processor := testrig.NewTestProcessor(state, federator, emailSender, webPushSender, mediaManager)

// Initialize workers.
testrig.StartWorkers(state, processor.Workers())
Expand Down
Loading