-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from BeatTogether/1.37.0
1.37.0
- Loading branch information
Showing
34 changed files
with
283 additions
and
207 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
BeatTogether.Status.Api.Controllers/BeatTogether.Status.Api.Controllers.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<Title>$(AssemblyName)</Title> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BeatTogether.Extensions.Serilog" Version="1.0.2" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.29" /> | ||
</ItemGroup> | ||
|
||
</Project> |
22 changes: 11 additions & 11 deletions
22
Configuration/QuickplayConfiguration.cs → ...s/Configuration/QuickplayConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
using BeatTogether.Status.Api.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Configuration | ||
{ | ||
public class QuickplayConfiguration | ||
{ | ||
public List<PredefinedPack> PredefinedPacks { get; set; } = new(); | ||
public List<LocalizedCustomPack> LocalizedCustomPacks { get; set; } = new(); | ||
} | ||
} | ||
using BeatTogether.Status.Api.Controllers.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Configuration | ||
{ | ||
public class QuickplayConfiguration | ||
{ | ||
public List<PredefinedPack> PredefinedPacks { get; set; } = new(); | ||
public List<LocalizedCustomPack> LocalizedCustomPacks { get; set; } = new(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
BeatTogether.Status.Api.Controllers/Configuration/StatusConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
using BeatTogether.Status.Api.Controllers.Models; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Configuration | ||
{ | ||
public class StatusConfiguration | ||
{ | ||
public string MinimumAppVersion { get; set; } = "1.0.0"; | ||
public long MaintenanceStartTime { get; set; } | ||
public long MaintenanceEndTime { get; set; } | ||
public List<LocalizedMessage> LocalizedMessages { get; set; } = new(); | ||
public List<RequiredMod> RequiredMods { get; set; } = new(); | ||
/// <summary> | ||
/// Prefer SSL (DTLS) for dedicated server connections? | ||
/// </summary> | ||
public bool UseSsl { get; set; } = false; | ||
public string ServerDisplayName { get; set; } = string.Empty; | ||
public string ServerDescription { get; set; } = string.Empty; | ||
public string ServerImageUrl { get; set; } = string.Empty; | ||
public int MaxPlayers { get; set; } = 25; | ||
public bool ServerSupportsPpModifiers { get; set; } = false; | ||
public bool ServerSupportsPpDifficulties { get; set; } = false; | ||
public bool ServerSupportsPpMaps { get; set; } = false; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
Controllers/QuickplayController.cs → ...ollers/Controllers/QuickplayController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 48 additions & 40 deletions
88
Controllers/StatusController.cs → ...ntrollers/Controllers/StatusController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,48 @@ | ||
using System; | ||
using BeatTogether.Status.Api.Configuration; | ||
using BeatTogether.Status.Api.Enums; | ||
using BeatTogether.Status.Api.Models; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace BeatTogether.Status.Api.Controllers | ||
{ | ||
[ApiController] | ||
[Route("status")] | ||
public class StatusController : ControllerBase | ||
{ | ||
private readonly StatusConfiguration _configuration; | ||
|
||
public StatusController(IOptionsSnapshot<StatusConfiguration> configuration) | ||
{ | ||
_configuration = configuration.Value; | ||
} | ||
|
||
[HttpGet] | ||
public MasterServerAvailabilityData Get() | ||
{ | ||
var status = AvailabilityStatus.Online; | ||
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); | ||
if (timestamp < _configuration.MaintenanceStartTime) | ||
status = AvailabilityStatus.MaintenanceUpcoming; | ||
else if (timestamp < _configuration.MaintenanceEndTime) | ||
status = AvailabilityStatus.Offline; | ||
return new MasterServerAvailabilityData( | ||
_configuration.MinimumAppVersion, | ||
status, | ||
_configuration.MaintenanceStartTime, | ||
_configuration.MaintenanceEndTime, | ||
new UserMessage(_configuration.LocalizedMessages), | ||
_configuration.RequiredMods | ||
); | ||
} | ||
} | ||
} | ||
using System; | ||
using BeatTogether.Status.Api.Controllers.Configuration; | ||
using BeatTogether.Status.Api.Controllers.Enums; | ||
using BeatTogether.Status.Api.Controllers.Models; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Controllers | ||
{ | ||
[ApiController] | ||
[Route("status")] | ||
public class StatusController : ControllerBase | ||
{ | ||
private readonly StatusConfiguration _configuration; | ||
|
||
public StatusController(IOptionsSnapshot<StatusConfiguration> configuration) | ||
{ | ||
_configuration = configuration.Value; | ||
} | ||
|
||
[HttpGet] | ||
public MasterServerStatusData Get() | ||
{ | ||
var status = AvailabilityStatus.Online; | ||
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); | ||
if (timestamp < _configuration.MaintenanceStartTime) | ||
status = AvailabilityStatus.MaintenanceUpcoming; | ||
else if (timestamp < _configuration.MaintenanceEndTime) | ||
status = AvailabilityStatus.Offline; | ||
return new MasterServerStatusData( | ||
_configuration.MinimumAppVersion, | ||
status, | ||
_configuration.MaintenanceStartTime, | ||
_configuration.MaintenanceEndTime, | ||
new UserMessage(_configuration.LocalizedMessages), | ||
_configuration.RequiredMods, | ||
_configuration.UseSsl, | ||
_configuration.ServerDisplayName, | ||
_configuration.ServerDescription, | ||
_configuration.ServerImageUrl, | ||
_configuration.MaxPlayers, | ||
_configuration.ServerSupportsPpModifiers, | ||
_configuration.ServerSupportsPpDifficulties, | ||
_configuration.ServerSupportsPpMaps | ||
); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Enums/AvailabilityStatus.cs → ...i.Controllers/Enums/AvailabilityStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Enums/Language.cs → ....Status.Api.Controllers/Enums/Language.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
BeatTogether.Status.Api.Controllers/Extensions/HostBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using BeatTogether.Extensions; | ||
using BeatTogether.Status.Api.Controllers.Configuration; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Extensions | ||
{ | ||
public static class HostBuilderExtensions | ||
{ | ||
public static IHostBuilder UseStatusServer(this IHostBuilder hostBuilder) => | ||
hostBuilder | ||
.ConfigureAppConfiguration() | ||
.ConfigureServices((hostBuilderContext, services) => | ||
services | ||
.Configure<StatusConfiguration>(hostBuilderContext.Configuration.GetSection("Status")) | ||
.Configure<QuickplayConfiguration>(hostBuilderContext.Configuration.GetSection("Quickplay")) | ||
); | ||
} | ||
} |
24 changes: 12 additions & 12 deletions
24
Models/LocalizedCustomPack.cs → ...Controllers/Models/LocalizedCustomPack.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class LocalizedCustomPack | ||
{ | ||
public string serializedName { get; set; } = string.Empty; | ||
public int order { get; set; } | ||
public List<LocalizedCustomPackName> localizedNames { get; set; } = new(); | ||
public List<string> packIds { get; set; } = new(); | ||
} | ||
} | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class LocalizedCustomPack | ||
{ | ||
public string serializedName { get; set; } = string.Empty; | ||
public int order { get; set; } | ||
public List<LocalizedCustomPackName> localizedNames { get; set; } = new(); | ||
public List<string> packIds { get; set; } = new(); | ||
} | ||
} |
20 changes: 10 additions & 10 deletions
20
Models/LocalizedCustomPackName.cs → ...rollers/Models/LocalizedCustomPackName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using BeatTogether.Status.Api.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class LocalizedCustomPackName | ||
{ | ||
public Language language { get; set; } | ||
public string packName { get; set; } = string.Empty; | ||
} | ||
} | ||
using BeatTogether.Status.Api.Controllers.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class LocalizedCustomPackName | ||
{ | ||
public Language language { get; set; } | ||
public string packName { get; set; } = string.Empty; | ||
} | ||
} |
20 changes: 10 additions & 10 deletions
20
Models/LocalizedMessage.cs → ...pi.Controllers/Models/LocalizedMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using BeatTogether.Status.Api.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class LocalizedMessage | ||
{ | ||
public Language language { get; set; } | ||
public string message { get; set; } = string.Empty; | ||
} | ||
} | ||
using BeatTogether.Status.Api.Controllers.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class LocalizedMessage | ||
{ | ||
public Language language { get; set; } | ||
public string message { get; set; } = string.Empty; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Models/MasterServerQuickplayData.cs → ...llers/Models/MasterServerQuickplayData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public record MasterServerQuickplayData(QuickplaySongPacksOverride quickPlayAvailablePacksOverride); | ||
} |
21 changes: 21 additions & 0 deletions
21
BeatTogether.Status.Api.Controllers/Models/MasterServerStatusData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using BeatTogether.Status.Api.Controllers.Enums; | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public record MasterServerStatusData( | ||
string minimumAppVersion, | ||
AvailabilityStatus status, | ||
long maintenanceStartTime, | ||
long maintenanceEndTime, | ||
UserMessage userMessage, | ||
List<RequiredMod> requiredMods, | ||
bool useSsl, | ||
string name, | ||
string description, | ||
string imageUrl, | ||
int maxPlayers, | ||
bool supportsPpModifiers, | ||
bool supportsPpDifficulties, | ||
bool supportsPpMaps); | ||
} |
16 changes: 8 additions & 8 deletions
16
Models/PredefinedPack.cs → ....Api.Controllers/Models/PredefinedPack.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class PredefinedPack | ||
{ | ||
public int order { get; set; } | ||
public string packId { get; set; } = string.Empty; | ||
} | ||
} | ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class PredefinedPack | ||
{ | ||
public int order { get; set; } | ||
public string packId { get; set; } = string.Empty; | ||
} | ||
} |
8 changes: 2 additions & 6 deletions
8
Models/QuickplaySongPacksOverride.cs → ...lers/Models/QuickplaySongPacksOverride.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public record RequiredMod | ||
{ | ||
/// <summary> | ||
/// BSIPA Mod ID | ||
/// </summary> | ||
public string id { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Minimum version of the mod required, if installed | ||
/// </summary> | ||
public string version { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Indicates whether the mod must be installed | ||
/// </summary> | ||
public bool required { get; set; } = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
| ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public record UserMessage(List<LocalizedMessage> localizedMessages); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.* | ||
run | ||
out | ||
Dockerfile |
Oops, something went wrong.