diff options
| author | 2025-10-15 18:19:17 +0200 | |
|---|---|---|
| committer | 2025-10-17 15:33:42 +0200 | |
| commit | 717fd7604aa7ae49acb51b9e7bd6b2cce046f85b (patch) | |
| tree | faeadd209fdeff0294ba7824e42083f55cd6b9e7 /internal/federation | |
| parent | [performance] cache account IDs in home timeline query not in exclusive lists... (diff) | |
| download | gotosocial-717fd7604aa7ae49acb51b9e7bd6b2cce046f85b.tar.xz | |
[bugfix] Fix HTTP return code for Likes of remote statuses (#4504)
# Description
> If this is a code change, please include a summary of what you've coded, and link to the issue(s) it closes/implements.
>
> If this is a documentation change, please briefly describe what you've changed and why.
Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4492 by golly gosh!!!
## Checklist
Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]`
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
- [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md).
- [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
- [x] I/we have not leveraged AI to create the proposed changes.
- [x] I/we have performed a self-review of added code.
- [x] I/we have written code that is legible and maintainable by others.
- [x] I/we have commented the added code, particularly in hard-to-understand areas.
- [ ] I/we have made any necessary changes to documentation.
- [ ] I/we have added tests that cover new code.
- [x] I/we have run tests and they pass locally with the changes.
- [x] I/we have run `go fmt ./...` and `golangci-lint run`.
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4504
Reviewed-by: kim <gruf@noreply.codeberg.org>
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/federation')
| -rw-r--r-- | internal/federation/federatingdb/like.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/internal/federation/federatingdb/like.go b/internal/federation/federatingdb/like.go index ca26c0692..4b7a5104e 100644 --- a/internal/federation/federatingdb/like.go +++ b/internal/federation/federatingdb/like.go @@ -54,21 +54,31 @@ func (f *DB) Like(ctx context.Context, likeable vocab.ActivityStreamsLike) error // Convert received AS like type to internal fave model. fave, err := f.converter.ASLikeToFave(ctx, likeable) - if err != nil { + if err != nil && !errors.Is(err, db.ErrNoEntries) { err := gtserror.Newf("error converting from AS type: %w", err) return gtserror.WrapWithCode(http.StatusBadRequest, err) } + // If the converted fave is nil that means we + // probably didn't have the target status or + // account or whatever in the DB, which so we + // don't need to do anything with this Like. + if fave == nil { + return nil + } + // Ensure fave enacted by correct account. if fave.AccountID != requesting.ID { return gtserror.NewfWithCode(http.StatusForbidden, "requester %s is not expected actor %s", requesting.URI, fave.Account.URI) } - // Ensure fave received by correct account. + // If the fave doesn't target the account + // receiving the message, just toss it. + // We don't (currently) need to handle + // Likes of other people's statuses. if fave.TargetAccountID != receiving.ID { - return gtserror.NewfWithCode(http.StatusForbidden, "receiver %s is not expected object %s", - receiving.URI, fave.TargetAccount.URI) + return nil } if !*fave.Status.Local { |
