diff options
| author | 2024-05-25 08:05:36 +0000 | |
|---|---|---|
| committer | 2024-05-25 08:05:36 +0000 | |
| commit | 84a767dd0878013194ed7551b5ae6ef715e841a6 (patch) | |
| tree | 9fb1b2b89e0bfbb4b8bf1e85d840c8653e646bb7 /main.c | |
| parent | Prevent some browsers from caching servers basic auth request (diff) | |
| parent | Backport from xs (fix regex.h compilation with tcc). (diff) | |
| download | snac2-84a767dd0878013194ed7551b5ae6ef715e841a6.tar.gz snac2-84a767dd0878013194ed7551b5ae6ef715e841a6.tar.xz snac2-84a767dd0878013194ed7551b5ae6ef715e841a6.zip | |
Merge pull request 'master' (#1) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/louis77/snac2/pulls/1
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 26 |
1 files changed, 25 insertions, 1 deletions
| @@ -44,6 +44,7 @@ int usage(void) | |||
| 44 | printf("limit {basedir} {uid} {actor} Limits an actor (drops their announces)\n"); | 44 | printf("limit {basedir} {uid} {actor} Limits an actor (drops their announces)\n"); |
| 45 | printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); | 45 | printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); |
| 46 | printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n"); | 46 | printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n"); |
| 47 | printf("search {basedir} {uid} {regex} Searches posts by content\n"); | ||
| 47 | 48 | ||
| 48 | return 1; | 49 | return 1; |
| 49 | } | 50 | } |
| @@ -314,7 +315,7 @@ int main(int argc, char *argv[]) | |||
| 314 | xs *msg = msg_follow(&snac, url); | 315 | xs *msg = msg_follow(&snac, url); |
| 315 | 316 | ||
| 316 | if (msg != NULL) { | 317 | if (msg != NULL) { |
| 317 | char *actor = xs_dict_get(msg, "object"); | 318 | const char *actor = xs_dict_get(msg, "object"); |
| 318 | 319 | ||
| 319 | following_add(&snac, actor, msg); | 320 | following_add(&snac, actor, msg); |
| 320 | 321 | ||
| @@ -374,6 +375,23 @@ int main(int argc, char *argv[]) | |||
| 374 | return 0; | 375 | return 0; |
| 375 | } | 376 | } |
| 376 | 377 | ||
| 378 | if (strcmp(cmd, "search") == 0) { /** **/ | ||
| 379 | int to; | ||
| 380 | |||
| 381 | /* 'url' contains the regex */ | ||
| 382 | xs *r = content_search(&snac, url, 1, 0, XS_ALL, 10, &to); | ||
| 383 | |||
| 384 | int c = 0; | ||
| 385 | const char *v; | ||
| 386 | |||
| 387 | /* print results as standalone links */ | ||
| 388 | while (xs_list_next(r, &v, &c)) { | ||
| 389 | printf("%s/admin/p/%s\n", snac.actor, v); | ||
| 390 | } | ||
| 391 | |||
| 392 | return 0; | ||
| 393 | } | ||
| 394 | |||
| 377 | if (strcmp(cmd, "ping") == 0) { /** **/ | 395 | if (strcmp(cmd, "ping") == 0) { /** **/ |
| 378 | xs *actor_o = NULL; | 396 | xs *actor_o = NULL; |
| 379 | 397 | ||
| @@ -458,6 +476,12 @@ int main(int argc, char *argv[]) | |||
| 458 | return 0; | 476 | return 0; |
| 459 | } | 477 | } |
| 460 | 478 | ||
| 479 | if (strcmp(cmd, "request2") == 0) { /** **/ | ||
| 480 | enqueue_object_request(&snac, url, 2); | ||
| 481 | |||
| 482 | return 0; | ||
| 483 | } | ||
| 484 | |||
| 461 | if (strcmp(cmd, "actor") == 0) { /** **/ | 485 | if (strcmp(cmd, "actor") == 0) { /** **/ |
| 462 | int status; | 486 | int status; |
| 463 | xs *data = NULL; | 487 | xs *data = NULL; |