Slon/Api/V1/Accounts: Handle array of ids for /api/v1/accounts/relationships

This commit is contained in:
Alec Murphy 2025-03-05 13:04:22 -05:00
parent 62b6d75851
commit 33a92718c7

View file

@ -158,11 +158,12 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
JsonObject* acct = NULL;
if (!StrICmp("relationships", session->path(3))) {
if (@slon_api_authorized(session)) {
// FIXME: handle array of id[]=
JsonArray* relationships = Json.CreateArray();
if (request_json->@("id%5B%5D")) {
JsonObject* target_account = @slon_api_account_by_id(request_json->@("id%5B%5D"));
JsonArray* relationship_of_ids = request_json->@("id");
JsonObject* target_account = NULL;
if (relationship_of_ids) {
for (i = 0; i < relationship_of_ids->length; i++) {
target_account = @slon_api_account_by_id(relationship_of_ids->@(i));
if (target_account) {
Bool followed_by = FALSE;
Bool following = FALSE;
@ -194,6 +195,7 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
relationships->append(Json.CreateItem(relationship, JSON_OBJECT));
}
}
}
session->send(relationships);
Json.Delete(relationships);