mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-23 22:53:32 -06:00
Follow request improvements (#282)
* tiny doc update * add rejectfollowrequest to db * add follow request reject to processor * add reject handler * tidy up follow request api * tidy up federation call * regenerate swagger docs * api endpoint tests * processor test * add reject federatingdb handler * start writing reject tests * test reject follow request * go fmt * increase sleep for slow test setups * more relaxed time.sleep
This commit is contained in:
parent
107685e22e
commit
15621f5324
24 changed files with 1256 additions and 69 deletions
|
|
@ -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 := >smodel.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(>smodel.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{}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue