[feature] do not uncache status / emoji media if attached status is bookmarked (#2956)

* do not uncache status / emoji media if attached status is bookmarked

* add status bookmark and bookmark IDs caches

* update status bookmark tests

* move IsStatusBookmarkedBy() to StatusBookmark{} interface, rely on cache

* fix envparsing.sh test
This commit is contained in:
kim 2024-06-06 10:44:43 +00:00 committed by GitHub
commit 5dcc954072
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 501 additions and 215 deletions

View file

@ -25,11 +25,16 @@ import (
type StatusBookmark interface {
// GetStatusBookmark gets one status bookmark with the given ID.
GetStatusBookmark(ctx context.Context, id string) (*gtsmodel.StatusBookmark, error)
GetStatusBookmarkByID(ctx context.Context, id string) (*gtsmodel.StatusBookmark, error)
// GetStatusBookmarkID is a shortcut function for returning just the database ID
// of a status bookmark created by the given accountID, targeting the given statusID.
GetStatusBookmarkID(ctx context.Context, accountID string, statusID string) (string, error)
// GetStatusBookmark fetches a status bookmark by the given account ID on the given status ID, if it exists.
GetStatusBookmark(ctx context.Context, accountID string, statusID string) (*gtsmodel.StatusBookmark, error)
// IsStatusBookmarked returns whether status has been bookmarked by any account.
IsStatusBookmarked(ctx context.Context, statusID string) (bool, error)
// IsStatusBookmarkedBy returns whether status ID is bookmarked by the given account ID.
IsStatusBookmarkedBy(ctx context.Context, accountID string, statusID string) (bool, error)
// GetStatusBookmarks retrieves status bookmarks created by the given accountID,
// and using the provided parameters. If limit is < 0 then no limit will be set.
@ -42,7 +47,7 @@ type StatusBookmark interface {
PutStatusBookmark(ctx context.Context, statusBookmark *gtsmodel.StatusBookmark) error
// DeleteStatusBookmark deletes one status bookmark with the given ID.
DeleteStatusBookmark(ctx context.Context, id string) error
DeleteStatusBookmarkByID(ctx context.Context, id string) error
// DeleteStatusBookmarks mass deletes status bookmarks targeting targetAccountID
// and/or originating from originAccountID and/or bookmarking statusID.