aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-09-19 20:13:18 +0200
committerdefault <nobody@localhost>2024-09-19 20:13:18 +0200
commit3a5c78147cf20f46ccabb9104bf650d7561ebde9 (patch)
tree60a4acce35f58d12ead90621e639c271905d4c6f
parenta0d1d13441cc0f766bcd49477bc9f0015639f246 (diff)
Move migration work.
-rw-r--r--activitypub.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/activitypub.c b/activitypub.c
index 7a8d4fa..9a49ba9 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -2667,7 +2667,7 @@ int process_queue(void)
/** account migration **/
int migrate_account(snac *user)
-/* migrates this account to a new one (stored in the 'aka' user field) */
+/* migrates this account to a new one (stored in the 'alias' user field) */
{
const char *new_account = xs_dict_get(user->config, "alias");
@@ -2676,6 +2676,26 @@ int migrate_account(snac *user)
return 1;
}
+ xs *new_actor = NULL;
+ int status;
+
+ if (!valid_status(status = actor_request(user, new_account, &new_actor))) {
+ snac_log(user, xs_fmt("Cannot migrate: error requesting actor %s %d", new_account, status));
+ return 1;
+ }
+
+ const char *loaka = xs_dict_get(new_actor, "alsoKnownAs");
+
+ if (xs_type(loaka) != XSTYPE_LIST) {
+ snac_log(user, xs_fmt("Cannot migrate: destination account doesn't have any aliases"));
+ return 1;
+ }
+
+ if (xs_list_in(loaka, user->actor) == -1) {
+ snac_log(user, xs_fmt("Cannot migrate: destination account doesn't have this one as an alias"));
+ return 1;
+ }
+
return 0;
}