summaryrefslogtreecommitdiff
path: root/internal/processing/conversations/update.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-07-04 15:30:39 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-07-04 15:30:39 +0200
commit66e1ec14aa07e115580afc8e1399677f3b54eeda (patch)
tree54aabccf5c0540abbfdea771745f354e05c8eb1a /internal/processing/conversations/update.go
parent[bugfix] set correct scope for StatusFavePOSTHandler (#4310) (diff)
downloadgotosocial-66e1ec14aa07e115580afc8e1399677f3b54eeda.tar.xz
[chore] move status filtering from type converter (#4306)
This finalizes the moving status filtering out of the type converter, and into its own `./internal/filter/` subpkg :) Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4306 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/processing/conversations/update.go')
-rw-r--r--internal/processing/conversations/update.go53
1 files changed, 32 insertions, 21 deletions
diff --git a/internal/processing/conversations/update.go b/internal/processing/conversations/update.go
index cf81d6906..21f1cf915 100644
--- a/internal/processing/conversations/update.go
+++ b/internal/processing/conversations/update.go
@@ -27,7 +27,6 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/id"
"code.superseriousbusiness.org/gotosocial/internal/log"
- "code.superseriousbusiness.org/gotosocial/internal/typeutils"
"code.superseriousbusiness.org/gotosocial/internal/util"
)
@@ -158,26 +157,6 @@ func (p *Processor) UpdateConversationsForStatus(ctx context.Context, status *gt
continue
}
- // Convert the conversation to API representation.
- apiConversation, err := p.converter.ConversationToAPIConversation(ctx,
- conversation,
- localAccount,
- nil,
- )
- if err != nil {
- // If the conversation's last status matched a hide filter, skip it.
- // If there was another kind of error, log that and skip it anyway.
- if !errors.Is(err, typeutils.ErrHideStatus) {
- log.Errorf(ctx,
- "error converting conversation %s to API representation for account %s: %v",
- status.ID,
- localAccount.ID,
- err,
- )
- }
- continue
- }
-
// If status was authored by this participant,
// don't bother notifying, they already know!
if status.AccountID == localAccount.ID {
@@ -198,6 +177,38 @@ func (p *Processor) UpdateConversationsForStatus(ctx context.Context, status *gt
continue
}
+ // Check whether status if filtered by local participant in context.
+ filtered, hide, err := p.statusFilter.StatusFilterResultsInContext(ctx,
+ localAccount,
+ status,
+ gtsmodel.FilterContextNotifications,
+ )
+ if err != nil {
+ log.Errorf(ctx, "error filtering status: %v", err)
+ continue
+ }
+
+ if hide {
+ continue
+ }
+
+ // Convert the conversation to API representation.
+ apiConversation, err := p.converter.ConversationToAPIConversation(ctx,
+ conversation,
+ localAccount,
+ )
+ if err != nil {
+ log.Errorf(ctx, "error converting conversation %s to API representation for account %s: %v",
+ status.ID,
+ localAccount.ID,
+ err,
+ )
+ continue
+ }
+
+ // Set filter results on attached status model.
+ apiConversation.LastStatus.Filtered = filtered
+
// Generate a notification,
notifications = append(notifications, ConversationNotification{
AccountID: localAccount.ID,