summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mastoapi.c29
-rw-r--r--snac.h4
2 files changed, 13 insertions, 20 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,
1036 } 1036 }
1037 else 1037 else
1038 if (strcmp(cmd, "/v1/timelines/public") == 0) { 1038 if (strcmp(cmd, "/v1/timelines/public") == 0) {
1039 /* the public timeline (public timelines for all users) */ 1039 /* the instance public timeline (public timelines for all users) */
1040
1041 /* NOTE: this api call needs no authorization; but,
1042 I need a logged-in user in mastoapi_status() for
1043 is_msg_public() and the liked/boosted flags,
1044 so it will silently fail for pure public access */
1040 1045
1041 const char *limit_s = xs_dict_get(args, "limit"); 1046 const char *limit_s = xs_dict_get(args, "limit");
1042 int limit = 0; 1047 int limit = 0;
@@ -1053,7 +1058,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1053 xs_list *p = timeline; 1058 xs_list *p = timeline;
1054 xs_str *md5; 1059 xs_str *md5;
1055 1060
1056 while (xs_list_iter(&p, &md5) && cnt < limit) { 1061 while (logged_in && xs_list_iter(&p, &md5) && cnt < limit) {
1057 xs *msg = NULL; 1062 xs *msg = NULL;
1058 1063
1059 /* get the entry */ 1064 /* get the entry */
@@ -1064,23 +1069,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1064 if (strcmp(xs_dict_get(msg, "type"), "Note") != 0) 1069 if (strcmp(xs_dict_get(msg, "type"), "Note") != 0)
1065 continue; 1070 continue;
1066 1071
1067 /* get the uid */ 1072 /* convert the Note into a Mastodon status */
1068 xs *l = xs_split(xs_dict_get(msg, "attributedTo"), "/"); 1073 xs *st = mastoapi_status(&snac1, msg);
1069 const char *uid = xs_list_get(l, -1);
1070
1071 if (!xs_is_null(uid)) {
1072 snac user;
1073
1074 if (user_open(&user, uid)) {
1075 /* convert the Note into a Mastodon status */
1076 xs *st = mastoapi_status(&user, msg);
1077
1078 if (st != NULL)
1079 out = xs_list_append(out, st);
1080
1081 user_free(&user);
1082 }
1083 1074
1075 if (st != NULL) {
1076 out = xs_list_append(out, st);
1084 cnt++; 1077 cnt++;
1085 } 1078 }
1086 } 1079 }
diff --git a/snac.h b/snac.h
index 5478933..10e8c4c 100644
--- a/snac.h
+++ b/snac.h
@@ -127,8 +127,8 @@ int is_muted(snac *snac, const char *actor);
127void hide(snac *snac, const char *id); 127void hide(snac *snac, const char *id);
128int is_hidden(snac *snac, const char *id); 128int is_hidden(snac *snac, const char *id);
129 129
130int actor_add(snac *snac, const char *actor, d_char *msg); 130int actor_add(snac *snac, const char *actor, xs_dict *msg);
131int actor_get(snac *snac, const char *actor, d_char **data); 131int actor_get(snac *snac, const char *actor, xs_dict **data);
132 132
133int static_get(snac *snac, const char *id, d_char **data, int *size); 133int static_get(snac *snac, const char *id, d_char **data, int *size);
134void static_put(snac *snac, const char *id, const char *data, int size); 134void static_put(snac *snac, const char *id, const char *data, int size);