diff options
author | 2023-10-25 16:04:53 +0200 | |
---|---|---|
committer | 2023-10-25 15:04:53 +0100 | |
commit | c7b6cd7770cad9bfdc23decffa7c4068752dbbbd (patch) | |
tree | 0f039fd34fb0287860fce06ff1c30dedd1882136 /internal/processing/workers/surfacenotify.go | |
parent | [bugfix] allow store smaller PNG image than 261 bytes (#2263) (#2298) (diff) | |
download | gotosocial-c7b6cd7770cad9bfdc23decffa7c4068752dbbbd.tar.xz |
[feature] Status thread mute/unmute functionality (#2278)
* add db models + functions for keeping track of threads
* give em the old linty testy
* create, remove, check mutes
* swagger
* testerino
* test mute/unmute via api
* add info log about new index creation
* thread + allow muting of any remote statuses that mention a local account
* IsStatusThreadMutedBy -> IsThreadMutedByAccount
* use common processing functions in status processor
* set = NULL
* favee!
* get rekt darlings, darlings get rekt
* testrig please, have mercy muy liege
Diffstat (limited to 'internal/processing/workers/surfacenotify.go')
-rw-r--r-- | internal/processing/workers/surfacenotify.go | 74 |
1 files changed, 70 insertions, 4 deletions
diff --git a/internal/processing/workers/surfacenotify.go b/internal/processing/workers/surfacenotify.go index 5a4f77a64..b99fa3ad3 100644 --- a/internal/processing/workers/surfacenotify.go +++ b/internal/processing/workers/surfacenotify.go @@ -28,15 +28,39 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/id" ) -// notifyMentions notifies each targeted account in -// the given mentions that they have a new mention. +// notifyMentions iterates through mentions on the +// given status, and notifies each mentioned account +// that they have a new mention. func (s *surface) notifyMentions( ctx context.Context, - mentions []*gtsmodel.Mention, + status *gtsmodel.Status, ) error { - errs := gtserror.NewMultiError(len(mentions)) + var ( + mentions = status.Mentions + errs = gtserror.NewMultiError(len(mentions)) + ) for _, mention := range mentions { + // Ensure thread not muted + // by mentioned account. + muted, err := s.state.DB.IsThreadMutedByAccount( + ctx, + status.ThreadID, + mention.TargetAccountID, + ) + + if err != nil { + errs.Append(err) + continue + } + + if muted { + // This mentioned account + // has muted the thread. + // Don't pester them. + continue + } + if err := s.notify( ctx, gtsmodel.NotificationMention, @@ -114,6 +138,24 @@ func (s *surface) notifyFave( return nil } + // Ensure favee hasn't + // muted the thread. + muted, err := s.state.DB.IsThreadMutedByAccount( + ctx, + fave.Status.ThreadID, + fave.TargetAccountID, + ) + + if err != nil { + return err + } + + if muted { + // Boostee doesn't want + // notifs for this thread. + return nil + } + return s.notify( ctx, gtsmodel.NotificationFave, @@ -134,11 +176,35 @@ func (s *surface) notifyAnnounce( return nil } + if status.BoostOf == nil { + // No boosted status + // set, nothing to do. + return nil + } + if status.BoostOfAccountID == status.AccountID { // Self-boost, nothing to do. return nil } + // Ensure boostee hasn't + // muted the thread. + muted, err := s.state.DB.IsThreadMutedByAccount( + ctx, + status.BoostOf.ThreadID, + status.BoostOfAccountID, + ) + + if err != nil { + return err + } + + if muted { + // Boostee doesn't want + // notifs for this thread. + return nil + } + return s.notify( ctx, gtsmodel.NotificationReblog, |