diff options
| author | 2024-09-18 18:34:17 +0200 | |
|---|---|---|
| committer | 2024-09-18 18:34:17 +0200 | |
| commit | 97cc35f577dbe390c5c6c841e41f6a82b32aff9d (patch) | |
| tree | 82c34bfcb1fa4a1adc1e3d4eab92d53d24ffc1f3 | |
| parent | Added 'export_csv' to the usage message. (diff) | |
| download | snac2-97cc35f577dbe390c5c6c841e41f6a82b32aff9d.tar.gz snac2-97cc35f577dbe390c5c6c841e41f6a82b32aff9d.tar.xz snac2-97cc35f577dbe390c5c6c841e41f6a82b32aff9d.zip | |
Started account migration code.
| -rw-r--r-- | activitypub.c | 27 | ||||
| -rw-r--r-- | main.c | 4 | ||||
| -rw-r--r-- | snac.h | 2 |
3 files changed, 33 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index c41dfbd..b15b883 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -1522,6 +1522,17 @@ xs_dict *msg_pong(snac *user, const char *rcpt, const char *object) | |||
| 1522 | } | 1522 | } |
| 1523 | 1523 | ||
| 1524 | 1524 | ||
| 1525 | xs_dict *msg_move(snac *user, const char *new_account) | ||
| 1526 | /* creates a Move message (to move the user to new_account) */ | ||
| 1527 | { | ||
| 1528 | xs_dict *msg = msg_base(user, "Move", "@dummy", user->actor, NULL, user->actor); | ||
| 1529 | |||
| 1530 | msg = xs_dict_append(msg, "target", new_account); | ||
| 1531 | |||
| 1532 | return msg; | ||
| 1533 | } | ||
| 1534 | |||
| 1535 | |||
| 1525 | xs_dict *msg_question(snac *user, const char *content, xs_list *attach, | 1536 | xs_dict *msg_question(snac *user, const char *content, xs_list *attach, |
| 1526 | const xs_list *opts, int multiple, int end_secs) | 1537 | const xs_list *opts, int multiple, int end_secs) |
| 1527 | /* creates a Question message */ | 1538 | /* creates a Question message */ |
| @@ -2653,6 +2664,22 @@ int process_queue(void) | |||
| 2653 | } | 2664 | } |
| 2654 | 2665 | ||
| 2655 | 2666 | ||
| 2667 | /** account migration **/ | ||
| 2668 | |||
| 2669 | int migrate_account(snac *user) | ||
| 2670 | /* migrates this account to a new one (stored in the 'aka' user field) */ | ||
| 2671 | { | ||
| 2672 | const char *new_account = xs_dict_get(user->config, "aka"); | ||
| 2673 | |||
| 2674 | if (xs_type(new_account) != XSTYPE_STRING) { | ||
| 2675 | snac_log(user, xs_fmt("Cannot migrate: 'aka' (new account) not defined")); | ||
| 2676 | return 1; | ||
| 2677 | } | ||
| 2678 | |||
| 2679 | return 0; | ||
| 2680 | } | ||
| 2681 | |||
| 2682 | |||
| 2656 | /** HTTP handlers */ | 2683 | /** HTTP handlers */ |
| 2657 | 2684 | ||
| 2658 | int activitypub_get_handler(const xs_dict *req, const char *q_path, | 2685 | int activitypub_get_handler(const xs_dict *req, const char *q_path, |
| @@ -273,6 +273,10 @@ int main(int argc, char *argv[]) | |||
| 273 | return 0; | 273 | return 0; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | if (strcmp(cmd, "migrate") == 0) { /** **/ | ||
| 277 | return migrate_account(&snac); | ||
| 278 | } | ||
| 279 | |||
| 276 | if ((url = GET_ARGV()) == NULL) | 280 | if ((url = GET_ARGV()) == NULL) |
| 277 | return usage(); | 281 | return usage(); |
| 278 | 282 | ||
| @@ -310,6 +310,7 @@ xs_dict *msg_actor(snac *snac); | |||
| 310 | xs_dict *msg_update(snac *snac, const xs_dict *object); | 310 | xs_dict *msg_update(snac *snac, const xs_dict *object); |
| 311 | xs_dict *msg_ping(snac *user, const char *rcpt); | 311 | xs_dict *msg_ping(snac *user, const char *rcpt); |
| 312 | xs_dict *msg_pong(snac *user, const char *rcpt, const char *object); | 312 | xs_dict *msg_pong(snac *user, const char *rcpt, const char *object); |
| 313 | xs_dict *msg_move(snac *user, const char *new_account); | ||
| 313 | xs_dict *msg_question(snac *user, const char *content, xs_list *attach, | 314 | xs_dict *msg_question(snac *user, const char *content, xs_list *attach, |
| 314 | const xs_list *opts, int multiple, int end_secs); | 315 | const xs_list *opts, int multiple, int end_secs); |
| 315 | 316 | ||
| @@ -389,6 +390,7 @@ void mastoapi_purge(void); | |||
| 389 | void verify_links(snac *user); | 390 | void verify_links(snac *user); |
| 390 | 391 | ||
| 391 | void export_csv(snac *user); | 392 | void export_csv(snac *user); |
| 393 | int migrate_account(snac *user); | ||
| 392 | void import_csv(snac *user); | 394 | void import_csv(snac *user); |
| 393 | 395 | ||
| 394 | typedef enum { | 396 | typedef enum { |