diff options
Diffstat (limited to 'internal/federation/federatingdb/delete.go')
-rw-r--r-- | internal/federation/federatingdb/delete.go | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/internal/federation/federatingdb/delete.go b/internal/federation/federatingdb/delete.go index 9aa36ee90..fc77f8025 100644 --- a/internal/federation/federatingdb/delete.go +++ b/internal/federation/federatingdb/delete.go @@ -27,7 +27,6 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/messages" - "github.com/superseriousbusiness/gotosocial/internal/util" ) // Delete removes the entry with the given id. @@ -40,32 +39,19 @@ func (f *federatingDB) Delete(ctx context.Context, id *url.URL) error { l := f.log.WithFields( logrus.Fields{ "func": "Delete", - "id": id.String(), + "id": id, }, ) - l.Debugf("received DELETE id %s", id.String()) + l.Debug("entering Delete") - targetAcctI := ctx.Value(util.APAccount) - if targetAcctI == nil { - // If the target account wasn't set on the context, that means this request didn't pass through the - // API, but came from inside GtS as the result of another activity on this instance. That being so, - // we can safely just ignore this activity, since we know we've already processed it elsewhere. - return nil - } - targetAcct, ok := targetAcctI.(*gtsmodel.Account) - if !ok { - l.Error("DELETE: target account was set on context but couldn't be parsed") - return nil + targetAcct, fromFederatorChan, err := extractFromCtx(ctx) + if err != nil { + return err } - - fromFederatorChanI := ctx.Value(util.APFromFederatorChanKey) - if fromFederatorChanI == nil { - l.Error("DELETE: from federator channel wasn't set on context") - return nil - } - fromFederatorChan, ok := fromFederatorChanI.(chan messages.FromFederator) - if !ok { - l.Error("DELETE: from federator channel was set on context but couldn't be parsed") + if targetAcct == nil || fromFederatorChan == nil { + // If the target account or federator channel wasn't set on the context, that means this request didn't pass + // through the API, but came from inside GtS as the result of another activity on this instance. That being so, + // we can safely just ignore this activity, since we know we've already processed it elsewhere. return nil } |