Add Web Push sender (similar to email sender)

This commit is contained in:
Vyr Cossont 2024-11-30 12:29:46 -08:00
commit 0c92f9f0f3
16 changed files with 699 additions and 1 deletions

View file

@ -51,6 +51,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/subscriptions"
"github.com/superseriousbusiness/gotosocial/internal/text"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
)
// Processor groups together processing functions and
@ -188,6 +189,7 @@ func NewProcessor(
mediaManager *mm.Manager,
state *state.State,
emailSender email.Sender,
webPushSender webpush.Sender,
visFilter *visibility.Filter,
intFilter *interaction.Filter,
) *Processor {
@ -241,6 +243,7 @@ func NewProcessor(
converter,
visFilter,
emailSender,
webPushSender,
&processor.account,
&processor.media,
&processor.stream,

View file

@ -24,6 +24,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/processing/stream"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
)
// Surface wraps functions for 'surfacing' the result
@ -38,5 +39,6 @@ type Surface struct {
Stream *stream.Processor
VisFilter *visibility.Filter
EmailSender email.Sender
WebPushSender webpush.Sender
Conversations *conversations.Processor
}

View file

@ -647,5 +647,10 @@ func (s *Surface) Notify(
}
s.Stream.Notify(ctx, targetAccount, apiNotif)
// Send Web Push notification to the user.
if err = s.WebPushSender.Send(ctx, notif, filters, compiledMutes); err != nil {
return gtserror.Newf("error sending Web Push notifications: %w", err)
}
return nil
}

View file

@ -28,6 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/processing/stream"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/internal/workers"
)
@ -44,6 +45,7 @@ func New(
converter *typeutils.Converter,
visFilter *visibility.Filter,
emailSender email.Sender,
webPushSender webpush.Sender,
account *account.Processor,
media *media.Processor,
stream *stream.Processor,
@ -65,6 +67,7 @@ func New(
Stream: stream,
VisFilter: visFilter,
EmailSender: emailSender,
WebPushSender: webPushSender,
Conversations: conversations,
}