diff options
| author | 2024-08-24 11:49:37 +0200 | |
|---|---|---|
| committer | 2024-08-24 11:49:37 +0200 | |
| commit | f23f04e0b1d117be714bf91d5266dab219ed741e (patch) | |
| tree | 0b3ddd60d51c8729949c3669993910a7f8f32a7b /internal/processing/fedi | |
| parent | [performance] ffmpeg ffprobe wrapper improvements (#3225) (diff) | |
| download | gotosocial-f23f04e0b1d117be714bf91d5266dab219ed741e.tar.xz | |
[feature] Interaction requests client api + settings panel (#3215)
* [feature] Interaction requests client api + settings panel
* test accept / reject
* fmt
* don't pin rejected interaction
* use single db model for interaction accept, reject, and request
* swaggor
* env sharting
* append errors
* remove ErrNoEntries checks
* change intReqID to reqID
* rename "pend" to "request"
* markIntsPending -> mark interactionsPending
* use log instead of returning error when rejecting interaction
* empty migration
* jolly renaming
* make interactionURI unique again
* swag grr
* remove unnecessary locks
* invalidate as last step
Diffstat (limited to 'internal/processing/fedi')
| -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)  	}  | 
