summaryrefslogtreecommitdiff
path: root/internal/processing/filters/v1
diff options
context:
space:
mode:
authorLibravatar Vyr Cossont <VyrCossont@users.noreply.github.com>2024-05-31 03:55:56 -0700
committerLibravatar GitHub <noreply@github.com>2024-05-31 12:55:56 +0200
commit61a8d362557c1787d534024ed2f14e999b785cc3 (patch)
treef0ace4432170c0c88afa3233c2c327c808b7b92d /internal/processing/filters/v1
parent[chore] little startup tweaks (#2941) (diff)
downloadgotosocial-61a8d362557c1787d534024ed2f14e999b785cc3.tar.xz
[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
Diffstat (limited to 'internal/processing/filters/v1')
-rw-r--r--internal/processing/filters/v1/get.go4
-rw-r--r--internal/processing/filters/v1/update.go8
2 files changed, 7 insertions, 5 deletions
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) {