summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/delete.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-07-27 10:45:22 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-27 10:45:22 +0200
commit2c2dbe318e2d01f4d7dbbade3970684e4f0b9f6b (patch)
tree0565cb6e2ce8a3f7f96fb2260fbdc0b7511abd87 /internal/federation/federatingdb/delete.go
parentdoc updates (#117) (diff)
downloadgotosocial-2c2dbe318e2d01f4d7dbbade3970684e4f0b9f6b.tar.xz
federating db updates (#118)
Diffstat (limited to 'internal/federation/federatingdb/delete.go')
-rw-r--r--internal/federation/federatingdb/delete.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/internal/federation/federatingdb/delete.go b/internal/federation/federatingdb/delete.go
index fe32434c4..02ce43620 100644
--- a/internal/federation/federatingdb/delete.go
+++ b/internal/federation/federatingdb/delete.go
@@ -26,25 +26,27 @@ func (f *federatingDB) Delete(ctx context.Context, id *url.URL) error {
)
l.Debugf("received DELETE id %s", id.String())
- inboxAcctI := ctx.Value(util.APAccount)
- if inboxAcctI == nil {
- l.Error("inbox account wasn't set on context")
+ 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
}
- inboxAcct, ok := inboxAcctI.(*gtsmodel.Account)
+ targetAcct, ok := targetAcctI.(*gtsmodel.Account)
if !ok {
- l.Error("inbox account was set on context but couldn't be parsed")
+ l.Error("DELETE: target account was set on context but couldn't be parsed")
return nil
}
fromFederatorChanI := ctx.Value(util.APFromFederatorChanKey)
if fromFederatorChanI == nil {
- l.Error("from federator channel wasn't set on context")
+ l.Error("DELETE: from federator channel wasn't set on context")
return nil
}
fromFederatorChan, ok := fromFederatorChanI.(chan gtsmodel.FromFederator)
if !ok {
- l.Error("from federator channel was set on context but couldn't be parsed")
+ l.Error("DELETE: from federator channel was set on context but couldn't be parsed")
return nil
}
@@ -57,13 +59,13 @@ func (f *federatingDB) Delete(ctx context.Context, id *url.URL) error {
// it's a status
l.Debugf("uri is for status with id: %s", s.ID)
if err := f.db.DeleteByID(s.ID, &gtsmodel.Status{}); err != nil {
- return fmt.Errorf("Delete: err deleting status: %s", err)
+ return fmt.Errorf("DELETE: err deleting status: %s", err)
}
fromFederatorChan <- gtsmodel.FromFederator{
APObjectType: gtsmodel.ActivityStreamsNote,
APActivityType: gtsmodel.ActivityStreamsDelete,
GTSModel: s,
- ReceivingAccount: inboxAcct,
+ ReceivingAccount: targetAcct,
}
}
@@ -72,13 +74,13 @@ func (f *federatingDB) Delete(ctx context.Context, id *url.URL) error {
// it's an account
l.Debugf("uri is for an account with id: %s", s.ID)
if err := f.db.DeleteByID(a.ID, &gtsmodel.Account{}); err != nil {
- return fmt.Errorf("Delete: err deleting account: %s", err)
+ return fmt.Errorf("DELETE: err deleting account: %s", err)
}
fromFederatorChan <- gtsmodel.FromFederator{
APObjectType: gtsmodel.ActivityStreamsProfile,
APActivityType: gtsmodel.ActivityStreamsDelete,
GTSModel: a,
- ReceivingAccount: inboxAcct,
+ ReceivingAccount: targetAcct,
}
}