diff options
author | 2024-09-09 15:56:58 -0700 | |
---|---|---|
committer | 2024-09-09 15:56:58 -0700 | |
commit | 540edef0c20dad4ea13d8af091ccf69796b848b6 (patch) | |
tree | d53106b4170f571a4472e60d35f9b7e2445269d4 /internal/processing/list | |
parent | [feature/frontend] Add options to include Unlisted posts or hide all posts (#... (diff) | |
download | gotosocial-540edef0c20dad4ea13d8af091ccf69796b848b6.tar.xz |
[feature] Implement exclusive lists (#3280)
Fixes #2616
Diffstat (limited to 'internal/processing/list')
-rw-r--r-- | internal/processing/list/create.go | 9 | ||||
-rw-r--r-- | internal/processing/list/get.go | 2 | ||||
-rw-r--r-- | internal/processing/list/update.go | 8 |
3 files changed, 16 insertions, 3 deletions
diff --git a/internal/processing/list/create.go b/internal/processing/list/create.go index 10dec1050..dacd7909f 100644 --- a/internal/processing/list/create.go +++ b/internal/processing/list/create.go @@ -30,12 +30,19 @@ import ( // Create creates one a new list for the given account, using the provided parameters. // These params should have already been validated by the time they reach this function. -func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, title string, repliesPolicy gtsmodel.RepliesPolicy) (*apimodel.List, gtserror.WithCode) { +func (p *Processor) Create( + ctx context.Context, + account *gtsmodel.Account, + title string, + repliesPolicy gtsmodel.RepliesPolicy, + exclusive bool, +) (*apimodel.List, gtserror.WithCode) { list := >smodel.List{ ID: id.NewULID(), Title: title, AccountID: account.ID, RepliesPolicy: repliesPolicy, + Exclusive: &exclusive, } if err := p.state.DB.PutList(ctx, list); err != nil { diff --git a/internal/processing/list/get.go b/internal/processing/list/get.go index 9a7e7716f..cdd3c6e0c 100644 --- a/internal/processing/list/get.go +++ b/internal/processing/list/get.go @@ -47,7 +47,7 @@ func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, id strin return p.apiList(ctx, list) } -// GetMultiple returns multiple lists created by the given account, sorted by list ID DESC (newest first). +// GetAll returns multiple lists created by the given account, sorted by list ID DESC (newest first). func (p *Processor) GetAll(ctx context.Context, account *gtsmodel.Account) ([]*apimodel.List, gtserror.WithCode) { lists, err := p.state.DB.GetListsForAccountID( // Use barebones ctx; no embedded diff --git a/internal/processing/list/update.go b/internal/processing/list/update.go index 656af1f78..408c334de 100644 --- a/internal/processing/list/update.go +++ b/internal/processing/list/update.go @@ -36,6 +36,7 @@ func (p *Processor) Update( id string, title *string, repliesPolicy *gtsmodel.RepliesPolicy, + exclusive *bool, ) (*apimodel.List, gtserror.WithCode) { list, errWithCode := p.getList( // Use barebones ctx; no embedded @@ -49,7 +50,7 @@ func (p *Processor) Update( } // Only update columns we're told to update. - columns := make([]string, 0, 2) + columns := make([]string, 0, 3) if title != nil { list.Title = *title @@ -61,6 +62,11 @@ func (p *Processor) Update( columns = append(columns, "replies_policy") } + if exclusive != nil { + list.Exclusive = exclusive + columns = append(columns, "exclusive") + } + if err := p.state.DB.UpdateList(ctx, list, columns...); err != nil { if errors.Is(err, db.ErrAlreadyExists) { err = errors.New("you already have a list with this title") |