diff options
author | 2024-04-11 11:45:53 +0200 | |
---|---|---|
committer | 2024-04-11 11:45:53 +0200 | |
commit | 9fb8a78f91adffd5f4d28df1270e407c25a7a16e (patch) | |
tree | d68200744e28d07e75a52bb0c9f6593c86a38a91 /internal/processing/timeline | |
parent | [performance] massively improved ActivityPub delivery worker efficiency (#2812) (diff) | |
download | gotosocial-9fb8a78f91adffd5f4d28df1270e407c25a7a16e.tar.xz |
[feature] New user sign-up via web page (#2796)
* [feature] User sign-up form and admin notifs
* add chosen + filtered languages to migration
* remove stray comment
* chosen languages schmosen schmanguages
* proper error on local account missing
Diffstat (limited to 'internal/processing/timeline')
-rw-r--r-- | internal/processing/timeline/notification.go | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/internal/processing/timeline/notification.go b/internal/processing/timeline/notification.go index 09febdb46..42f708999 100644 --- a/internal/processing/timeline/notification.go +++ b/internal/processing/timeline/notification.go @@ -60,31 +60,14 @@ func (p *Processor) NotificationsGet(ctx context.Context, authed *oauth.Auth, ma prevMinIDValue = n.ID } - // Ensure this notification should be shown to requester. - if n.OriginAccount != nil { - // Account is set, ensure it's visible to notif target. - visible, err := p.filter.AccountVisible(ctx, authed.Account, n.OriginAccount) - if err != nil { - log.Debugf(ctx, "skipping notification %s because of an error checking notification visibility: %s", n.ID, err) - continue - } - - if !visible { - continue - } + visible, err := p.notifVisible(ctx, n, authed.Account) + if err != nil { + log.Debugf(ctx, "skipping notification %s because of an error checking notification visibility: %v", n.ID, err) + continue } - if n.Status != nil { - // Status is set, ensure it's visible to notif target. - visible, err := p.filter.StatusVisible(ctx, authed.Account, n.Status) - if err != nil { - log.Debugf(ctx, "skipping notification %s because of an error checking notification visibility: %s", n.ID, err) - continue - } - - if !visible { - continue - } + if !visible { + continue } item, err := p.converter.NotificationToAPINotification(ctx, n) @@ -142,3 +125,44 @@ func (p *Processor) NotificationsClear(ctx context.Context, authed *oauth.Auth) return nil } + +func (p *Processor) notifVisible( + ctx context.Context, + n *gtsmodel.Notification, + acct *gtsmodel.Account, +) (bool, error) { + // If account is set, ensure it's + // visible to notif target. + if n.OriginAccount != nil { + // If this is a new local account sign-up, + // skip normal visibility checking because + // origin account won't be confirmed yet. + if n.NotificationType == gtsmodel.NotificationSignup { + return true, nil + } + + visible, err := p.filter.AccountVisible(ctx, acct, n.OriginAccount) + if err != nil { + return false, err + } + + if !visible { + return false, nil + } + } + + // If status is set, ensure it's + // visible to notif target. + if n.Status != nil { + visible, err := p.filter.StatusVisible(ctx, acct, n.Status) + if err != nil { + return false, err + } + + if !visible { + return false, nil + } + } + + return true, nil +} |