Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.37.0 #6

Merged
merged 24 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8580edf
maint: target .net 7 / latest
roydejong Jul 5, 2023
fe15e5a
tweak: add "useSsl" to availability data
roydejong Jul 5, 2023
5866e0a
Add extra info to the server infomation endpoint
cubicgraphics Apr 2, 2024
1bac5d4
Merge branch 'dev-1.31.0' into dev-1.35.0
cubicgraphics Apr 2, 2024
6194e2f
Fix typo
cubicgraphics Apr 2, 2024
1eb9c22
Update docker.yml
cubicgraphics Apr 2, 2024
dbdeb89
Update docker actions file
cubicgraphics Apr 2, 2024
25efc2a
Merge branch 'dev-1.35.0' of https://github.com/BeatTogether/BeatToge…
cubicgraphics Apr 2, 2024
a28d0ec
Undo docker changes
cubicgraphics Apr 2, 2024
ef107cc
Updated docketfile to specify .net 7
cubicgraphics Apr 2, 2024
66b9776
merge info data into status endpoint
roydejong Apr 4, 2024
402cb5d
tweak: consistent casing on "PP" fields
roydejong Apr 14, 2024
3b8978c
tweak: use "snake_case" for API response fields
roydejong Apr 14, 2024
cb25368
Added config for info
cubicgraphics May 11, 2024
619b3ee
Merge branch 'dev-1.35.0' of https://github.com/BeatTogether/BeatToge…
cubicgraphics May 11, 2024
e24f7c2
Fix config
cubicgraphics May 11, 2024
8dec8da
Added function for loading api configs
cubicgraphics May 11, 2024
946fada
Seperate server executeable and api controllers
cubicgraphics May 14, 2024
cfd4424
Fix dockerfile
cubicgraphics May 14, 2024
df995e3
Update appsettings.json
cubicgraphics Aug 24, 2024
972a0e3
Update docker.yml
cubicgraphics Aug 24, 2024
9fbdfce
Update docker.yml
cubicgraphics Aug 24, 2024
2600242
Moved the solution file
cubicgraphics Aug 24, 2024
12f16b6
Merge branch '1.37.0' of https://github.com/BeatTogether/BeatTogether…
cubicgraphics Aug 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
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();
}
}
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;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BeatTogether.Status.Api.Configuration;
using BeatTogether.Status.Api.Models;
using BeatTogether.Status.Api.Controllers.Configuration;
using BeatTogether.Status.Api.Controllers.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;

namespace BeatTogether.Status.Api.Controllers
namespace BeatTogether.Status.Api.Controllers.Controllers
{
[ApiController]
[Route("status/mp_override.json")]
Expand Down
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
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BeatTogether.Status.Api.Enums
namespace BeatTogether.Status.Api.Controllers.Enums
{
public enum AvailabilityStatus
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BeatTogether.Status.Api.Enums
namespace BeatTogether.Status.Api.Controllers.Enums
{
public enum Language
{
Expand Down
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"))
);
}
}
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();
}
}
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;
}
}
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;
}
}
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);
}
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);
}
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;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BeatTogether.Status.Api.Models

namespace BeatTogether.Status.Api.Controllers.Models
{
public record QuickplaySongPacksOverride(
List<PredefinedPack> predefinedPackIds,
Expand Down
18 changes: 18 additions & 0 deletions BeatTogether.Status.Api.Controllers/Models/RequiredMod.cs
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;
}
}
5 changes: 5 additions & 0 deletions BeatTogether.Status.Api.Controllers/Models/UserMessage.cs
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);
}
13 changes: 0 additions & 13 deletions BeatTogether.Status.Api.csproj

This file was deleted.

12 changes: 9 additions & 3 deletions BeatTogether.Status.Api.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30626.31
# Visual Studio Version 17
VisualStudioVersion = 17.8.34316.72
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeatTogether.Status.Api", "BeatTogether.Status.Api.csproj", "{EF1C2D6B-3B1A-48A6-BD7F-554910E7E957}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeatTogether.Status.Api", "BeatTogether.Status.Api\BeatTogether.Status.Api.csproj", "{EF1C2D6B-3B1A-48A6-BD7F-554910E7E957}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeatTogether.Status.Api.Controllers", "BeatTogether.Status.Api.Controllers\BeatTogether.Status.Api.Controllers.csproj", "{5E167F5A-625A-4F74-8424-FE6FD428D904}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{EF1C2D6B-3B1A-48A6-BD7F-554910E7E957}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF1C2D6B-3B1A-48A6-BD7F-554910E7E957}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF1C2D6B-3B1A-48A6-BD7F-554910E7E957}.Release|Any CPU.Build.0 = Release|Any CPU
{5E167F5A-625A-4F74-8424-FE6FD428D904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E167F5A-625A-4F74-8424-FE6FD428D904}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E167F5A-625A-4F74-8424-FE6FD428D904}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E167F5A-625A-4F74-8424-FE6FD428D904}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 4 additions & 0 deletions BeatTogether.Status.Api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.*
run
out
Dockerfile
Loading
Loading