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/status/fave.go | |
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/status/fave.go')
-rw-r--r-- | internal/processing/status/fave.go | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/internal/processing/status/fave.go b/internal/processing/status/fave.go index a16fb6620..dbeba7fe9 100644 --- a/internal/processing/status/fave.go +++ b/internal/processing/status/fave.go @@ -33,24 +33,46 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/uris" ) -func (p *Processor) getFaveableStatus(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*gtsmodel.Status, *gtsmodel.StatusFave, gtserror.WithCode) { - targetStatus, errWithCode := p.c.GetVisibleTargetStatus(ctx, requestingAccount, targetStatusID) +func (p *Processor) getFaveableStatus( + ctx context.Context, + requester *gtsmodel.Account, + targetID string, +) ( + *gtsmodel.Status, + *gtsmodel.StatusFave, + gtserror.WithCode, +) { + // Get target status and ensure it's not a boost. + target, errWithCode := p.c.GetVisibleTargetStatus( + ctx, + requester, + targetID, + ) + if errWithCode != nil { + return nil, nil, errWithCode + } + + target, errWithCode = p.c.UnwrapIfBoost( + ctx, + requester, + target, + ) if errWithCode != nil { return nil, nil, errWithCode } - if !*targetStatus.Likeable { + if !*target.Likeable { err := errors.New("status is not faveable") return nil, nil, gtserror.NewErrorForbidden(err, err.Error()) } - fave, err := p.state.DB.GetStatusFave(ctx, requestingAccount.ID, targetStatusID) + fave, err := p.state.DB.GetStatusFave(ctx, requester.ID, target.ID) if err != nil && !errors.Is(err, db.ErrNoEntries) { err = fmt.Errorf("getFaveTarget: error checking existing fave: %w", err) return nil, nil, gtserror.NewErrorInternalError(err) } - return targetStatus, fave, nil + return target, fave, nil } // FaveCreate adds a fave for the requestingAccount, targeting the given status (no-op if fave already exists). |