mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-24 16:43:36 +00:00
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:
commit
422b3148ae
1 changed files with 121 additions and 108 deletions
19
mastoapi.c
19
mastoapi.c
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue