mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 15:38:45 -07:00
feat: Add support for 2018 client API endpoints and data models
- Implemented new search endpoints for rooms to accommodate the 2018 client. - Added support for retrieving room details and featured rooms in a format compatible with the 2018 client. - Introduced new data models for login responses and player presence specific to the 2018 client. - Created mappers to convert between internal entities and the 2018 wire formats for players and rooms. - Updated existing storefront APIs to include versioned endpoints for the 2018 client. - Enhanced the version controller to return dual-format responses for compatibility with both 2018 and 2020 clients. - Refactored the configuration service to ensure trailing slashes in URLs for the 2018 client.
This commit is contained in:
@@ -102,7 +102,7 @@ public class ConfigService(IConfiguration config, DomainConfig domain)
|
||||
foreach (var (service, sub) in ServiceSubdomains)
|
||||
{
|
||||
var host = string.IsNullOrEmpty(sub) ? apex : $"{sub}.{apex}";
|
||||
map[service] = $"https://{host}";
|
||||
map[service] = $"https://{host}/";
|
||||
}
|
||||
return map;
|
||||
}
|
||||
@@ -115,12 +115,21 @@ public class ConfigService(IConfiguration config, DomainConfig domain)
|
||||
if (domain.SingleOriginEnabled)
|
||||
{
|
||||
var prefix = string.IsNullOrEmpty(sub) ? "www" : sub;
|
||||
map[service] = $"{domain.SingleOriginBaseUrl}/__dn/{prefix}";
|
||||
map[service] = $"{domain.SingleOriginBaseUrl}/__dn/{prefix}/";
|
||||
continue;
|
||||
}
|
||||
var host = string.IsNullOrEmpty(sub) ? domain.Apex : domain.Sub(sub);
|
||||
map[service] = domain.Url(host);
|
||||
map[service] = EnsureTrailingSlash(domain.Url(host));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// The 2018.06 client builds every API URL by RAW string concat —
|
||||
// new Uri(string.Concat(serviceBase, "api/config/v2")) — so each service
|
||||
// base MUST be an absolute origin ending in '/', else the host glues to
|
||||
// the path ("https://api.apexapi/config/v2") and every call 404s. The
|
||||
// 2020 client runs EnsureEndsWith('/') on these values itself, so the
|
||||
// trailing slash is idempotent there — safe for both eras.
|
||||
private static string EnsureTrailingSlash(string url)
|
||||
=> url.EndsWith('/') ? url : url + "/";
|
||||
}
|
||||
|
||||
@@ -632,6 +632,15 @@ public class PlayerService(DorkNetDbContext db, RoomService rooms, ILogger<Playe
|
||||
public async Task<PlayerEntity?> GetByIdAsync(long id) =>
|
||||
await db.Players.Include(p => p.Avatar).FirstOrDefaultAsync(p => p.Id == id);
|
||||
|
||||
/// <summary>Bulk profile fetch for the 2018 client's batch resolvers
|
||||
/// (api/players/v1/list, presence). Single query; order is not guaranteed.</summary>
|
||||
public async Task<List<PlayerEntity>> GetByIdsAsync(IEnumerable<long> ids)
|
||||
{
|
||||
var idList = ids.Distinct().ToList();
|
||||
if (idList.Count == 0) return [];
|
||||
return await db.Players.Where(p => idList.Contains(p.Id)).ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stamp the calling platform onto an existing account so the
|
||||
/// next boot's <c>/cachedlogin/forplatformid</c> query finds it.
|
||||
|
||||
@@ -839,37 +839,13 @@ public class RoomService(DorkNetDbContext db)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project a RoomEntity to the wire shape Room.Deserialize at RVA
|
||||
/// 0x114E430 expects. Required keys (PascalCase):
|
||||
/// RoomId, Name, Description, CreatorPlayerId, ImageName, State,
|
||||
/// Accessibility, SupportsLevelVoting, IsAGRoom, CloningAllowed,
|
||||
/// SupportsScreens, SupportsWalkVR, SupportsTeleportVR,
|
||||
/// AllowsJuniors, RoomWarningMask, CustomRoomWarning
|
||||
/// Optional: IsDormRoom, SupportsVRLow, SupportsMobile, DisableMicAutoMute.
|
||||
/// Project a RoomEntity to the flat June-2018 wire room (RecNet
|
||||
/// Room.Deserialize, RecNet.cs:78244). This branch is 2018-only, so every
|
||||
/// room-returning endpoint emits this shape via the shared mapper — the
|
||||
/// 2020 RoomDetails/Scenes shape crashes the 2018 deserializer. See
|
||||
/// <see cref="Compat2018.Room2018Mapper"/>.
|
||||
/// </summary>
|
||||
public static object ToWireRoom(RoomEntity r) => new
|
||||
{
|
||||
RoomId = r.Id,
|
||||
Name = r.Name,
|
||||
Description = r.Description,
|
||||
CreatorPlayerId = r.CreatorPlayerId,
|
||||
ImageName = r.ImageName,
|
||||
State = r.State,
|
||||
Accessibility = r.Accessibility,
|
||||
SupportsLevelVoting = r.SupportsLevelVoting,
|
||||
IsAGRoom = r.IsAGRoom,
|
||||
IsDormRoom = r.IsDormRoom,
|
||||
CloningAllowed = r.CloningAllowed,
|
||||
SupportsVRLow = r.SupportsVRLow,
|
||||
SupportsMobile = r.SupportsMobile,
|
||||
SupportsScreens = r.SupportsScreens,
|
||||
SupportsWalkVR = r.SupportsWalkVR,
|
||||
SupportsTeleportVR = r.SupportsTeleportVR,
|
||||
AllowsJuniors = r.AllowsJuniors,
|
||||
RoomWarningMask = r.RoomWarningMask,
|
||||
CustomRoomWarning = r.CustomRoomWarning,
|
||||
DisableMicAutoMute = r.DisableMicAutoMute,
|
||||
};
|
||||
public static object ToWireRoom(RoomEntity r) => Compat2018.Room2018Mapper.From(r);
|
||||
|
||||
/// <summary>
|
||||
/// Idempotent admin overrides applied AFTER SeedAsync. Keeps the seed
|
||||
|
||||
Reference in New Issue
Block a user