summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar grunfink2025-05-27 21:14:23 +0200
committerGravatar grunfink2025-05-27 21:14:23 +0200
commit5bc451159420d5d51a507fda82a623069cfae92b (patch)
tree725767368e77caa9751d39778b046b5ad00e4806
parentRenamed timeline_here() to timeline_here_by_md5(), as it always should have b... (diff)
downloadpenes-snac2-5bc451159420d5d51a507fda82a623069cfae92b.tar.gz
penes-snac2-5bc451159420d5d51a507fda82a623069cfae92b.tar.xz
penes-snac2-5bc451159420d5d51a507fda82a623069cfae92b.zip
New function timeline_here().
-rw-r--r--data.c8
-rw-r--r--html.c8
-rw-r--r--main.c2
-rw-r--r--mastoapi.c4
-rw-r--r--snac.h1
5 files changed, 13 insertions, 10 deletions
diff --git a/data.c b/data.c
index 9eada38..224976b 100644
--- a/data.c
+++ b/data.c
@@ -1400,6 +1400,14 @@ int timeline_here_by_md5(snac *snac, const char *md5)
1400} 1400}
1401 1401
1402 1402
1403int 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
1403int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg) 1411int 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{
diff --git a/html.c b/html.c
index 4aa0fa4..4c30355 100644
--- a/html.c
+++ b/html.c
@@ -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 }
diff --git a/main.c b/main.c
index 9cfbb0d..80df2d0 100644
--- a/main.c
+++ b/main.c
@@ -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);
diff --git a/mastoapi.c b/mastoapi.c
index c88fd1b..df713a8 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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
diff --git a/snac.h b/snac.h
index 621ab8a..f32a90d 100644
--- a/snac.h
+++ b/snac.h
@@ -165,6 +165,7 @@ int pending_count(snac *user);
165double timeline_mtime(snac *snac); 165double timeline_mtime(snac *snac);
166int timeline_touch(snac *snac); 166int timeline_touch(snac *snac);
167int timeline_here_by_md5(snac *snac, const char *md5); 167int timeline_here_by_md5(snac *snac, const char *md5);
168int timeline_here(snac *snac, const char *id);
168int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); 169int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg);
169int timeline_del(snac *snac, const char *id); 170int timeline_del(snac *snac, const char *id);
170xs_str *user_index_fn(snac *user, const char *idx_name); 171xs_str *user_index_fn(snac *user, const char *idx_name);