diff options
| author | 2025-04-18 09:08:48 +0200 | |
|---|---|---|
| committer | 2025-04-18 09:08:48 +0200 | |
| commit | 1ebf2a2d874f3ee589785e8175abdcb33a963d72 (patch) | |
| tree | 80fa888a7057d406eec6c10eeb36ff5c36c2e608 /main.c | |
| parent | New command-line options 'create_list' and 'delete_list'. (diff) | |
| download | penes-snac2-1ebf2a2d874f3ee589785e8175abdcb33a963d72.tar.gz penes-snac2-1ebf2a2d874f3ee589785e8175abdcb33a963d72.tar.xz penes-snac2-1ebf2a2d874f3ee589785e8175abdcb33a963d72.zip | |
New command-line option 'add_to_list'.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 30 |
1 files changed, 30 insertions, 0 deletions
| @@ -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; |