commit 5bc4511
grunfink
·
2025-05-27 19:14:23 +0000 UTC
parent 631e44a
New function timeline_here().
5 files changed,
+13,
-10
M
data.c
+8,
-0
1@@ -1400,6 +1400,14 @@ int timeline_here_by_md5(snac *snac, const char *md5)
2 }
3
4
5+int timeline_here(snac *user, const char *id)
6+{
7+ xs *md5 = xs_md5_hex(id, strlen(id));
8+
9+ return timeline_here_by_md5(user, md5);
10+}
11+
12+
13 int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg)
14 /* gets a message from the timeline */
15 {
M
html.c
+2,
-6
1@@ -2115,9 +2115,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2 const char *parent = get_in_reply_to(msg);
3
4 if (!xs_is_null(parent) && *parent) {
5- xs *md5 = xs_md5_hex(parent, strlen(parent));
6-
7- if (!timeline_here_by_md5(user, md5)) {
8+ if (!timeline_here(user, parent)) {
9 xs_html_add(post_header,
10 xs_html_tag("div",
11 xs_html_attr("class", "snac-origin"),
12@@ -3773,9 +3771,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
13 q = url_acct;
14
15 /* add the post to the timeline */
16- xs *md5 = xs_md5_hex(q, strlen(q));
17-
18- if (!timeline_here_by_md5(&snac, md5))
19+ if (!timeline_here(&snac, q))
20 timeline_add(&snac, q, object);
21 }
22 }
M
main.c
+1,
-1
1@@ -695,7 +695,7 @@ int main(int argc, char *argv[])
2 xs_json_dump(data, 4, stdout);
3 enqueue_actor_refresh(&snac, xs_dict_get(data, "attributedTo"), 0);
4
5- if (!timeline_here_by_md5(&snac, url))
6+ if (!timeline_here(&snac, url))
7 timeline_add(&snac, url, data);
8 else
9 printf("Post %s already here\n", url);
+1,
-3
1@@ -2508,9 +2508,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 /* reply something only for offset 0; otherwise,
3 apps like Tusky keep asking again and again */
4 if (xs_startswith(q, "https://")) {
5- xs *md5 = xs_md5_hex(q, strlen(q));
6-
7- if (!timeline_here_by_md5(&snac1, md5)) {
8+ if (!timeline_here(&snac1, q)) {
9 xs *object = NULL;
10 int status;
11
M
snac.h
+1,
-0
1@@ -165,6 +165,7 @@ int pending_count(snac *user);
2 double timeline_mtime(snac *snac);
3 int timeline_touch(snac *snac);
4 int timeline_here_by_md5(snac *snac, const char *md5);
5+int timeline_here(snac *snac, const char *id);
6 int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg);
7 int timeline_del(snac *snac, const char *id);
8 xs_str *user_index_fn(snac *user, const char *idx_name);