Merge pull request 'Mastodon API private timeline fixes' (#44) from poesty/snac2:master into master

Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/44
This commit is contained in:
grunfink 2023-06-11 07:05:07 +00:00
commit 422b3148ae

View File

@ -1172,7 +1172,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
/* only return entries older that max_id */
if (max_id) {
if (strcmp(v, max_id) == 0)
if (strcmp(v, MID_TO_MD5(max_id)) == 0)
max_id = NULL;
continue;
@ -1180,14 +1180,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
/* only returns entries newer than since_id */
if (since_id) {
if (strcmp(v, since_id) == 0)
if (strcmp(v, MID_TO_MD5(since_id)) == 0)
break;
}
/* only returns entries newer than min_id */
/* what does really "Return results immediately newer than ID" mean? */
if (min_id) {
if (strcmp(v, min_id) == 0)
if (strcmp(v, MID_TO_MD5(min_id)) == 0)
break;
}
@ -1200,6 +1200,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
continue;
/* discard notes from people we don't follow with no boosts */
if (!following_check(&snac1, xs_dict_get(msg, "attributedTo")) &&
object_announces_len(xs_dict_get(msg, "id")) == 0)
continue;
/* discard notes from muted morons */
if (is_muted(&snac1, xs_dict_get(msg, "attributedTo")))
continue;
@ -1505,6 +1510,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
else
if (xs_startswith(cmd, "/v1/statuses/")) { /** **/
/* information about a status */
if (logged_in) {
xs *l = xs_split(cmd, "/");
const char *id = xs_list_get(l, 3);
const char *op = xs_list_get(l, 4);
@ -1602,6 +1608,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
}
}
}
else
status = 401;
}
else
if (strcmp(cmd, "/v1/preferences") == 0) { /** **/
*body = xs_dup("{}");
@ -1622,6 +1631,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
}
else
if (strcmp(cmd, "/v2/search") == 0) { /** **/
if (logged_in) {
const char *q = xs_dict_get(args, "q");
const char *type = xs_dict_get(args, "type");
const char *offset = xs_dict_get(args, "offset");
@ -1660,6 +1670,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
*ctype = "application/json";
status = 200;
}
else
status = 401;
}
/* user cleanup */
if (logged_in)