mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-25 16:53:37 +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 */
|
/* only return entries older that max_id */
|
||||||
if (max_id) {
|
if (max_id) {
|
||||||
if (strcmp(v, max_id) == 0)
|
if (strcmp(v, MID_TO_MD5(max_id)) == 0)
|
||||||
max_id = NULL;
|
max_id = NULL;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -1180,14 +1180,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
|
|
||||||
/* only returns entries newer than since_id */
|
/* only returns entries newer than since_id */
|
||||||
if (since_id) {
|
if (since_id) {
|
||||||
if (strcmp(v, since_id) == 0)
|
if (strcmp(v, MID_TO_MD5(since_id)) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only returns entries newer than min_id */
|
/* only returns entries newer than min_id */
|
||||||
/* what does really "Return results immediately newer than ID" mean? */
|
/* what does really "Return results immediately newer than ID" mean? */
|
||||||
if (min_id) {
|
if (min_id) {
|
||||||
if (strcmp(v, min_id) == 0)
|
if (strcmp(v, MID_TO_MD5(min_id)) == 0)
|
||||||
break;
|
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)
|
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0)
|
||||||
continue;
|
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 */
|
/* discard notes from muted morons */
|
||||||
if (is_muted(&snac1, xs_dict_get(msg, "attributedTo")))
|
if (is_muted(&snac1, xs_dict_get(msg, "attributedTo")))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1505,6 +1510,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
else
|
else
|
||||||
if (xs_startswith(cmd, "/v1/statuses/")) { /** **/
|
if (xs_startswith(cmd, "/v1/statuses/")) { /** **/
|
||||||
/* information about a status */
|
/* information about a status */
|
||||||
|
if (logged_in) {
|
||||||
xs *l = xs_split(cmd, "/");
|
xs *l = xs_split(cmd, "/");
|
||||||
const char *id = xs_list_get(l, 3);
|
const char *id = xs_list_get(l, 3);
|
||||||
const char *op = xs_list_get(l, 4);
|
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
|
else
|
||||||
if (strcmp(cmd, "/v1/preferences") == 0) { /** **/
|
if (strcmp(cmd, "/v1/preferences") == 0) { /** **/
|
||||||
*body = xs_dup("{}");
|
*body = xs_dup("{}");
|
||||||
|
@ -1622,6 +1631,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(cmd, "/v2/search") == 0) { /** **/
|
if (strcmp(cmd, "/v2/search") == 0) { /** **/
|
||||||
|
if (logged_in) {
|
||||||
const char *q = xs_dict_get(args, "q");
|
const char *q = xs_dict_get(args, "q");
|
||||||
const char *type = xs_dict_get(args, "type");
|
const char *type = xs_dict_get(args, "type");
|
||||||
const char *offset = xs_dict_get(args, "offset");
|
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";
|
*ctype = "application/json";
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
status = 401;
|
||||||
|
}
|
||||||
|
|
||||||
/* user cleanup */
|
/* user cleanup */
|
||||||
if (logged_in)
|
if (logged_in)
|
||||||
|
|
Loading…
Reference in a new issue