diff --git a/docs/api/swagger.yaml b/docs/api/swagger.yaml index 8e3c942c2..8bd6e3725 100644 --- a/docs/api/swagger.yaml +++ b/docs/api/swagger.yaml @@ -3316,7 +3316,6 @@ paths: post: consumes: - multipart/form-data - description: NOT IMPLEMENTED YET! operationId: accountMove parameters: - description: Password of the account user, for confirmation. diff --git a/internal/api/client/accounts/accountmove.go b/internal/api/client/accounts/accountmove.go index 4f311e106..3698c06a3 100644 --- a/internal/api/client/accounts/accountmove.go +++ b/internal/api/client/accounts/accountmove.go @@ -31,8 +31,6 @@ // // Move your account to another account. // -// NOT IMPLEMENTED YET! -// // --- // tags: // - accounts diff --git a/internal/api/client/accounts/accounts.go b/internal/api/client/accounts/accounts.go index 000c27d78..c94fbfbaa 100644 --- a/internal/api/client/accounts/accounts.go +++ b/internal/api/client/accounts/accounts.go @@ -113,5 +113,5 @@ func (m *Module) Route(attachHandler func(method string, path string, f ...gin.H // migration handlers attachHandler(http.MethodPost, AliasPath, m.AccountAliasPOSTHandler) - // attachHandler(http.MethodPost, MovePath, m.AccountMovePOSTHandler) // todo: enable this only when Move is completed + attachHandler(http.MethodPost, MovePath, m.AccountMovePOSTHandler) } diff --git a/internal/processing/account/move.go b/internal/processing/account/move.go index ca8dd4dea..a68c8f750 100644 --- a/internal/processing/account/move.go +++ b/internal/processing/account/move.go @@ -154,6 +154,17 @@ func (p *Processor) MoveSelf( } } + // If originAcct has already moved, ensure + // this move reattempt is to the same account. + if originAcct.IsMoving() && + originAcct.MovedToURI != targetAcct.URI { + err := fmt.Errorf( + "your account is already Moving or has Moved to %s; you cannot also Move to %s", + originAcct.MovedToURI, targetAcct.URI, + ) + return gtserror.NewErrorUnprocessableEntity(err, err.Error()) + } + // Target account MUST be aliased to this // account for this to be a valid Move. if !slices.Contains(targetAcct.AlsoKnownAsURIs, originAcct.URI) { diff --git a/web/source/settings/user/migration.tsx b/web/source/settings/user/migration.tsx index d0c5e3393..9dfa3a75b 100644 --- a/web/source/settings/user/migration.tsx +++ b/web/source/settings/user/migration.tsx @@ -40,49 +40,23 @@ export default function UserMigration() { } function UserMigrationForm({ data: profile }) { - let urlStr = store.getState().oauth.instanceUrl ?? ""; - let url = new URL(urlStr); - return ( <>

Account Migration Settings

-
- - Moving your account to another instance, or moving an account from another instance to your account, isn't implemented yet! You will only be able to use the "alias" section of the below panel. See here for progress. -

- The following settings allow you to alias your account to another account - elsewhere, and to move your followers and following lists to another account. + The following settings allow you to alias your account to + another account elsewhere, or to move to another account.

Account aliasing is harmless and reversible; you can set and unset up to five account aliases as many times as you wish.

- The account move action, on the other hand, has serious and irreversible consequences. + The account move action, on the other + hand, has serious and irreversible consequences.

- To move, you must set an alias from your account to the target account, using this settings panel. -

-

- You must also set an alias from the target account back to your account, using - the settings panel of the instance on which the target account resides. -

-

- Provide the following details to the other instance: -

-
-
-
Account handle/username:
-
@{profile.acct}@{url.host}
-
-
-
Account URI:
-
{urlStr}/users/{profile.username}
-
-
-

- For more information on account migration, please see the documentation. + For more information on account migration, please see the documentation.

@@ -166,44 +140,70 @@ function AlsoKnownAsURI({ index, data }) { } function MoveForm({ data: profile }) { + let urlStr = store.getState().oauth.instanceUrl ?? ""; + let url = new URL(urlStr); + const form = { movedToURI: useTextInput("moved_to_uri", { source: profile, - valueSelector: (p) => p.moved?.uri }, + valueSelector: (p) => p.moved?.url }, ), password: useTextInput("password"), }; - const [submitForm, result] = useFormSubmit(form, useMoveAccountMutation()); + const [submitForm, result] = useFormSubmit(form, useMoveAccountMutation(), { + changedOnly: false, + }); return (

Move Account

- - Learn more about moving your account (opens in a new tab) - +

+

+ For a move to be successful, you must have already set an alias from the + target account back to the account you're moving from (ie., this account), + using the settings panel of the instance on which the target account resides. +

+

+ To do this, provide the following details to the other instance: +

+
+
+
Account handle/username:
+
@{profile.acct}@{url.host}
+
+
+
Account URI:
+
{urlStr}/users/{profile.username}
+
+
+
+ + Learn more about moving your account (opens in a new tab) + +