diff options
| author | 2024-05-08 10:20:25 +0200 | |
|---|---|---|
| committer | 2024-05-08 10:20:25 +0200 | |
| commit | 3ab733cdf5a71b9a27399e8336e0c236c13d67fb (patch) | |
| tree | 81e9885f2bffabcaf849f170888eaa0be40a4234 /main.c | |
| parent | Merge branch 'master' of grunfink-codeberg:grunfink/snac2 (diff) | |
| download | penes-snac2-3ab733cdf5a71b9a27399e8336e0c236c13d67fb.tar.gz penes-snac2-3ab733cdf5a71b9a27399e8336e0c236c13d67fb.tar.xz penes-snac2-3ab733cdf5a71b9a27399e8336e0c236c13d67fb.zip | |
New function search_by_content().
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 18 |
1 files changed, 18 insertions, 0 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 | } |
| @@ -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 | xs *tl = timeline_simple_list(&snac, "private", 0, XS_ALL); | ||
| 380 | |||
| 381 | /* 'url' contains the regex */ | ||
| 382 | xs *r = search_by_content(&snac, tl, url, 10); | ||
| 383 | |||
| 384 | int c = 0; | ||
| 385 | 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 | ||