Slon/Api/V1/Accounts: Handle array of ids for /api/v1/accounts/relationships
This commit is contained in:
parent
62b6d75851
commit
33a92718c7
1 changed files with 31 additions and 29 deletions
|
@ -158,11 +158,12 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
|
||||||
JsonObject* acct = NULL;
|
JsonObject* acct = NULL;
|
||||||
if (!StrICmp("relationships", session->path(3))) {
|
if (!StrICmp("relationships", session->path(3))) {
|
||||||
if (@slon_api_authorized(session)) {
|
if (@slon_api_authorized(session)) {
|
||||||
// FIXME: handle array of id[]=
|
|
||||||
|
|
||||||
JsonArray* relationships = Json.CreateArray();
|
JsonArray* relationships = Json.CreateArray();
|
||||||
if (request_json->@("id%5B%5D")) {
|
JsonArray* relationship_of_ids = request_json->@("id");
|
||||||
JsonObject* target_account = @slon_api_account_by_id(request_json->@("id%5B%5D"));
|
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) {
|
if (target_account) {
|
||||||
Bool followed_by = FALSE;
|
Bool followed_by = FALSE;
|
||||||
Bool following = FALSE;
|
Bool following = FALSE;
|
||||||
|
@ -194,6 +195,7 @@ U0 @slon_api_v1_accounts_get(SlonHttpSession* session)
|
||||||
relationships->append(Json.CreateItem(relationship, JSON_OBJECT));
|
relationships->append(Json.CreateItem(relationship, JSON_OBJECT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
session->send(relationships);
|
session->send(relationships);
|
||||||
Json.Delete(relationships);
|
Json.Delete(relationships);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue