diff options
| -rw-r--r-- | activitypub.c | 2 | ||||
| -rw-r--r-- | data.c | 24 | ||||
| -rw-r--r-- | html.c | 25 | ||||
| -rw-r--r-- | mastoapi.c | 2 | ||||
| -rw-r--r-- | snac.h | 4 |
5 files changed, 33 insertions, 24 deletions
diff --git a/activitypub.c b/activitypub.c index cade0d9..bcb733a 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -3081,7 +3081,7 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path, | |||
| 3081 | int cnt = xs_number_get(xs_dict_get_def(srv_config, "max_public_entries", "20")); | 3081 | int cnt = xs_number_get(xs_dict_get_def(srv_config, "max_public_entries", "20")); |
| 3082 | 3082 | ||
| 3083 | /* get the public outbox or the pinned list */ | 3083 | /* get the public outbox or the pinned list */ |
| 3084 | xs *elems = *p_path == 'o' ? timeline_simple_list(&snac, "public", 0, cnt) : pinned_list(&snac); | 3084 | xs *elems = *p_path == 'o' ? timeline_simple_list(&snac, "public", 0, cnt, NULL) : pinned_list(&snac); |
| 3085 | 3085 | ||
| 3086 | xs_list_foreach(elems, v) { | 3086 | xs_list_foreach(elems, v) { |
| 3087 | xs *i = NULL; | 3087 | xs *i = NULL; |
| @@ -1489,16 +1489,28 @@ xs_str *user_index_fn(snac *user, const char *idx_name) | |||
| 1489 | } | 1489 | } |
| 1490 | 1490 | ||
| 1491 | 1491 | ||
| 1492 | xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show) | 1492 | xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show, int *more) |
| 1493 | /* returns a timeline (with all entries) */ | 1493 | /* returns a timeline (with all entries) */ |
| 1494 | { | 1494 | { |
| 1495 | xs *idx = user_index_fn(user, idx_name); | 1495 | xs *idx = user_index_fn(user, idx_name); |
| 1496 | 1496 | ||
| 1497 | return index_list_desc(idx, skip, show); | 1497 | /* if a more flag is sent, request one more */ |
| 1498 | xs_list *lst = index_list_desc(idx, skip, show + (more != NULL ? 1 : 0)); | ||
| 1499 | |||
| 1500 | if (more != NULL) { | ||
| 1501 | if (xs_list_len(lst) > show) { | ||
| 1502 | *more = 1; | ||
| 1503 | lst = xs_list_del(lst, -1); | ||
| 1504 | } | ||
| 1505 | else | ||
| 1506 | *more = 0; | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | return lst; | ||
| 1498 | } | 1510 | } |
| 1499 | 1511 | ||
| 1500 | 1512 | ||
| 1501 | xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show) | 1513 | xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show, int *more) |
| 1502 | /* returns a timeline (only top level entries) */ | 1514 | /* returns a timeline (only top level entries) */ |
| 1503 | { | 1515 | { |
| 1504 | int c_max; | 1516 | int c_max; |
| @@ -1510,7 +1522,7 @@ xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show) | |||
| 1510 | if (show > c_max) | 1522 | if (show > c_max) |
| 1511 | show = c_max; | 1523 | show = c_max; |
| 1512 | 1524 | ||
| 1513 | xs *list = timeline_simple_list(snac, idx_name, skip, show); | 1525 | xs *list = timeline_simple_list(snac, idx_name, skip, show, more); |
| 1514 | 1526 | ||
| 1515 | return timeline_top_level(snac, list); | 1527 | return timeline_top_level(snac, list); |
| 1516 | } | 1528 | } |
| @@ -2709,9 +2721,9 @@ xs_list *content_search(snac *user, const char *regex, | |||
| 2709 | const char *md5s[3] = {0}; | 2721 | const char *md5s[3] = {0}; |
| 2710 | int c[3] = {0}; | 2722 | int c[3] = {0}; |
| 2711 | 2723 | ||
| 2712 | tls[0] = timeline_simple_list(user, "public", 0, XS_ALL); /* public */ | 2724 | tls[0] = timeline_simple_list(user, "public", 0, XS_ALL, NULL); /* public */ |
| 2713 | tls[1] = timeline_instance_list(0, XS_ALL); /* instance */ | 2725 | tls[1] = timeline_instance_list(0, XS_ALL); /* instance */ |
| 2714 | tls[2] = priv ? timeline_simple_list(user, "private", 0, XS_ALL) : xs_list_new(); /* private or none */ | 2726 | tls[2] = priv ? timeline_simple_list(user, "private", 0, XS_ALL, NULL) : xs_list_new(); /* private or none */ |
| 2715 | 2727 | ||
| 2716 | /* first positioning */ | 2728 | /* first positioning */ |
| 2717 | for (int n = 0; n < 3; n++) | 2729 | for (int n = 0; n < 3; n++) |
| @@ -3314,21 +3314,17 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3314 | } | 3314 | } |
| 3315 | else { | 3315 | else { |
| 3316 | xs *list = NULL; | 3316 | xs *list = NULL; |
| 3317 | xs *next = NULL; | 3317 | int more = 0; |
| 3318 | 3318 | ||
| 3319 | if (xs_is_true(xs_dict_get(srv_config, "strict_public_timelines"))) { | 3319 | if (xs_is_true(xs_dict_get(srv_config, "strict_public_timelines"))) |
| 3320 | list = timeline_simple_list(&snac, "public", skip, show); | 3320 | list = timeline_simple_list(&snac, "public", skip, show, &more); |
| 3321 | next = timeline_simple_list(&snac, "public", skip + show, 1); | 3321 | else |
| 3322 | } | 3322 | list = timeline_list(&snac, "public", skip, show, &more); |
| 3323 | else { | ||
| 3324 | list = timeline_list(&snac, "public", skip, show); | ||
| 3325 | next = timeline_list(&snac, "public", skip + show, 1); | ||
| 3326 | } | ||
| 3327 | 3323 | ||
| 3328 | xs *pins = pinned_list(&snac); | 3324 | xs *pins = pinned_list(&snac); |
| 3329 | pins = xs_list_cat(pins, list); | 3325 | pins = xs_list_cat(pins, list); |
| 3330 | 3326 | ||
| 3331 | *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "", 1, error); | 3327 | *body = html_timeline(&snac, pins, 1, skip, show, more, NULL, "", 1, error); |
| 3332 | 3328 | ||
| 3333 | *b_size = strlen(*body); | 3329 | *b_size = strlen(*body); |
| 3334 | status = HTTP_STATUS_OK; | 3330 | status = HTTP_STATUS_OK; |
| @@ -3490,13 +3486,14 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3490 | xs_dict_get(req, "if-none-match"), etag); | 3486 | xs_dict_get(req, "if-none-match"), etag); |
| 3491 | } | 3487 | } |
| 3492 | else { | 3488 | else { |
| 3489 | int more = 0; | ||
| 3490 | |||
| 3493 | snac_debug(&snac, 1, xs_fmt("building timeline")); | 3491 | snac_debug(&snac, 1, xs_fmt("building timeline")); |
| 3494 | 3492 | ||
| 3495 | xs *list = timeline_list(&snac, "private", skip, show); | 3493 | xs *list = timeline_list(&snac, "private", skip, show, &more); |
| 3496 | xs *next = timeline_list(&snac, "private", skip + show, 1); | ||
| 3497 | 3494 | ||
| 3498 | *body = html_timeline(&snac, list, 0, skip, show, | 3495 | *body = html_timeline(&snac, list, 0, skip, show, |
| 3499 | xs_list_len(next), NULL, "/admin", 1, error); | 3496 | more, NULL, "/admin", 1, error); |
| 3500 | 3497 | ||
| 3501 | *b_size = strlen(*body); | 3498 | *b_size = strlen(*body); |
| 3502 | status = HTTP_STATUS_OK; | 3499 | status = HTTP_STATUS_OK; |
| @@ -3702,7 +3699,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3702 | 3699 | ||
| 3703 | int cnt = xs_number_get(xs_dict_get_def(srv_config, "max_public_entries", "20")); | 3700 | int cnt = xs_number_get(xs_dict_get_def(srv_config, "max_public_entries", "20")); |
| 3704 | 3701 | ||
| 3705 | xs *elems = timeline_simple_list(&snac, "public", 0, cnt); | 3702 | xs *elems = timeline_simple_list(&snac, "public", 0, cnt, NULL); |
| 3706 | xs *bio = xs_dup(xs_dict_get(snac.config, "bio")); | 3703 | xs *bio = xs_dup(xs_dict_get(snac.config, "bio")); |
| 3707 | 3704 | ||
| 3708 | xs *rss_title = xs_fmt("%s (@%s@%s)", | 3705 | xs *rss_title = xs_fmt("%s (@%s@%s)", |
| @@ -1676,7 +1676,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 1676 | else | 1676 | else |
| 1677 | if (strcmp(opt, "statuses") == 0) { /** **/ | 1677 | if (strcmp(opt, "statuses") == 0) { /** **/ |
| 1678 | /* the public list of posts of a user */ | 1678 | /* the public list of posts of a user */ |
| 1679 | xs *timeline = timeline_simple_list(&snac2, "public", 0, 256); | 1679 | xs *timeline = timeline_simple_list(&snac2, "public", 0, 256, NULL); |
| 1680 | xs_list *p = timeline; | 1680 | xs_list *p = timeline; |
| 1681 | const xs_str *v; | 1681 | const xs_str *v; |
| 1682 | 1682 | ||
| @@ -157,8 +157,8 @@ int timeline_here(snac *snac, const char *md5); | |||
| 157 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); | 157 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); |
| 158 | int timeline_del(snac *snac, const char *id); | 158 | int timeline_del(snac *snac, const char *id); |
| 159 | xs_str *user_index_fn(snac *user, const char *idx_name); | 159 | xs_str *user_index_fn(snac *user, const char *idx_name); |
| 160 | xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show); | 160 | xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show, int *more); |
| 161 | xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show); | 161 | xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show, int *more); |
| 162 | int timeline_add(snac *snac, const char *id, const xs_dict *o_msg); | 162 | int timeline_add(snac *snac, const char *id, const xs_dict *o_msg); |
| 163 | int timeline_admire(snac *snac, const char *id, const char *admirer, int like); | 163 | int timeline_admire(snac *snac, const char *id, const char *admirer, int like); |
| 164 | 164 | ||