From 2a172a6861a9f29f6fd87db5af10ccb382664191 Mon Sep 17 00:00:00 2001 From: CWX Date: Fri, 14 Feb 2025 17:12:09 +0000 Subject: [PATCH] make launcherV2 endpoints consistent, add new profile endpoint --- Libraries/Core/Callbacks/LauncherV2Callbacks.cs | 10 ++++++++++ Libraries/Core/Controllers/LauncherV2Controller.cs | 6 ++++++ .../Spt/Launcher/LauncherV2ProfileResponse.cs | 13 +++++++++++++ .../Core/Routers/Static/LauncherV2StaticRouter.cs | 10 +++++++--- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 Libraries/Core/Models/Spt/Launcher/LauncherV2ProfileResponse.cs diff --git a/Libraries/Core/Callbacks/LauncherV2Callbacks.cs b/Libraries/Core/Callbacks/LauncherV2Callbacks.cs index f27e04e9..1ec008a7 100644 --- a/Libraries/Core/Callbacks/LauncherV2Callbacks.cs +++ b/Libraries/Core/Callbacks/LauncherV2Callbacks.cs @@ -109,4 +109,14 @@ public class LauncherV2Callbacks( } ); } + + public object Profile(string? sessionId) + { + return _httpResponseUtil.NoBody( + new LauncherV2ProfileResponse + { + Response = _launcherV2Controller.GetProfile(sessionId) + } + ); + } } diff --git a/Libraries/Core/Controllers/LauncherV2Controller.cs b/Libraries/Core/Controllers/LauncherV2Controller.cs index bed8aca3..8afa66b2 100644 --- a/Libraries/Core/Controllers/LauncherV2Controller.cs +++ b/Libraries/Core/Controllers/LauncherV2Controller.cs @@ -1,5 +1,6 @@ using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Launcher; +using Core.Models.Eft.Profile; using Core.Models.Spt.Config; using Core.Models.Spt.Mod; using Core.Models.Utils; @@ -207,4 +208,9 @@ public class LauncherV2Controller( return null; } + + public SptProfile GetProfile(string? sessionId) + { + return _saveServer.GetProfile(sessionId); + } } diff --git a/Libraries/Core/Models/Spt/Launcher/LauncherV2ProfileResponse.cs b/Libraries/Core/Models/Spt/Launcher/LauncherV2ProfileResponse.cs new file mode 100644 index 00000000..0994cdc5 --- /dev/null +++ b/Libraries/Core/Models/Spt/Launcher/LauncherV2ProfileResponse.cs @@ -0,0 +1,13 @@ +using Core.Models.Eft.Profile; +using Core.Models.Utils; + +namespace Core.Models.Spt.Launcher; + +public class LauncherV2ProfileResponse : IRequestData +{ + public SptProfile Response + { + get; + set; + } +} diff --git a/Libraries/Core/Routers/Static/LauncherV2StaticRouter.cs b/Libraries/Core/Routers/Static/LauncherV2StaticRouter.cs index 351d2ca2..626d8166 100644 --- a/Libraries/Core/Routers/Static/LauncherV2StaticRouter.cs +++ b/Libraries/Core/Routers/Static/LauncherV2StaticRouter.cs @@ -21,12 +21,12 @@ public class LauncherV2StaticRouter : StaticRouter (url, _, sessionID, _) => launcherV2Callbacks.Types() ), new RouteAction( - "/launcher/v2/Login", + "/launcher/v2/login", (url, info, sessionID, _) => launcherV2Callbacks.Login(info as LoginRequestData), typeof(LoginRequestData) ), new RouteAction( - "/launcher/v2/Register", + "/launcher/v2/register", (url, info, sessionID, _) => launcherV2Callbacks.Register(info as RegisterData), typeof(RegisterData) ), @@ -36,7 +36,7 @@ public class LauncherV2StaticRouter : StaticRouter typeof(ChangeRequestData) ), new RouteAction( - "/launcher/v2/Remove", + "/launcher/v2/remove", (url, info, sessionID, _) => launcherV2Callbacks.Remove(info as LoginRequestData), typeof(LoginRequestData) ), @@ -51,6 +51,10 @@ public class LauncherV2StaticRouter : StaticRouter new RouteAction( "/launcher/v2/profiles", (url, _, sessionID, _) => launcherV2Callbacks.Profiles() + ), + new RouteAction( + "/launcher/v2/profile", + (url, _, sessionID, _) => launcherV2Callbacks.Profile(sessionID) ) ] )