mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Move migration work.
This commit is contained in:
parent
a0d1d13441
commit
3a5c78147c
1 changed files with 21 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue