commit d4364e8

default  ·  2024-02-22 11:26:32 +0000 UTC
parent 69d3362
Added *another argument* to html_timeline() to select where posts are taken from.

This way, the /instance logged-in timeline can show posts that are not
really into a user's timeline.
3 files changed,  +14, -10
M html.c
M snac.h
M html.c
+10, -7
 1@@ -1886,7 +1886,8 @@ xs_html *html_footer(void)
 2 
 3 
 4 xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
 5-                      int skip, int show, int show_more, char *tag, char *page)
 6+                      int skip, int show, int show_more,
 7+                      char *tag, char *page, int utl)
 8 /* returns the HTML for the timeline */
 9 {
10     xs_list *p = (xs_list *)list;
11@@ -1938,7 +1939,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
12         xs *msg = NULL;
13         int status;
14 
15-        if (user && !is_pinned_by_md5(user, v))
16+        if (utl && user && !is_pinned_by_md5(user, v))
17             status = timeline_get_by_md5(user, v, &msg);
18         else
19             status = object_get_by_md5(v, &msg);
20@@ -2412,7 +2413,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
21 
22         if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) {
23             /** empty public timeline for private users **/
24-            *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "");
25+            *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "", 1);
26             *b_size = strlen(*body);
27             status  = 200;
28         }
29@@ -2430,7 +2431,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
30             xs *pins = pinned_list(&snac);
31             pins = xs_list_cat(pins, list);
32 
33-            *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "");
34+            *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "", 1);
35 
36             *b_size = strlen(*body);
37             status  = 200;
38@@ -2467,7 +2468,8 @@ int html_get_handler(const xs_dict *req, const char *q_path,
39                 xs *pins = pinned_list(&snac);
40                 pins = xs_list_cat(pins, list);
41 
42-                *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL, "/admin");
43+                *body = html_timeline(&snac, pins, 0, skip, show,
44+                        xs_list_len(next), NULL, "/admin", 1);
45 
46                 *b_size = strlen(*body);
47                 status  = 200;
48@@ -2511,7 +2513,8 @@ int html_get_handler(const xs_dict *req, const char *q_path,
49             xs *list = timeline_instance_list(skip, show);
50             xs *next = timeline_instance_list(skip + show, 1);
51 
52-            *body = html_timeline(&snac, list, 0, skip, show, xs_list_len(next), NULL, "/instance");
53+            *body = html_timeline(&snac, list, 0, skip, show,
54+                xs_list_len(next), NULL, "/instance", 0);
55             *b_size = strlen(*body);
56             status  = 200;
57         }
58@@ -2530,7 +2533,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
59 
60             list = xs_list_append(list, md5);
61 
62-            *body   = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "");
63+            *body   = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "", 1);
64             *b_size = strlen(*body);
65             status  = 200;
66         }
+2, -2
 1@@ -195,13 +195,13 @@ int server_get_handler(xs_dict *req, const char *q_path,
 2                 more = 1;
 3             }
 4 
 5-            *body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL);
 6+            *body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL, 0);
 7         }
 8         else
 9         if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) {
10             /** instance timeline **/
11             xs *tl = timeline_instance_list(0, 30);
12-            *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL);
13+            *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL, 0);
14         }
15         else
16             *body = greeting_html();
M snac.h
+2, -1
 1@@ -297,7 +297,8 @@ xs_str *sanitize(const char *content);
 2 xs_str *encode_html(const char *str);
 3 
 4 xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
 5-                      int skip, int show, int show_more, char *tag, char *page);
 6+                      int skip, int show, int show_more,
 7+                      char *tag, char *page, int utl);
 8 
 9 int html_get_handler(const xs_dict *req, const char *q_path,
10                      char **body, int *b_size, char **ctype, xs_str **etag);