From c27b4d7ed02cdabac00c3ddedb8201b74f745ec6 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 25 Feb 2023 13:16:30 +0100 Subject: [feature] Client API endpoints + v. basic web view for pinned posts (#1547) * implement status pin client api + web handler * make test names + comments more descriptive * don't use separate table for status pins * remove unused add + remove checking * tidy up + add some more tests --- internal/db/account.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'internal/db/account.go') diff --git a/internal/db/account.go b/internal/db/account.go index 42a8c62b0..7989b9838 100644 --- a/internal/db/account.go +++ b/internal/db/account.go @@ -62,15 +62,29 @@ type Account interface { // GetAccountStatusesCount is a shortcut for the common action of counting statuses produced by accountID. CountAccountStatuses(ctx context.Context, accountID string) (int, Error) + // CountAccountPinned returns the total number of pinned statuses owned by account with the given id. + CountAccountPinned(ctx context.Context, accountID string) (int, Error) + // GetAccountStatuses is a shortcut for getting the most recent statuses. accountID is optional, if not provided // then all statuses will be returned. If limit is set to 0, the size of the returned slice will not be limited. This can // be very memory intensive so you probably shouldn't do this! - // In case of no entries, a 'no entries' error will be returned - GetAccountStatuses(ctx context.Context, accountID string, limit int, excludeReplies bool, excludeReblogs bool, maxID string, minID string, pinnedOnly bool, mediaOnly bool, publicOnly bool) ([]*gtsmodel.Status, Error) + // + // In the case of no statuses, this function will return db.ErrNoEntries. + GetAccountStatuses(ctx context.Context, accountID string, limit int, excludeReplies bool, excludeReblogs bool, maxID string, minID string, mediaOnly bool, publicOnly bool) ([]*gtsmodel.Status, Error) + + // GetAccountPinnedStatuses returns ONLY statuses owned by the give accountID for which a corresponding StatusPin + // exists in the database. Statuses which are not pinned will not be returned by this function. + // + // Statuses will be returned in the order in which they were pinned, from latest pinned to oldest pinned (descending). + // + // In the case of no statuses, this function will return db.ErrNoEntries. + GetAccountPinnedStatuses(ctx context.Context, accountID string) ([]*gtsmodel.Status, Error) // GetAccountWebStatuses is similar to GetAccountStatuses, but it's specifically for returning statuses that // should be visible via the web view of an account. So, only public, federated statuses that aren't boosts // or replies. + // + // In the case of no statuses, this function will return db.ErrNoEntries. GetAccountWebStatuses(ctx context.Context, accountID string, limit int, maxID string) ([]*gtsmodel.Status, Error) GetBookmarks(ctx context.Context, accountID string, limit int, maxID string, minID string) ([]*gtsmodel.StatusBookmark, Error) -- cgit v1.2.3