summaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/bundb/relationship.go25
-rw-r--r--internal/db/relationship.go5
2 files changed, 30 insertions, 0 deletions
diff --git a/internal/db/bundb/relationship.go b/internal/db/bundb/relationship.go
index 64d896527..4f15c7772 100644
--- a/internal/db/bundb/relationship.go
+++ b/internal/db/bundb/relationship.go
@@ -255,6 +255,31 @@ func (r *relationshipDB) AcceptFollowRequest(ctx context.Context, originAccountI
return follow, nil
}
+func (r *relationshipDB) RejectFollowRequest(ctx context.Context, originAccountID string, targetAccountID string) (*gtsmodel.FollowRequest, db.Error) {
+ // first get the follow request out of the database
+ fr := &gtsmodel.FollowRequest{}
+ if err := r.conn.
+ NewSelect().
+ Model(fr).
+ Where("account_id = ?", originAccountID).
+ Where("target_account_id = ?", targetAccountID).
+ Scan(ctx); err != nil {
+ return nil, r.conn.ProcessError(err)
+ }
+
+ // now delete it from the database by ID
+ if _, err := r.conn.
+ NewDelete().
+ Model(&gtsmodel.FollowRequest{ID: fr.ID}).
+ WherePK().
+ Exec(ctx); err != nil {
+ return nil, r.conn.ProcessError(err)
+ }
+
+ // return the deleted follow request
+ return fr, nil
+}
+
func (r *relationshipDB) GetAccountFollowRequests(ctx context.Context, accountID string) ([]*gtsmodel.FollowRequest, db.Error) {
followRequests := []*gtsmodel.FollowRequest{}
diff --git a/internal/db/relationship.go b/internal/db/relationship.go
index c43b3d9ac..ac2df5228 100644
--- a/internal/db/relationship.go
+++ b/internal/db/relationship.go
@@ -54,6 +54,11 @@ type Relationship interface {
// It will return the newly created follow for further processing.
AcceptFollowRequest(ctx context.Context, originAccountID string, targetAccountID string) (*gtsmodel.Follow, Error)
+ // RejectFollowRequest fetches a follow request from the database, and then deletes it.
+ //
+ // 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)