diff options
| author | 2025-05-27 21:14:23 +0200 | |
|---|---|---|
| committer | 2025-05-27 21:14:23 +0200 | |
| commit | 5bc451159420d5d51a507fda82a623069cfae92b (patch) | |
| tree | 725767368e77caa9751d39778b046b5ad00e4806 | |
| parent | Renamed timeline_here() to timeline_here_by_md5(), as it always should have b... (diff) | |
| download | snac2-5bc451159420d5d51a507fda82a623069cfae92b.tar.gz snac2-5bc451159420d5d51a507fda82a623069cfae92b.tar.xz snac2-5bc451159420d5d51a507fda82a623069cfae92b.zip | |
New function timeline_here().
| -rw-r--r-- | data.c | 8 | ||||
| -rw-r--r-- | html.c | 8 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | mastoapi.c | 4 | ||||
| -rw-r--r-- | snac.h | 1 |
5 files changed, 13 insertions, 10 deletions
| @@ -1400,6 +1400,14 @@ int timeline_here_by_md5(snac *snac, const char *md5) | |||
| 1400 | } | 1400 | } |
| 1401 | 1401 | ||
| 1402 | 1402 | ||
| 1403 | int timeline_here(snac *user, const char *id) | ||
| 1404 | { | ||
| 1405 | xs *md5 = xs_md5_hex(id, strlen(id)); | ||
| 1406 | |||
| 1407 | return timeline_here_by_md5(user, md5); | ||
| 1408 | } | ||
| 1409 | |||
| 1410 | |||
| 1403 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg) | 1411 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg) |
| 1404 | /* gets a message from the timeline */ | 1412 | /* gets a message from the timeline */ |
| 1405 | { | 1413 | { |
| @@ -2115,9 +2115,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2115 | const char *parent = get_in_reply_to(msg); | 2115 | const char *parent = get_in_reply_to(msg); |
| 2116 | 2116 | ||
| 2117 | if (!xs_is_null(parent) && *parent) { | 2117 | if (!xs_is_null(parent) && *parent) { |
| 2118 | xs *md5 = xs_md5_hex(parent, strlen(parent)); | 2118 | if (!timeline_here(user, parent)) { |
| 2119 | |||
| 2120 | if (!timeline_here_by_md5(user, md5)) { | ||
| 2121 | xs_html_add(post_header, | 2119 | xs_html_add(post_header, |
| 2122 | xs_html_tag("div", | 2120 | xs_html_tag("div", |
| 2123 | xs_html_attr("class", "snac-origin"), | 2121 | xs_html_attr("class", "snac-origin"), |
| @@ -3773,9 +3771,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3773 | q = url_acct; | 3771 | q = url_acct; |
| 3774 | 3772 | ||
| 3775 | /* add the post to the timeline */ | 3773 | /* add the post to the timeline */ |
| 3776 | xs *md5 = xs_md5_hex(q, strlen(q)); | 3774 | if (!timeline_here(&snac, q)) |
| 3777 | |||
| 3778 | if (!timeline_here_by_md5(&snac, md5)) | ||
| 3779 | timeline_add(&snac, q, object); | 3775 | timeline_add(&snac, q, object); |
| 3780 | } | 3776 | } |
| 3781 | } | 3777 | } |
| @@ -695,7 +695,7 @@ int main(int argc, char *argv[]) | |||
| 695 | xs_json_dump(data, 4, stdout); | 695 | xs_json_dump(data, 4, stdout); |
| 696 | enqueue_actor_refresh(&snac, xs_dict_get(data, "attributedTo"), 0); | 696 | enqueue_actor_refresh(&snac, xs_dict_get(data, "attributedTo"), 0); |
| 697 | 697 | ||
| 698 | if (!timeline_here_by_md5(&snac, url)) | 698 | if (!timeline_here(&snac, url)) |
| 699 | timeline_add(&snac, url, data); | 699 | timeline_add(&snac, url, data); |
| 700 | else | 700 | else |
| 701 | printf("Post %s already here\n", url); | 701 | printf("Post %s already here\n", url); |
| @@ -2508,9 +2508,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2508 | /* reply something only for offset 0; otherwise, | 2508 | /* reply something only for offset 0; otherwise, |
| 2509 | apps like Tusky keep asking again and again */ | 2509 | apps like Tusky keep asking again and again */ |
| 2510 | if (xs_startswith(q, "https://")) { | 2510 | if (xs_startswith(q, "https://")) { |
| 2511 | xs *md5 = xs_md5_hex(q, strlen(q)); | 2511 | if (!timeline_here(&snac1, q)) { |
| 2512 | |||
| 2513 | if (!timeline_here_by_md5(&snac1, md5)) { | ||
| 2514 | xs *object = NULL; | 2512 | xs *object = NULL; |
| 2515 | int status; | 2513 | int status; |
| 2516 | 2514 | ||
| @@ -165,6 +165,7 @@ int pending_count(snac *user); | |||
| 165 | double timeline_mtime(snac *snac); | 165 | double timeline_mtime(snac *snac); |
| 166 | int timeline_touch(snac *snac); | 166 | int timeline_touch(snac *snac); |
| 167 | int timeline_here_by_md5(snac *snac, const char *md5); | 167 | int timeline_here_by_md5(snac *snac, const char *md5); |
| 168 | int timeline_here(snac *snac, const char *id); | ||
| 168 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); | 169 | int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); |
| 169 | int timeline_del(snac *snac, const char *id); | 170 | int timeline_del(snac *snac, const char *id); |
| 170 | xs_str *user_index_fn(snac *user, const char *idx_name); | 171 | xs_str *user_index_fn(snac *user, const char *idx_name); |