Browse Source

Move migration work.

default 6 months ago
parent
commit
3a5c78147c
1 changed files with 21 additions and 1 deletions
  1. 21 1
      activitypub.c

+ 21 - 1
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;
 }