summaryrefslogtreecommitdiff
path: root/internal/db/relationship.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-03-20 19:10:08 +0100
committerLibravatar GitHub <noreply@github.com>2023-03-20 18:10:08 +0000
commite8595f0c64f527af0913d1a426b697e67ff74ac9 (patch)
treea5d45b1ad8b96318944408a23fda91f008643900 /internal/db/relationship.go
parent[chore]: Bump github.com/miekg/dns from 1.1.51 to 1.1.52 (#1636) (diff)
downloadgotosocial-e8595f0c64f527af0913d1a426b697e67ff74ac9.tar.xz
[chore] Refactor account deleting/block logic, tidy up some other processing things (#1599)
* start refactoring account deletion * update to use state.DB * further messing about * some more tidying up * more tidying, cleaning, nice-making * further adventures in refactoring and the woes of technical debt * update fr accept/reject * poking + prodding * fix up deleting * create fave uri * don't log using requestingAccount.ID because it might be nil * move getBookmarks function * use exists query to check for status bookmark * use deletenotifications func * fiddle * delete follow request notif * split up some db functions * Fix possible nil pointer panic * fix more possible nil pointers * fix license headers * warn when follow missing (target) account * return wrapped err when bookmark/fave models can't be retrieved * simplify self account delete * warn log likely race condition * de-sillify status delete loop * move error check due north * warn when unfollowSideEffects has no target account * warn when no boost account is found * warn + dump follow when no account * more warnings * warn on fave account not set * move for loop inside anonymous function * fix funky logic * don't remove mutual account items on block; do make sure unfollow occurs in both directions!
Diffstat (limited to 'internal/db/relationship.go')
-rw-r--r--internal/db/relationship.go63
1 files changed, 51 insertions, 12 deletions
diff --git a/internal/db/relationship.go b/internal/db/relationship.go
index 643a5696a..d13a73dea 100644
--- a/internal/db/relationship.go
+++ b/internal/db/relationship.go
@@ -73,22 +73,61 @@ type Relationship interface {
// The deleted follow request will be returned so that further processing can be done on it.
RejectFollowRequest(ctx context.Context, originAccountID string, targetAccountID string) (*gtsmodel.FollowRequest, Error)
- // GetAccountFollowRequests returns all follow requests targeting the given account.
- GetAccountFollowRequests(ctx context.Context, accountID string) ([]*gtsmodel.FollowRequest, Error)
+ // GetFollows returns a slice of follows owned by the given accountID, and/or
+ // targeting the given account id.
+ //
+ // If accountID is set and targetAccountID isn't, then all follows created by
+ // accountID will be returned.
+ //
+ // If targetAccountID is set and accountID isn't, then all follows targeting
+ // targetAccountID will be returned.
+ //
+ // If both accountID and targetAccountID are set, then only 0 or 1 follows will
+ // be in the returned slice.
+ GetFollows(ctx context.Context, accountID string, targetAccountID string) ([]*gtsmodel.Follow, Error)
- // GetAccountFollows returns a slice of follows owned by the given accountID.
- GetAccountFollows(ctx context.Context, accountID string) ([]*gtsmodel.Follow, Error)
+ // GetLocalFollowersIDs returns a list of local account IDs which follow the
+ // targetAccountID. The returned IDs are not guaranteed to be ordered in any
+ // particular way, so take care.
+ GetLocalFollowersIDs(ctx context.Context, targetAccountID string) ([]string, Error)
- // CountAccountFollows returns the amount of accounts that the given accountID is following.
+ // CountFollows is like GetFollows, but just counts rather than returning.
+ CountFollows(ctx context.Context, accountID string, targetAccountID string) (int, Error)
+
+ // GetFollowRequests returns a slice of follows requests owned by the given
+ // accountID, and/or targeting the given account id.
+ //
+ // If accountID is set and targetAccountID isn't, then all requests created by
+ // accountID will be returned.
//
- // If localOnly is set to true, then only follows from *this instance* will be returned.
- CountAccountFollows(ctx context.Context, accountID string, localOnly bool) (int, Error)
+ // If targetAccountID is set and accountID isn't, then all requests targeting
+ // targetAccountID will be returned.
+ //
+ // If both accountID and targetAccountID are set, then only 0 or 1 requests will
+ // be in the returned slice.
+ GetFollowRequests(ctx context.Context, accountID string, targetAccountID string) ([]*gtsmodel.FollowRequest, Error)
+
+ // CountFollowRequests is like GetFollowRequests, but just counts rather than returning.
+ CountFollowRequests(ctx context.Context, accountID string, targetAccountID string) (int, Error)
- // GetAccountFollowedBy fetches follows that target given accountID.
+ // Unfollow removes a follow targeting targetAccountID and originating
+ // from originAccountID.
+ //
+ // If a follow was removed this way, the AP URI of the follow will be
+ // returned to the caller, so that further processing can take place
+ // if necessary.
//
- // If localOnly is set to true, then only follows from *this instance* will be returned.
- GetAccountFollowedBy(ctx context.Context, accountID string, localOnly bool) ([]*gtsmodel.Follow, Error)
+ // If no follow was removed this way, the returned string will be empty.
+ Unfollow(ctx context.Context, originAccountID string, targetAccountID string) (string, Error)
- // CountAccountFollowedBy returns the amounts that the given ID is followed by.
- CountAccountFollowedBy(ctx context.Context, accountID string, localOnly bool) (int, Error)
+ // UnfollowRequest removes a follow request targeting targetAccountID
+ // and originating from originAccountID.
+ //
+ // If a follow request was removed this way, the AP URI of the follow
+ // request will be returned to the caller, so that further processing
+ // can take place if necessary.
+ //
+ // If no follow request was removed this way, the returned string will
+ // be empty.
+ UnfollowRequest(ctx context.Context, originAccountID string, targetAccountID string) (string, Error)
}