From 61a8d362557c1787d534024ed2f14e999b785cc3 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Fri, 31 May 2024 03:55:56 -0700 Subject: [feature] Implement Filter API v2 (#2936) * Use correct entity name * We support server-side filters now * Document filter v1 methods that can throw a 409 * Validate v1 filter phrase as filter title * Always check v1 filter API status codes in tests * Document keyword minimum requirement on filter API v1 * Make it possible to specify filter keyword update columns per filter keyword * Implement v2 filter API * Fix lint and tests * Update Swagger spec * Fix filter update test * Update Swagger spec *correctly* * Update actual files Swagger spec was generated from * Remove keywords_attributes and statuses_attributes * Add test for serialization of empty filter * More helpful messages when object is owned by wrong account --- internal/processing/filters/v1/get.go | 4 ++-- internal/processing/filters/v1/update.go | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'internal/processing/filters/v1') diff --git a/internal/processing/filters/v1/get.go b/internal/processing/filters/v1/get.go index 39575dd94..3ead09b20 100644 --- a/internal/processing/filters/v1/get.go +++ b/internal/processing/filters/v1/get.go @@ -59,8 +59,8 @@ func (p *Processor) GetAll(ctx context.Context, account *gtsmodel.Account) ([]*a } apiFilters := make([]*apimodel.FilterV1, 0, len(filters)) - for _, list := range filters { - apiFilter, errWithCode := p.apiFilter(ctx, list) + for _, filter := range filters { + apiFilter, errWithCode := p.apiFilter(ctx, filter) if errWithCode != nil { return nil, errWithCode } diff --git a/internal/processing/filters/v1/update.go b/internal/processing/filters/v1/update.go index 1fe49721b..0421dc786 100644 --- a/internal/processing/filters/v1/update.go +++ b/internal/processing/filters/v1/update.go @@ -149,9 +149,11 @@ func (p *Processor) Update( "context_thread", "context_account", } - filterKeywordColumns := []string{ - "keyword", - "whole_word", + filterKeywordColumns := [][]string{ + { + "keyword", + "whole_word", + }, } if err := p.state.DB.UpdateFilter(ctx, filter, filterColumns, filterKeywordColumns, nil, nil); err != nil { if errors.Is(err, db.ErrAlreadyExists) { -- cgit v1.2.3