diff options
| author | 2025-04-18 09:08:48 +0200 | |
|---|---|---|
| committer | 2025-04-18 09:08:48 +0200 | |
| commit | 1ebf2a2d874f3ee589785e8175abdcb33a963d72 (patch) | |
| tree | 80fa888a7057d406eec6c10eeb36ff5c36c2e608 | |
| parent | New command-line options 'create_list' and 'delete_list'. (diff) | |
| download | snac2-1ebf2a2d874f3ee589785e8175abdcb33a963d72.tar.gz snac2-1ebf2a2d874f3ee589785e8175abdcb33a963d72.tar.xz snac2-1ebf2a2d874f3ee589785e8175abdcb33a963d72.zip | |
New command-line option 'add_to_list'.
| -rw-r--r-- | data.c | 4 | ||||
| -rw-r--r-- | main.c | 30 |
2 files changed, 32 insertions, 2 deletions
| @@ -2404,7 +2404,7 @@ xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op | |||
| 2404 | break; | 2404 | break; |
| 2405 | 2405 | ||
| 2406 | case 1: /** append actor to list **/ | 2406 | case 1: /** append actor to list **/ |
| 2407 | if (actor_md5 != NULL) { | 2407 | if (xs_is_string(actor_md5) && xs_is_hex(actor_md5)) { |
| 2408 | if (!index_in_md5(fn, actor_md5)) | 2408 | if (!index_in_md5(fn, actor_md5)) |
| 2409 | index_add_md5(fn, actor_md5); | 2409 | index_add_md5(fn, actor_md5); |
| 2410 | } | 2410 | } |
| @@ -2412,7 +2412,7 @@ xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op | |||
| 2412 | break; | 2412 | break; |
| 2413 | 2413 | ||
| 2414 | case 2: /** delete actor from list **/ | 2414 | case 2: /** delete actor from list **/ |
| 2415 | if (actor_md5 != NULL) | 2415 | if (xs_is_string(actor_md5) && xs_is_hex(actor_md5)) |
| 2416 | index_del_md5(fn, actor_md5); | 2416 | index_del_md5(fn, actor_md5); |
| 2417 | 2417 | ||
| 2418 | break; | 2418 | break; |
| @@ -61,6 +61,9 @@ int usage(void) | |||
| 61 | printf("import_block_list {basedir} {uid} {file} Imports a Mastodon CSV block list file\n"); | 61 | printf("import_block_list {basedir} {uid} {file} Imports a Mastodon CSV block list file\n"); |
| 62 | printf("lists {basedir} {uid} Returns the names of the lists created by the user\n"); | 62 | printf("lists {basedir} {uid} Returns the names of the lists created by the user\n"); |
| 63 | printf("list_members {basedir} {uid} {name} Returns the list of accounts inside a list\n"); | 63 | printf("list_members {basedir} {uid} {name} Returns the list of accounts inside a list\n"); |
| 64 | printf("create_list {basedir} {uid} {name} Creates a new list\n"); | ||
| 65 | printf("delete_list {basedir} {uid} {name} Deletes an existing list\n"); | ||
| 66 | printf("add_to_list {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n"); | ||
| 64 | 67 | ||
| 65 | return 1; | 68 | return 1; |
| 66 | } | 69 | } |
| @@ -345,6 +348,33 @@ int main(int argc, char *argv[]) | |||
| 345 | return 0; | 348 | return 0; |
| 346 | } | 349 | } |
| 347 | 350 | ||
| 351 | if (strcmp(cmd, "add_to_list") == 0) { /** **/ | ||
| 352 | const char *account = GET_ARGV(); | ||
| 353 | |||
| 354 | if (account != NULL) { | ||
| 355 | xs *lid = list_maint(&snac, url, 4); | ||
| 356 | |||
| 357 | if (lid != NULL) { | ||
| 358 | xs *actor = NULL; | ||
| 359 | xs *uid = NULL; | ||
| 360 | |||
| 361 | if (valid_status(webfinger_request(account, &actor, &uid))) { | ||
| 362 | xs *md5 = xs_md5_hex(actor, strlen(actor)); | ||
| 363 | |||
| 364 | list_content(&snac, lid, md5, 1); | ||
| 365 | printf("Actor %s (%s) added to list %s (%s)\n", actor, uid, url, lid); | ||
| 366 | } | ||
| 367 | else | ||
| 368 | fprintf(stderr, "Cannot resolve account '%s'\n", account); | ||
| 369 | } | ||
| 370 | else | ||
| 371 | fprintf(stderr, "Cannot find a list named '%s'\n", url); | ||
| 372 | |||
| 373 | } | ||
| 374 | |||
| 375 | return 0; | ||
| 376 | } | ||
| 377 | |||
| 348 | if (strcmp(cmd, "alias") == 0) { /** **/ | 378 | if (strcmp(cmd, "alias") == 0) { /** **/ |
| 349 | xs *actor = NULL; | 379 | xs *actor = NULL; |
| 350 | xs *uid = NULL; | 380 | xs *uid = NULL; |