diff options
| -rw-r--r-- | data.c | 13 | ||||
| -rw-r--r-- | html.c | 10 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | mastoapi.c | 2 | ||||
| -rw-r--r-- | snac.h | 3 |
5 files changed, 19 insertions, 11 deletions
| @@ -2491,7 +2491,8 @@ void notify_clear(snac *snac) | |||
| 2491 | 2491 | ||
| 2492 | /** searches **/ | 2492 | /** searches **/ |
| 2493 | 2493 | ||
| 2494 | xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, int max_res, int *timeout) | 2494 | xs_list *content_search(snac *user, const char *regex, |
| 2495 | int priv, int skip, int show, int max_secs, int *timeout) | ||
| 2495 | /* returns a list of posts which content matches the regex */ | 2496 | /* returns a list of posts which content matches the regex */ |
| 2496 | { | 2497 | { |
| 2497 | if (regex == NULL || *regex == '\0') | 2498 | if (regex == NULL || *regex == '\0') |
| @@ -2520,7 +2521,7 @@ xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, i | |||
| 2520 | xs_list_next(pub_tl, &pub_md5, &pub_c); | 2521 | xs_list_next(pub_tl, &pub_md5, &pub_c); |
| 2521 | xs_list_next(priv_tl, &priv_md5, &priv_c); | 2522 | xs_list_next(priv_tl, &priv_md5, &priv_c); |
| 2522 | 2523 | ||
| 2523 | while (max_res > 0) { | 2524 | while (show > 0) { |
| 2524 | char *md5 = NULL; | 2525 | char *md5 = NULL; |
| 2525 | enum { NONE, PUBLIC, PRIVATE } from = NONE; | 2526 | enum { NONE, PUBLIC, PRIVATE } from = NONE; |
| 2526 | 2527 | ||
| @@ -2591,8 +2592,12 @@ xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, i | |||
| 2591 | xs *l = xs_regex_select_n(c, regex, 1); | 2592 | xs *l = xs_regex_select_n(c, regex, 1); |
| 2592 | 2593 | ||
| 2593 | if (xs_list_len(l)) { | 2594 | if (xs_list_len(l)) { |
| 2594 | xs_set_add(&seen, md5); | 2595 | if (skip) |
| 2595 | max_res--; | 2596 | skip--; |
| 2597 | else { | ||
| 2598 | xs_set_add(&seen, md5); | ||
| 2599 | show--; | ||
| 2600 | } | ||
| 2596 | } | 2601 | } |
| 2597 | } | 2602 | } |
| 2598 | 2603 | ||
| @@ -2563,9 +2563,9 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2563 | char *q = xs_dict_get(q_vars, "q"); | 2563 | char *q = xs_dict_get(q_vars, "q"); |
| 2564 | 2564 | ||
| 2565 | if (q && *q) { | 2565 | if (q && *q) { |
| 2566 | /* search by content */ | 2566 | /** search by content **/ |
| 2567 | int to = 0; | 2567 | int to = 0; |
| 2568 | xs *tl = content_search(&snac, q, 1, skip ? 10 : 0, skip + show, &to); | 2568 | xs *tl = content_search(&snac, q, 1, skip, show, skip ? 10 : 0, &to); |
| 2569 | xs *title = NULL; | 2569 | xs *title = NULL; |
| 2570 | xs *page = xs_fmt("/admin?q=%s", q); | 2570 | xs *page = xs_fmt("/admin?q=%s", q); |
| 2571 | int tl_len = xs_list_len(tl); | 2571 | int tl_len = xs_list_len(tl); |
| @@ -2573,10 +2573,12 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2573 | if (tl_len) | 2573 | if (tl_len) |
| 2574 | title = xs_fmt(L("Search results for '%s'"), q); | 2574 | title = xs_fmt(L("Search results for '%s'"), q); |
| 2575 | else | 2575 | else |
| 2576 | if (skip) | ||
| 2577 | title = xs_fmt(L("No more matches for '%s'"), q); | ||
| 2578 | else | ||
| 2576 | title = xs_fmt(L("Nothing found for '%s'"), q); | 2579 | title = xs_fmt(L("Nothing found for '%s'"), q); |
| 2577 | 2580 | ||
| 2578 | *body = html_timeline(&snac, tl, 0, 0, tl_len, | 2581 | *body = html_timeline(&snac, tl, 0, skip, show, tl_len > 0, title, page, 1); |
| 2579 | (to || tl_len == skip + show), title, page, 1); | ||
| 2580 | *b_size = strlen(*body); | 2582 | *b_size = strlen(*body); |
| 2581 | status = 200; | 2583 | status = 200; |
| 2582 | } | 2584 | } |
| @@ -379,7 +379,7 @@ int main(int argc, char *argv[]) | |||
| 379 | int to; | 379 | int to; |
| 380 | 380 | ||
| 381 | /* 'url' contains the regex */ | 381 | /* 'url' contains the regex */ |
| 382 | xs *r = content_search(&snac, url, 1, 10, XS_ALL, &to); | 382 | xs *r = content_search(&snac, url, 1, 0, XS_ALL, 10, &to); |
| 383 | 383 | ||
| 384 | int c = 0; | 384 | int c = 0; |
| 385 | char *v; | 385 | char *v; |
| @@ -2261,7 +2261,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2261 | if (xs_is_null(type) || strcmp(type, "statuses") == 0) { | 2261 | if (xs_is_null(type) || strcmp(type, "statuses") == 0) { |
| 2262 | int to = 0; | 2262 | int to = 0; |
| 2263 | int cnt = 40; | 2263 | int cnt = 40; |
| 2264 | xs *tl = content_search(&snac1, q, 1, 0, cnt, &to); | 2264 | xs *tl = content_search(&snac1, q, 1, 0, cnt, 0, &to); |
| 2265 | int c = 0; | 2265 | int c = 0; |
| 2266 | char *v; | 2266 | char *v; |
| 2267 | 2267 | ||
| @@ -179,7 +179,8 @@ xs_list *list_timeline(snac *user, const char *list, int skip, int show); | |||
| 179 | xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); | 179 | xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); |
| 180 | void list_distribute(snac *user, const char *who, const xs_dict *post); | 180 | void list_distribute(snac *user, const char *who, const xs_dict *post); |
| 181 | 181 | ||
| 182 | xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, int max_res, int *timeout); | 182 | xs_list *content_search(snac *user, const char *regex, |
| 183 | int priv, int skip, int show, int max_secs, int *timeout); | ||
| 183 | 184 | ||
| 184 | int actor_add(const char *actor, xs_dict *msg); | 185 | int actor_add(const char *actor, xs_dict *msg); |
| 185 | int actor_get(const char *actor, xs_dict **data); | 186 | int actor_get(const char *actor, xs_dict **data); |