diff options
Diffstat (limited to 'internal/processing/fedi/accept.go')
-rw-r--r-- | internal/processing/fedi/accept.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/internal/processing/fedi/accept.go b/internal/processing/fedi/accept.go index 72d810f94..fc699ee08 100644 --- a/internal/processing/fedi/accept.go +++ b/internal/processing/fedi/accept.go @@ -27,14 +27,14 @@ import ( ) // AcceptGet handles the getting of a fedi/activitypub -// representation of a local interaction approval. +// representation of a local interaction acceptance. // // It performs appropriate authentication before // returning a JSON serializable interface. func (p *Processor) AcceptGet( ctx context.Context, requestedUser string, - approvalID string, + reqID string, ) (interface{}, gtserror.WithCode) { // Authenticate incoming request, getting related accounts. auth, errWithCode := p.authenticate(ctx, requestedUser) @@ -52,25 +52,26 @@ func (p *Processor) AcceptGet( receivingAcct := auth.receivingAcct - approval, err := p.state.DB.GetInteractionApprovalByID(ctx, approvalID) + req, err := p.state.DB.GetInteractionRequestByID(ctx, reqID) if err != nil && !errors.Is(err, db.ErrNoEntries) { - err := gtserror.Newf("db error getting approval %s: %w", approvalID, err) + err := gtserror.Newf("db error getting interaction request %s: %w", reqID, err) return nil, gtserror.NewErrorInternalError(err) } - if approval.AccountID != receivingAcct.ID { - const text = "approval does not belong to receiving account" - return nil, gtserror.NewErrorNotFound(errors.New(text)) + if req == nil || !req.IsAccepted() { + // Request doesn't exist or hasn't been accepted. + err := gtserror.Newf("interaction request %s not found", reqID) + return nil, gtserror.NewErrorNotFound(err) } - if approval == nil { - err := gtserror.Newf("approval %s not found", approvalID) - return nil, gtserror.NewErrorNotFound(err) + if req.TargetAccountID != receivingAcct.ID { + const text = "interaction request does not belong to receiving account" + return nil, gtserror.NewErrorNotFound(errors.New(text)) } - accept, err := p.converter.InteractionApprovalToASAccept(ctx, approval) + accept, err := p.converter.InteractionReqToASAccept(ctx, req) if err != nil { - err := gtserror.Newf("error converting approval: %w", err) + err := gtserror.Newf("error converting accept: %w", err) return nil, gtserror.NewErrorInternalError(err) } |