mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
Started account migration code.
This commit is contained in:
parent
00716d1871
commit
97cc35f577
3 changed files with 33 additions and 0 deletions
|
@ -1522,6 +1522,17 @@ xs_dict *msg_pong(snac *user, const char *rcpt, const char *object)
|
|||
}
|
||||
|
||||
|
||||
xs_dict *msg_move(snac *user, const char *new_account)
|
||||
/* creates a Move message (to move the user to new_account) */
|
||||
{
|
||||
xs_dict *msg = msg_base(user, "Move", "@dummy", user->actor, NULL, user->actor);
|
||||
|
||||
msg = xs_dict_append(msg, "target", new_account);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
|
||||
const xs_list *opts, int multiple, int end_secs)
|
||||
/* creates a Question message */
|
||||
|
@ -2653,6 +2664,22 @@ int process_queue(void)
|
|||
}
|
||||
|
||||
|
||||
/** account migration **/
|
||||
|
||||
int migrate_account(snac *user)
|
||||
/* migrates this account to a new one (stored in the 'aka' user field) */
|
||||
{
|
||||
const char *new_account = xs_dict_get(user->config, "aka");
|
||||
|
||||
if (xs_type(new_account) != XSTYPE_STRING) {
|
||||
snac_log(user, xs_fmt("Cannot migrate: 'aka' (new account) not defined"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** HTTP handlers */
|
||||
|
||||
int activitypub_get_handler(const xs_dict *req, const char *q_path,
|
||||
|
|
4
main.c
4
main.c
|
@ -273,6 +273,10 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(cmd, "migrate") == 0) { /** **/
|
||||
return migrate_account(&snac);
|
||||
}
|
||||
|
||||
if ((url = GET_ARGV()) == NULL)
|
||||
return usage();
|
||||
|
||||
|
|
2
snac.h
2
snac.h
|
@ -310,6 +310,7 @@ xs_dict *msg_actor(snac *snac);
|
|||
xs_dict *msg_update(snac *snac, const xs_dict *object);
|
||||
xs_dict *msg_ping(snac *user, const char *rcpt);
|
||||
xs_dict *msg_pong(snac *user, const char *rcpt, const char *object);
|
||||
xs_dict *msg_move(snac *user, const char *new_account);
|
||||
xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
|
||||
const xs_list *opts, int multiple, int end_secs);
|
||||
|
||||
|
@ -389,6 +390,7 @@ void mastoapi_purge(void);
|
|||
void verify_links(snac *user);
|
||||
|
||||
void export_csv(snac *user);
|
||||
int migrate_account(snac *user);
|
||||
void import_csv(snac *user);
|
||||
|
||||
typedef enum {
|
||||
|
|
Loading…
Reference in a new issue