Skip to content

Commit

Permalink
finished cleanup of GetPublicRoomsForUsersAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
Yucked committed Jun 4, 2024
1 parent 80b1ca9 commit 6cde226
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Ankh.Api/Handlers/RoomHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,16 @@ public async ValueTask<IReadOnlyList<RestRoomModel>> SearchRoomsAsync(
public async ValueTask<IDictionary<long, VURoomModel[]>> GetPublicRoomsForUsersAsync(params long[] userIds) {
var responseMessage =
await httpClient.GetAsync($"https://client-dynamic.imvu.com/api/find_locations.php?cids={userIds}");

if (!responseMessage.IsSuccessStatusCode) {
return default;
logger.LogError("{responseMessage.StatusCode}: {responseMessage.ReasonPhrase}",
responseMessage.StatusCode,
responseMessage.ReasonPhrase);
throw new Exception(responseMessage.ReasonPhrase);
}

using var document = await JsonDocument.ParseAsync(await responseMessage.Content.ReadAsStreamAsync());
var result = document
return document
.RootElement
.GetProperty("result")
.EnumerateObject()
Expand All @@ -180,8 +184,6 @@ public async ValueTask<IDictionary<long, VURoomModel[]>> GetPublicRoomsForUsersA
.ToArray();
return (long.Parse(x.Name), rooms);
})
.ToDictionary(x => x.Item1, y => y.rooms);

return result;
.ToDictionary(x => x.Item1, y => y.rooms)!;
}
}

0 comments on commit 6cde226

Please sign in to comment.