commit cfa0df3
default
·
2023-04-30 05:00:49 +0000 UTC
parent e31c481
The instance timeline now works.
2 files changed,
+13,
-20
M
snac.h
+11,
-18
1@@ -1036,7 +1036,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 }
3 else
4 if (strcmp(cmd, "/v1/timelines/public") == 0) {
5- /* the public timeline (public timelines for all users) */
6+ /* the instance public timeline (public timelines for all users) */
7+
8+ /* NOTE: this api call needs no authorization; but,
9+ I need a logged-in user in mastoapi_status() for
10+ is_msg_public() and the liked/boosted flags,
11+ so it will silently fail for pure public access */
12
13 const char *limit_s = xs_dict_get(args, "limit");
14 int limit = 0;
15@@ -1053,7 +1058,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
16 xs_list *p = timeline;
17 xs_str *md5;
18
19- while (xs_list_iter(&p, &md5) && cnt < limit) {
20+ while (logged_in && xs_list_iter(&p, &md5) && cnt < limit) {
21 xs *msg = NULL;
22
23 /* get the entry */
24@@ -1064,23 +1069,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
25 if (strcmp(xs_dict_get(msg, "type"), "Note") != 0)
26 continue;
27
28- /* get the uid */
29- xs *l = xs_split(xs_dict_get(msg, "attributedTo"), "/");
30- const char *uid = xs_list_get(l, -1);
31-
32- if (!xs_is_null(uid)) {
33- snac user;
34-
35- if (user_open(&user, uid)) {
36- /* convert the Note into a Mastodon status */
37- xs *st = mastoapi_status(&user, msg);
38-
39- if (st != NULL)
40- out = xs_list_append(out, st);
41-
42- user_free(&user);
43- }
44+ /* convert the Note into a Mastodon status */
45+ xs *st = mastoapi_status(&snac1, msg);
46
47+ if (st != NULL) {
48+ out = xs_list_append(out, st);
49 cnt++;
50 }
51 }
M
snac.h
+2,
-2
1@@ -127,8 +127,8 @@ int is_muted(snac *snac, const char *actor);
2 void hide(snac *snac, const char *id);
3 int is_hidden(snac *snac, const char *id);
4
5-int actor_add(snac *snac, const char *actor, d_char *msg);
6-int actor_get(snac *snac, const char *actor, d_char **data);
7+int actor_add(snac *snac, const char *actor, xs_dict *msg);
8+int actor_get(snac *snac, const char *actor, xs_dict **data);
9
10 int static_get(snac *snac, const char *id, d_char **data, int *size);
11 void static_put(snac *snac, const char *id, const char *data, int size);