commit 3a5c78147cf20f46ccabb9104bf650d7561ebde9
parent a0d1d13441cc0f766bcd49477bc9f0015639f246
Author: default <nobody@localhost>
Date: Thu, 19 Sep 2024 20:13:18 +0200
Move migration work.
Diffstat:
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git 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;
}