Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Process outgoing Move from clientAPI #2750

Merged
merged 20 commits into from Mar 13, 2024
Merged

Conversation

tsmethurst
Copy link
Contributor

@tsmethurst tsmethurst commented Mar 12, 2024

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.

This pull request implements actual processing functionality for accounts Moving via the GtS client API:

  • Federate Move activity out when a valid Move has been submitted via the API.
  • Process local side effects of a Move (redirect local followers to new target).
  • Prevent Moved local accounts from taking most write/create style actions via the client API.
  • Document the Move procedure.
  • Indicate on the web frontend if an account has moved (see image).

Screenshot from 2024-03-11 12-18-52

Relates to #130

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).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have not leveraged AI to create the proposed changes.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • 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.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

Copy link
Member

@daenney daenney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick first pass. Things look pretty sensible and the client API side looks a lot less complicated.

internal/api/client/accounts/note.go Outdated Show resolved Hide resolved
if err != nil {
err := fmt.Errorf("invalid moved_to_uri provided in account Move request: %w", err)
return gtserror.NewErrorBadRequest(err, err.Error())
}

if movedToURI.Scheme != "https" && movedToURI.Scheme != "http" {
if targetAcctURI.Scheme != "https" && targetAcctURI.Scheme != "http" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you can't really move to an http URL, as the whole fedi requires TLS, should we check it against config.GetProtocol instead? In case you're running in test mode or something. GenerateURIForMove also uses config.GetProtocol.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think doing this would actually break some of our tests (as we use a mix of http / https test domains).

honestly i don't think it's much of an attack vector (if any), and the check will be faster this way than going through a read mutex lock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave this for now, but perhaps we can make a separate issue to better support http-only local testing, since similar discussions have happened elsewhere too.

internal/uris/uri.go Outdated Show resolved Hide resolved
Co-authored-by: Daenney <daenney@users.noreply.github.com>
@tsmethurst tsmethurst merged commit ab2d063 into main Mar 13, 2024
3 checks passed
@tsmethurst tsmethurst deleted the process_outgoing_move branch March 13, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants