diff options
author | 2023-12-01 15:27:15 +0100 | |
---|---|---|
committer | 2023-12-01 15:27:15 +0100 | |
commit | 0e2c34219112db3a6b7801530a946fd5b1bbb111 (patch) | |
tree | 6a5557373dbfc9edc80de941b13e870a8af32881 /internal/processing/workers | |
parent | [bugfix] in fedi API CreateStatus(), handle case of data-race and return earl... (diff) | |
download | gotosocial-0e2c34219112db3a6b7801530a946fd5b1bbb111.tar.xz |
[bugfix/chore] `Announce` reliability updates (#2405)v0.13.0-rc1
* [bugfix/chore] `Announce` updates
* test update
* fix tests
* TestParseAnnounce
* update comments
* don't lock/unlock, change function signature
* naming stuff
* don't check domain block twice
* UnwrapIfBoost
* beep boop
Diffstat (limited to 'internal/processing/workers')
-rw-r--r-- | internal/processing/workers/fromfediapi.go | 38 | ||||
-rw-r--r-- | internal/processing/workers/fromfediapi_test.go | 4 |
2 files changed, 19 insertions, 23 deletions
diff --git a/internal/processing/workers/fromfediapi.go b/internal/processing/workers/fromfediapi.go index 4c5c85666..d04e4ab8d 100644 --- a/internal/processing/workers/fromfediapi.go +++ b/internal/processing/workers/fromfediapi.go @@ -26,7 +26,6 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtscontext" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" - "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/processing/account" @@ -332,45 +331,44 @@ func (p *fediAPI) CreateLike(ctx context.Context, fMsg messages.FromFediAPI) err } func (p *fediAPI) CreateAnnounce(ctx context.Context, fMsg messages.FromFediAPI) error { - status, ok := fMsg.GTSModel.(*gtsmodel.Status) + boost, ok := fMsg.GTSModel.(*gtsmodel.Status) if !ok { return gtserror.Newf("%T not parseable as *gtsmodel.Status", fMsg.GTSModel) } // Dereference status that this boosts, note - // that this will handle dereferencing the status + // that this will handle storing the boost in + // the db, and dereferencing the target status // ancestors / descendants where appropriate. - if err := p.federate.DereferenceAnnounce(ctx, - status, + var err error + boost, err = p.federate.EnrichAnnounce( + ctx, + boost, fMsg.ReceivingAccount.Username, - ); err != nil { - return gtserror.Newf("error dereferencing announce: %w", err) - } - - // Generate an ID for the boost wrapper status. - statusID, err := id.NewULIDFromTime(status.CreatedAt) + ) if err != nil { - return gtserror.Newf("error generating id: %w", err) - } - status.ID = statusID + if gtserror.IsUnretrievable(err) { + // Boosted status domain blocked, nothing to do. + log.Debugf(ctx, "skipping announce: %v", err) + return nil + } - // Store the boost wrapper status. - if err := p.state.DB.PutStatus(ctx, status); err != nil { - return gtserror.Newf("db error inserting status: %w", err) + // Actual error. + return gtserror.Newf("error dereferencing announce: %w", err) } // Timeline and notify the announce. - if err := p.surface.timelineAndNotifyStatus(ctx, status); err != nil { + if err := p.surface.timelineAndNotifyStatus(ctx, boost); err != nil { log.Errorf(ctx, "error timelining and notifying status: %v", err) } - if err := p.surface.notifyAnnounce(ctx, status); err != nil { + if err := p.surface.notifyAnnounce(ctx, boost); err != nil { log.Errorf(ctx, "error notifying announce: %v", err) } // Interaction counts changed on the original status; // uncache the prepared version from all timelines. - p.surface.invalidateStatusFromTimelines(ctx, status.ID) + p.surface.invalidateStatusFromTimelines(ctx, boost.BoostOfID) return nil } diff --git a/internal/processing/workers/fromfediapi_test.go b/internal/processing/workers/fromfediapi_test.go index 952c008cc..799eaf2dc 100644 --- a/internal/processing/workers/fromfediapi_test.go +++ b/internal/processing/workers/fromfediapi_test.go @@ -45,9 +45,7 @@ func (suite *FromFediAPITestSuite) TestProcessFederationAnnounce() { boostingAccount := suite.testAccounts["remote_account_1"] announceStatus := >smodel.Status{} announceStatus.URI = "https://example.org/some-announce-uri" - announceStatus.BoostOf = >smodel.Status{ - URI: boostedStatus.URI, - } + announceStatus.BoostOfURI = boostedStatus.URI announceStatus.CreatedAt = time.Now() announceStatus.UpdatedAt = time.Now() announceStatus.AccountID = boostingAccount.ID |