mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@@ -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 approval == nil {
|
||||
err := gtserror.Newf("approval %s not found", approvalID)
|
||||
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)
|
||||
}
|
||||
|
||||
accept, err := p.converter.InteractionApprovalToASAccept(ctx, approval)
|
||||
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.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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user