aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2025-05-27 21:14:23 +0200
committergrunfink <grunfink@comam.es>2025-05-27 21:14:23 +0200
commit5bc451159420d5d51a507fda82a623069cfae92b (patch)
tree725767368e77caa9751d39778b046b5ad00e4806
parent631e44a64a20741b5e4716bf75caf7fa743fef82 (diff)
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)
}
+int timeline_here(snac *user, const char *id)
+{
+ xs *md5 = xs_md5_hex(id, strlen(id));
+
+ return timeline_here_by_md5(user, md5);
+}
+
+
int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg)
/* gets a message from the timeline */
{
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,
const char *parent = get_in_reply_to(msg);
if (!xs_is_null(parent) && *parent) {
- xs *md5 = xs_md5_hex(parent, strlen(parent));
-
- if (!timeline_here_by_md5(user, md5)) {
+ if (!timeline_here(user, parent)) {
xs_html_add(post_header,
xs_html_tag("div",
xs_html_attr("class", "snac-origin"),
@@ -3773,9 +3771,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
q = url_acct;
/* add the post to the timeline */
- xs *md5 = xs_md5_hex(q, strlen(q));
-
- if (!timeline_here_by_md5(&snac, md5))
+ if (!timeline_here(&snac, q))
timeline_add(&snac, q, object);
}
}
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[])
xs_json_dump(data, 4, stdout);
enqueue_actor_refresh(&snac, xs_dict_get(data, "attributedTo"), 0);
- if (!timeline_here_by_md5(&snac, url))
+ if (!timeline_here(&snac, url))
timeline_add(&snac, url, data);
else
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,
/* reply something only for offset 0; otherwise,
apps like Tusky keep asking again and again */
if (xs_startswith(q, "https://")) {
- xs *md5 = xs_md5_hex(q, strlen(q));
-
- if (!timeline_here_by_md5(&snac1, md5)) {
+ if (!timeline_here(&snac1, q)) {
xs *object = NULL;
int status;
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);
double timeline_mtime(snac *snac);
int timeline_touch(snac *snac);
int timeline_here_by_md5(snac *snac, const char *md5);
+int timeline_here(snac *snac, const char *id);
int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg);
int timeline_del(snac *snac, const char *id);
xs_str *user_index_fn(snac *user, const char *idx_name);