summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c29
1 files changed, 11 insertions, 18 deletions
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++;
}
}