Skip to content

Commit

Permalink
logic for displaying users public rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
Yucked committed Jun 4, 2024
1 parent 2f6b9c0 commit 80b1ca9
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions Ankh.Api/Handlers/RoomHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,29 @@ public async ValueTask<IReadOnlyList<RestRoomModel>> SearchRoomsAsync(
/// <summary>
///
/// </summary>
/// <param name="userId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public async ValueTask<VURoomModel> GetPublicRoomsForUserAsync(long userId) {
// https://client-dynamic.imvu.com/api/find_locations.php?cids={userIds}
return default;
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;
}

using var document = await JsonDocument.ParseAsync(await responseMessage.Content.ReadAsStreamAsync());
var result = document
.RootElement
.GetProperty("result")
.EnumerateObject()
.Select(x => {
var rooms = x.Value
.EnumerateArray()
.Select(y => y.Deserialize<VURoomModel>())
.ToArray();
return (long.Parse(x.Name), rooms);
})
.ToDictionary(x => x.Item1, y => y.rooms);

return result;
}
}

0 comments on commit 80b1ca9

Please sign in to comment.