summaryrefslogtreecommitdiff
path: root/internal/db/bundb/list.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/bundb/list.go')
-rw-r--r--internal/db/bundb/list.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/internal/db/bundb/list.go b/internal/db/bundb/list.go
index 5cf10ce3c..ec96f1dfc 100644
--- a/internal/db/bundb/list.go
+++ b/internal/db/bundb/list.go
@@ -143,11 +143,7 @@ func (l *listDB) PopulateList(ctx context.Context, list *gtsmodel.List) error {
}
}
- if err := errs.Combine(); err != nil {
- return gtserror.Newf("%w", err)
- }
-
- return nil
+ return errs.Combine()
}
func (l *listDB) PutList(ctx context.Context, list *gtsmodel.List) error {
@@ -503,6 +499,22 @@ func (l *listDB) DeleteListEntriesForFollowID(ctx context.Context, followID stri
return nil
}
+func (l *listDB) ListIncludesAccount(ctx context.Context, listID string, accountID string) (bool, error) {
+ exists, err := l.db.
+ NewSelect().
+ TableExpr("? AS ?", bun.Ident("list_entries"), bun.Ident("list_entry")).
+ Join(
+ "JOIN ? AS ? ON ? = ?",
+ bun.Ident("follows"), bun.Ident("follow"),
+ bun.Ident("list_entry.follow_id"), bun.Ident("follow.id"),
+ ).
+ Where("? = ?", bun.Ident("list_entry.list_id"), listID).
+ Where("? = ?", bun.Ident("follow.target_account_id"), accountID).
+ Exists(ctx)
+
+ return exists, l.db.ProcessError(err)
+}
+
// collate will collect the values of type T from an expected slice of length 'len',
// passing the expected index to each call of 'get' and deduplicating the end result.
func collate[T comparable](get func(int) T, len int) []T {