Initialize repository
Added basic info to get in game for like...August 2016 ;-; It's not much but it's a start
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Activities;
|
||||
using RecRoomArchive.Services;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Activities.Charades.V1
|
||||
{
|
||||
[Route(template: "api/[controller]/charades/v1")]
|
||||
[ApiController]
|
||||
public class ActivitiesController(MessageOfTheDayService motdService) : ControllerBase
|
||||
{
|
||||
// TODO: Move out of MOTD service
|
||||
[HttpGet(template: "words")]
|
||||
public async Task<ActionResult<List<CharadesWord>>> GetCharadesWords()
|
||||
{
|
||||
return Ok(await motdService.GetCharadesWordsList());
|
||||
}
|
||||
}
|
||||
}
|
||||
41
RecRoomArchive/Controllers/API/Avatar/V2/AvatarController.cs
Normal file
41
RecRoomArchive/Controllers/API/Avatar/V2/AvatarController.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Avatar;
|
||||
using RecRoomArchive.Services;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Avatar.V2
|
||||
{
|
||||
[Route(template: "api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class AvatarController(FileService fileService) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<PlayerAvatar>> GetAvatar()
|
||||
{
|
||||
var avatarData = fileService.GetData("avatar.json");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(avatarData))
|
||||
{
|
||||
var baseAvatar = new PlayerAvatar();
|
||||
fileService.SetData("avatar.json", JsonSerializer.Serialize(baseAvatar));
|
||||
return Ok(baseAvatar);
|
||||
}
|
||||
|
||||
var avatar = JsonSerializer.Deserialize<PlayerAvatar>(avatarData);
|
||||
return Ok(avatar);
|
||||
}
|
||||
|
||||
[HttpGet(template: "gifts")]
|
||||
public async Task<ActionResult<List<object>>> GetPendingGifts()
|
||||
{
|
||||
return Ok(new List<object>());
|
||||
}
|
||||
|
||||
[HttpPost(template: "set")]
|
||||
public async Task<ActionResult<PlayerAvatar>> SetAvatar(PlayerAvatar avatar)
|
||||
{
|
||||
fileService.SetData("avatar.json", JsonSerializer.Serialize(avatar));
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
16
RecRoomArchive/Controllers/API/Avatar/V3/AvatarController.cs
Normal file
16
RecRoomArchive/Controllers/API/Avatar/V3/AvatarController.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Avatar.V3
|
||||
{
|
||||
[Route(template: "api/[controller]/v3")]
|
||||
[ApiController]
|
||||
public class AvatarController() : ControllerBase
|
||||
{
|
||||
// TODO: Implement
|
||||
[HttpGet(template: "items")]
|
||||
public async Task<ActionResult<List<object>>> GetUnlockedAvatarItems()
|
||||
{
|
||||
return Ok(new List<object>());
|
||||
}
|
||||
}
|
||||
}
|
||||
34
RecRoomArchive/Controllers/API/Config/V1/ConfigController.cs
Normal file
34
RecRoomArchive/Controllers/API/Config/V1/ConfigController.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Services;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Config.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Configs that control Rec Room. These configs include data like Amplitude, MessageOfTheDay, Objectives, etc...
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]/v1")]
|
||||
[ApiController]
|
||||
public class ConfigController(MessageOfTheDayService motdService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the legacy version of the Message of the Day, to display on the Dorm Room bulletin board, or to show on the login screen in pre-Dorm Room versions of the game
|
||||
/// </summary>
|
||||
/// <returns>A basic string to display in game, related to the Message of the Day</returns>
|
||||
[HttpGet(template: "motd")]
|
||||
public async Task<ActionResult<string>> GetMessageOfTheDay()
|
||||
{
|
||||
var messageOfTheDay = await motdService.GetMessageOfTheDay();
|
||||
return Ok(messageOfTheDay);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current daily objectives to use before config/v2 existed
|
||||
/// </summary>
|
||||
/// <returns>A list of objectives</returns>
|
||||
[HttpGet(template: "objectives")]
|
||||
public async Task<ActionResult<List<object>>> GetDailyObjectives()
|
||||
{
|
||||
return Ok(new List<object>());
|
||||
}
|
||||
}
|
||||
}
|
||||
25
RecRoomArchive/Controllers/API/Config/V2/ConfigController.cs
Normal file
25
RecRoomArchive/Controllers/API/Config/V2/ConfigController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Config;
|
||||
using RecRoomArchive.Services;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Config.V2
|
||||
{
|
||||
/// <summary>
|
||||
/// Configs that control Rec Room. These configs include data like Amplitude, MessageOfTheDay, Objectives, etc...
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class ConfigController(ConfigService configService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the RecRoomConfig, containing lots of data on how the game should function
|
||||
/// </summary>
|
||||
/// <returns>RecRoomConfig</returns>
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<RecRoomConfig>> GetRecRoomConfig()
|
||||
{
|
||||
var recRoomConfig = await configService.GetRecRoomConfig();
|
||||
return Ok(recRoomConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
RecRoomArchive/Controllers/API/Images/V2/ImagesController.cs
Normal file
31
RecRoomArchive/Controllers/API/Images/V2/ImagesController.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Players;
|
||||
using RecRoomArchive.Services;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Images.V2
|
||||
{
|
||||
[Route("api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class ImagesController(FileService fileService, ImageService imageService) : ControllerBase
|
||||
{
|
||||
[HttpPost(template: "profile")]
|
||||
public async Task<ActionResult> SetProfileImage(IFormFile image)
|
||||
{
|
||||
using var stream = image.OpenReadStream();
|
||||
var imageName = await imageService.SaveImageAsync(stream);
|
||||
|
||||
var profileData = fileService.GetData("profile.json");
|
||||
if (profileData == null)
|
||||
return BadRequest("Profile is not populated");
|
||||
|
||||
var profile = JsonSerializer.Deserialize<BaseProfile>(profileData)!;
|
||||
|
||||
profile.ProfileImageName = imageName;
|
||||
|
||||
fileService.SetData("profile.json", JsonSerializer.Serialize(profile));
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Messages.V2
|
||||
{
|
||||
[Route(template: "api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class MessagesController : ControllerBase
|
||||
{
|
||||
[HttpGet(template: "get")]
|
||||
public async Task<ActionResult<List<object>>> GetMessages()
|
||||
{
|
||||
return new List<object>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.PlatformLogin.Requests;
|
||||
using RecRoomArchive.Models.API.PlatformLogin.Responses;
|
||||
using RecRoomArchive.Services;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.PlatformLogin.V2
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to login to accounts on Rec Room
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class PlatformLoginController(AppVersionService appVersionService, AccountService accountService, AuthorizationService authorizationService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the appVersion provided is allowed to play (which it most certainly will be unless its a weird build or someone messed with it)
|
||||
/// </summary>
|
||||
/// <returns>An Ok response if the version is valid, Forbid if it is not. Forbid will yield the client displaying "Rec Room Update Required" soo maybe don't</returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> Login([FromHeader(Name = "X-Rec-Room-Version")] string appVersion, [FromForm] BaseLoginRequest loginRequest)
|
||||
{
|
||||
var username = loginRequest.Name ?? string.Empty;
|
||||
|
||||
var buildTimestamp = loginRequest.BuildTimestamp;
|
||||
|
||||
// We are going to store the appVersion on login now...
|
||||
await appVersionService.StoreAppVersion(appVersion);
|
||||
await appVersionService.StoreBuildTimestamp(buildTimestamp);
|
||||
|
||||
// See if a profile exists yet...
|
||||
if(!accountService.AccountExists())
|
||||
{
|
||||
// ...if not, create it!
|
||||
accountService.CreateAccount(username);
|
||||
}
|
||||
|
||||
var accountId = accountService.GetSelfAccount()!.Id;
|
||||
|
||||
return Ok(new BaseLoginResponse
|
||||
{
|
||||
Token = authorizationService.GenerateToken(accountId),
|
||||
PlayerId = accountId
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
75
RecRoomArchive/Controllers/API/Players/PlayersController.cs
Normal file
75
RecRoomArchive/Controllers/API/Players/PlayersController.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Players;
|
||||
using RecRoomArchive.Services;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Players
|
||||
{
|
||||
/// <summary>
|
||||
/// Used in August 2016 RecNet
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]")]
|
||||
[ApiController]
|
||||
public class PlayersController(AccountService accountService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the profile tied to a SteamID (If it exists)
|
||||
/// </summary>
|
||||
/// <param name="steamId">The SteamID of the player we are trying to get the profile of</param>
|
||||
/// <returns>The profile of the player, if it exists</returns>
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<AugustProfile>> GetProfile([Required, FromQuery] ulong steamId)
|
||||
{
|
||||
var baseProfile = accountService.GetSelfAccount();
|
||||
if (baseProfile == null)
|
||||
return NotFound();
|
||||
|
||||
var profile = new AugustProfile(baseProfile)
|
||||
{
|
||||
SteamID = steamId
|
||||
};
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a profile and links it to a SteamID if the player does not already exist
|
||||
/// </summary>
|
||||
/// <param name="steamId">The SteamID of the player that we are creating a profile for</param>
|
||||
/// <param name="username">The Steam username of the player that we are creating a profile for</param>
|
||||
/// <returns>A new AugustProfile</returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<AugustProfile>> CreateProfile(
|
||||
[Required, FromForm(Name = "SteamID")] ulong steamId,
|
||||
[Required, FromForm(Name = "Name")] string username)
|
||||
{
|
||||
if (!accountService.AccountExists())
|
||||
{
|
||||
accountService.CreateAccount(username);
|
||||
}
|
||||
|
||||
var baseProfile = accountService.GetSelfAccount();
|
||||
if (baseProfile == null)
|
||||
return NotFound();
|
||||
|
||||
var profile = new AugustProfile(baseProfile)
|
||||
{
|
||||
SteamID = steamId
|
||||
};
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores data related to the player onto the server
|
||||
/// </summary>
|
||||
/// <param name="profileId">The Id of the Profile we are storing data for</param>
|
||||
/// <param name="model">The data the client posts...it happens to be an entire profile but we can take only the data we need :)</param>
|
||||
/// <returns>A successful response, likely will just return the updated profile</returns>
|
||||
[HttpPut(template: "{profileId:long}")]
|
||||
public async Task<ActionResult<AugustProfile>> UpdateProfile([Required] ulong profileId, [FromBody] AugustProfile model)
|
||||
{
|
||||
return (AugustProfile)accountService.GetSelfAccount()!;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Config;
|
||||
using RecRoomArchive.Models.API.Platform;
|
||||
using RecRoomArchive.Models.API.Players;
|
||||
using RecRoomArchive.Services;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Players.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to get accounts / profiles in 2016-2020 although gets phased out as time goes on...
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]/v1")]
|
||||
[ApiController]
|
||||
public class PlayersController(AccountService accountService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the profile of this ID (If it exists)
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the player we are trying to get the profile of</param>
|
||||
/// <returns>The profile of the player, if it exists</returns>
|
||||
[HttpGet(template: "{id:long}")]
|
||||
public async Task<ActionResult<BaseProfile>> GetProfile([Required] ulong id)
|
||||
{
|
||||
return accountService.GetSelfAccount()!;
|
||||
}
|
||||
|
||||
[HttpPost(template: "listByPlatformId")]
|
||||
public async Task<ActionResult<List<object>>> GetFromServer([FromForm] PlatformType platform, [FromForm] List<ulong> platformIds)
|
||||
{
|
||||
return Ok(new List<object>());
|
||||
}
|
||||
|
||||
[HttpGet(template: "search/{query}")]
|
||||
public async Task<ActionResult<List<BaseProfile>>> SearchForProfiles(string query)
|
||||
{
|
||||
return Ok(new List<BaseProfile>());
|
||||
}
|
||||
|
||||
[HttpGet(template: "phoneLastFour")]
|
||||
public async Task<ActionResult<PhoneNumberDTO>> GetPhoneLastFour()
|
||||
{
|
||||
return Ok(new PhoneNumberDTO());
|
||||
}
|
||||
|
||||
[HttpGet(template: "blockDuration")]
|
||||
public async Task<ActionResult<BlockDurationDTO>> GetBlockDuration()
|
||||
{
|
||||
return Ok(new BlockDurationDTO());
|
||||
}
|
||||
|
||||
[HttpPost(template: "objectives")]
|
||||
public async Task<ActionResult> CompleteObjectives(object objective)
|
||||
{
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Players;
|
||||
using RecRoomArchive.Models.Common;
|
||||
using RecRoomArchive.Services;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Players.V2
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to modify accounts / profiles in 2017-2019 although gets phased out as time goes on...
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class PlayersController(FileService fileService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the players displayName
|
||||
/// </summary>
|
||||
/// <param name="name">The displayName the player is requesting</param>
|
||||
/// <returns>OkResponse</returns>
|
||||
[HttpPost(template: "displayName")]
|
||||
public async Task<ActionResult<OkResponse>> SetDisplayName([FromForm(Name = "Name")] string name)
|
||||
{
|
||||
var profileData = fileService.GetData("profile.json");
|
||||
if (profileData == null)
|
||||
return BadRequest("Profile is not populated");
|
||||
|
||||
var profile = JsonSerializer.Deserialize<BaseProfile>(profileData)!;
|
||||
|
||||
profile.DisplayName = name;
|
||||
|
||||
fileService.SetData("profile.json", JsonSerializer.Serialize(profile));
|
||||
|
||||
return Ok(OkResponse.Ok());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Relationships.V2
|
||||
{
|
||||
[Route(template: "api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class RelationshipsController : ControllerBase
|
||||
{
|
||||
[HttpGet(template: "get")]
|
||||
public async Task<ActionResult<List<object>>> GetRelationships()
|
||||
{
|
||||
return new List<object>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Avatar;
|
||||
using RecRoomArchive.Models.API.Setting;
|
||||
using RecRoomArchive.Services;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.Settings.V2
|
||||
{
|
||||
[Route(template: "api/[controller]/v2")]
|
||||
[ApiController]
|
||||
public class SettingsController(FileService fileService) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<Setting>>> GetSettings()
|
||||
{
|
||||
var settingsData = fileService.GetData("settings.json");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(settingsData))
|
||||
{
|
||||
return Ok(new List<Setting>());
|
||||
}
|
||||
|
||||
var settings = JsonSerializer.Deserialize<List<Setting>>(settingsData);
|
||||
return Ok(settings);
|
||||
}
|
||||
|
||||
[HttpPost(template: "set")]
|
||||
public async Task<ActionResult> SetSetting(Setting setting)
|
||||
{
|
||||
var settingsData = fileService.GetData("settings.json");
|
||||
|
||||
var settings = string.IsNullOrWhiteSpace(settingsData) ? [] : JsonSerializer.Deserialize<List<Setting>>(settingsData) ?? [];
|
||||
|
||||
settings.RemoveAll(x => x.Key == setting.Key);
|
||||
settings.Add(setting);
|
||||
|
||||
fileService.SetData("settings.json", JsonSerializer.Serialize(settings));
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Services;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.VersionCheck.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Endpoints used to check if the version the player is playing on is up to date enough to play Rec Room, due to this being a custom server, it doesn't really matter
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]/v1")]
|
||||
[ApiController]
|
||||
public class VersionCheckController(AppVersionService appVersionService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the appVersion provided is allowed to play (which it most certainly will be unless its a weird build or someone messed with it)
|
||||
/// </summary>
|
||||
/// <returns>An Ok response if the version is valid, Forbid if it is not. Forbid will yield the client displaying "Rec Room Update Required" soo maybe don't</returns>
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> CheckVersion([FromHeader(Name = "X-Rec-Room-Version")] string appVersion)
|
||||
{
|
||||
if (appVersion == null)
|
||||
return Forbid();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user