summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/account/delete.go18
-rw-r--r--internal/processing/account_test.go11
2 files changed, 20 insertions, 9 deletions
diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go
index 5b40804d8..67192cb8f 100644
--- a/internal/processing/account/delete.go
+++ b/internal/processing/account/delete.go
@@ -145,11 +145,12 @@ selectStatusesLoop:
for {
statuses, err := p.db.GetAccountStatuses(ctx, account.ID, 20, false, false, maxID, "", false, false, false)
if err != nil {
- if err == db.ErrNoEntries {
+ if errors.Is(err, db.ErrNoEntries) {
// no statuses left for this instance so we're done
l.Infof("Delete: done iterating through statuses for account %s", account.Username)
break selectStatusesLoop
}
+
// an actual error has occurred
l.Errorf("Delete: db error selecting statuses for account %s: %s", account.Username, err)
break selectStatusesLoop
@@ -158,6 +159,7 @@ selectStatusesLoop:
for i, s := range statuses {
// pass the status delete through the client api channel for processing
s.Account = account
+
l.Debug("putting status in the client api channel")
p.clientWorker.Queue(messages.FromClientAPI{
APObjectType: ap.ObjectNote,
@@ -168,20 +170,20 @@ selectStatusesLoop:
})
if err := p.db.DeleteByID(ctx, s.ID, s); err != nil {
- if err != db.ErrNoEntries {
+ if !errors.Is(err, db.ErrNoEntries) {
// actual error has occurred
- l.Errorf("Delete: db error status %s for account %s: %s", s.ID, account.Username, err)
- break selectStatusesLoop
+ l.Errorf("Delete: db error deleting status %s for account %s: %s", s.ID, account.Username, err)
+ continue
}
}
// if there are any boosts of this status, delete them as well
boosts := []*gtsmodel.Status{}
if err := p.db.GetWhere(ctx, []db.Where{{Key: "boost_of_id", Value: s.ID}}, &boosts); err != nil {
- if err != db.ErrNoEntries {
+ if !errors.Is(err, db.ErrNoEntries) {
// an actual error has occurred
l.Errorf("Delete: db error selecting boosts of status %s for account %s: %s", s.ID, account.Username, err)
- break selectStatusesLoop
+ continue
}
}
@@ -189,8 +191,10 @@ selectStatusesLoop:
if b.Account == nil {
bAccount, err := p.db.GetAccountByID(ctx, b.AccountID)
if err != nil {
+ l.Errorf("Delete: db error populating boosted status account: %v", err)
continue
}
+
b.Account = bAccount
}
@@ -207,7 +211,7 @@ selectStatusesLoop:
if err != db.ErrNoEntries {
// actual error has occurred
l.Errorf("Delete: db error deleting boost with id %s: %s", b.ID, err)
- break selectStatusesLoop
+ continue
}
}
}
diff --git a/internal/processing/account_test.go b/internal/processing/account_test.go
index 3fd7d83f4..b34358ba1 100644
--- a/internal/processing/account_test.go
+++ b/internal/processing/account_test.go
@@ -57,10 +57,14 @@ func (suite *AccountTestSuite) TestAccountDeleteLocal() {
DeleteOriginID: deletingAccount.ID,
})
suite.NoError(errWithCode)
- time.Sleep(1 * time.Second) // wait a sec for the delete to process
// the delete should be federated outwards to the following account's inbox
- sent, ok := suite.httpClient.SentMessages[followingAccount.InboxURI]
+ var sent []byte
+ var ok bool
+ for !ok {
+ sent, ok = suite.httpClient.SentMessages[followingAccount.InboxURI]
+ }
+
suite.True(ok)
delete := &struct {
Actor string `json:"actor"`
@@ -79,6 +83,9 @@ func (suite *AccountTestSuite) TestAccountDeleteLocal() {
suite.Equal(pub.PublicActivityPubIRI, delete.CC)
suite.Equal("Delete", delete.Type)
+ // wait for the delete to go through
+ time.Sleep(1 * time.Second)
+
// the deleted account should be deleted
dbAccount, err := suite.db.GetAccountByID(ctx, deletingAccount.ID)
suite.NoError(err)