commit 1b3f768

default  ·  2023-10-09 09:49:45 +0000 UTC
parent 4676f8c
mastoapi: some tweaks to better match the returned data in timelines.
2 files changed,  +23, -18
M data.c
M data.c
+9, -9
 1@@ -1121,15 +1121,6 @@ xs_list *timeline_top_level(snac *snac, xs_list *list)
 2 xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int show)
 3 /* returns a timeline (with all entries) */
 4 {
 5-    int c_max;
 6-
 7-    /* maximum number of items in the timeline */
 8-    c_max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
 9-
10-    /* never more timeline entries than the configured maximum */
11-    if (show > c_max)
12-        show = c_max;
13-
14     xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name);
15 
16     return index_list_desc(idx, skip, show);
17@@ -1139,6 +1130,15 @@ xs_list *timeline_simple_list(snac *snac, const char *idx_name, int skip, int sh
18 xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show)
19 /* returns a timeline (only top level entries) */
20 {
21+    int c_max;
22+
23+    /* maximum number of items in the timeline */
24+    c_max = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
25+
26+    /* never more timeline entries than the configured maximum */
27+    if (show > c_max)
28+        show = c_max;
29+
30     xs *list = timeline_simple_list(snac, idx_name, skip, show);
31 
32     return timeline_top_level(snac, list);
+14, -9
 1@@ -1265,7 +1265,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 2             if (limit == 0)
 3                 limit = 20;
 4 
 5-            xs *timeline = timeline_simple_list(&snac1, "private", 0, 256);
 6+            xs *timeline = timeline_simple_list(&snac1, "private", 0, 2048);
 7 
 8             xs *out      = xs_list_new();
 9             xs_list *p   = timeline;
10@@ -1304,19 +1304,24 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
11                 if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
12                     continue;
13 
14-#if 0
15-                /* discard notes from people we don't follow with no boosts */
16-                if (!following_check(&snac1, xs_dict_get(msg, "attributedTo")) &&
17-                    object_announces_len(xs_dict_get(msg, "id")) == 0)
18-                    continue;
19-#endif
20+                const char *atto = xs_dict_get(msg, "attributedTo");
21+                const char *id   = xs_dict_get(msg, "id");
22+
23+                /* is this message from a person we don't follow? */
24+                if (strcmp(atto, snac1.actor) && !following_check(&snac1, atto)) {
25+                    /* if we didn't boost it, discard */
26+                    xs *idx = object_announces(id);
27+
28+                    if (xs_list_in(idx, snac1.md5) == -1)
29+                        continue;
30+                }
31 
32                 /* discard notes from muted morons */
33-                if (is_muted(&snac1, xs_dict_get(msg, "attributedTo")))
34+                if (is_muted(&snac1, atto))
35                     continue;
36 
37                 /* discard hidden notes */
38-                if (is_hidden(&snac1, xs_dict_get(msg, "id")))
39+                if (is_hidden(&snac1, id))
40                     continue;
41 
42                 /* discard poll votes (they have a name) */