commit 3a5c781
default
·
2024-09-19 18:13:18 +0000 UTC
parent a0d1d13
Move migration work.
1 files changed,
+21,
-1
+21,
-1
1@@ -2667,7 +2667,7 @@ int process_queue(void)
2 /** account migration **/
3
4 int migrate_account(snac *user)
5-/* migrates this account to a new one (stored in the 'aka' user field) */
6+/* migrates this account to a new one (stored in the 'alias' user field) */
7 {
8 const char *new_account = xs_dict_get(user->config, "alias");
9
10@@ -2676,6 +2676,26 @@ int migrate_account(snac *user)
11 return 1;
12 }
13
14+ xs *new_actor = NULL;
15+ int status;
16+
17+ if (!valid_status(status = actor_request(user, new_account, &new_actor))) {
18+ snac_log(user, xs_fmt("Cannot migrate: error requesting actor %s %d", new_account, status));
19+ return 1;
20+ }
21+
22+ const char *loaka = xs_dict_get(new_actor, "alsoKnownAs");
23+
24+ if (xs_type(loaka) != XSTYPE_LIST) {
25+ snac_log(user, xs_fmt("Cannot migrate: destination account doesn't have any aliases"));
26+ return 1;
27+ }
28+
29+ if (xs_list_in(loaka, user->actor) == -1) {
30+ snac_log(user, xs_fmt("Cannot migrate: destination account doesn't have this one as an alias"));
31+ return 1;
32+ }
33+
34 return 0;
35 }
36