From cfa0df3ac5a8b62539a3d1830414ec3d81d24f5d Mon Sep 17 00:00:00 2001 From: default Date: Sun, 30 Apr 2023 07:00:49 +0200 Subject: The instance timeline now works. --- mastoapi.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'mastoapi.c') diff --git a/mastoapi.c b/mastoapi.c index 92acd41..5c4e27f 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -1036,7 +1036,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, } else if (strcmp(cmd, "/v1/timelines/public") == 0) { - /* the public timeline (public timelines for all users) */ + /* the instance public timeline (public timelines for all users) */ + + /* NOTE: this api call needs no authorization; but, + I need a logged-in user in mastoapi_status() for + is_msg_public() and the liked/boosted flags, + so it will silently fail for pure public access */ const char *limit_s = xs_dict_get(args, "limit"); int limit = 0; @@ -1053,7 +1058,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, xs_list *p = timeline; xs_str *md5; - while (xs_list_iter(&p, &md5) && cnt < limit) { + while (logged_in && xs_list_iter(&p, &md5) && cnt < limit) { xs *msg = NULL; /* get the entry */ @@ -1064,23 +1069,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, if (strcmp(xs_dict_get(msg, "type"), "Note") != 0) continue; - /* get the uid */ - xs *l = xs_split(xs_dict_get(msg, "attributedTo"), "/"); - const char *uid = xs_list_get(l, -1); - - if (!xs_is_null(uid)) { - snac user; - - if (user_open(&user, uid)) { - /* convert the Note into a Mastodon status */ - xs *st = mastoapi_status(&user, msg); - - if (st != NULL) - out = xs_list_append(out, st); - - user_free(&user); - } + /* convert the Note into a Mastodon status */ + xs *st = mastoapi_status(&snac1, msg); + if (st != NULL) { + out = xs_list_append(out, st); cnt++; } } -- cgit v1.2.3