summaryrefslogtreecommitdiff
path: root/internal/processing/followrequest.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-10-16 13:27:43 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-16 13:27:43 +0200
commit15621f5324b4613d83efb94711c97eeaa83da2b3 (patch)
treeb86c837dec89f5c74a7127f1bcd8e224bf6dd8a6 /internal/processing/followrequest.go
parentUser password change (#280) (diff)
downloadgotosocial-15621f5324b4613d83efb94711c97eeaa83da2b3.tar.xz
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
Diffstat (limited to 'internal/processing/followrequest.go')
-rw-r--r--internal/processing/followrequest.go43
1 files changed, 41 insertions, 2 deletions
diff --git a/internal/processing/followrequest.go b/internal/processing/followrequest.go
index 74bffd693..20df80f57 100644
--- a/internal/processing/followrequest.go
+++ b/internal/processing/followrequest.go
@@ -99,6 +99,45 @@ func (p *processor) FollowRequestAccept(ctx context.Context, auth *oauth.Auth, a
return r, nil
}
-func (p *processor) FollowRequestDeny(ctx context.Context, auth *oauth.Auth) gtserror.WithCode {
- return nil
+func (p *processor) FollowRequestReject(ctx context.Context, auth *oauth.Auth, accountID string) (*apimodel.Relationship, gtserror.WithCode) {
+ followRequest, err := p.db.RejectFollowRequest(ctx, accountID, auth.Account.ID)
+ if err != nil {
+ return nil, gtserror.NewErrorNotFound(err)
+ }
+
+ if followRequest.Account == nil {
+ a, err := p.db.GetAccountByID(ctx, followRequest.AccountID)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(err)
+ }
+ followRequest.Account = a
+ }
+
+ if followRequest.TargetAccount == nil {
+ a, err := p.db.GetAccountByID(ctx, followRequest.TargetAccountID)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(err)
+ }
+ followRequest.TargetAccount = a
+ }
+
+ p.fromClientAPI <- messages.FromClientAPI{
+ APObjectType: ap.ActivityFollow,
+ APActivityType: ap.ActivityReject,
+ GTSModel: followRequest,
+ OriginAccount: followRequest.Account,
+ TargetAccount: followRequest.TargetAccount,
+ }
+
+ gtsR, err := p.db.GetRelationship(ctx, auth.Account.ID, accountID)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(err)
+ }
+
+ r, err := p.tc.RelationshipToAPIRelationship(ctx, gtsR)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(err)
+ }
+
+ return r, nil
}