Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion Refresh.Core/Configuration/IntegrationConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Refresh.Core.Configuration;
/// </summary>
public class IntegrationConfig : Config
{
public override int CurrentConfigVersion => 8;
public override int CurrentConfigVersion => 9;
public override int Version { get; set; }
protected override void Migrate(int oldVer, dynamic oldConfig)
{
Expand Down Expand Up @@ -69,6 +69,7 @@ protected override void Migrate(int oldVer, dynamic oldConfig)
#endregion

public string? GrafanaDashboardUrl { get; set; }
public string? ServerStatusUrl { get; set; }

/// <summary>
/// A link to a .SVG or .PNG containing the logo to use for branding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ public class ApiInstanceResponse : IApiResponse

public required bool MaintenanceModeEnabled { get; set; }
public required string? GrafanaDashboardUrl { get; set; }
public required string? ServerStatusUrl { get; set; }

public required string WebsiteLogoUrl { get; set; }
public required string? WebsiteDefaultTheme { get; set; }

public required ApiContactInfoResponse ContactInfo { get; set; }

public required ApiContestResponse? ActiveContest { get; set; }

public required ApiRolePermissionsResponse NormalUserPermissions { get; set; }
public required ApiRolePermissionsResponse TrustedUserPermissions { get; set; }

public required bool IsPresenceServerEnabled { get; set; }
// TODO: similar attribute for CWLib integration
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Refresh.Core.Configuration;

namespace Refresh.Interfaces.APIv3.Endpoints.DataTypes.Response;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class ApiRolePermissionsResponse : IApiResponse
{
public required ConfigAssetFlags BlockedAssetFlags { get; set; }
public required bool ReadOnlyMode { get; set; }
public required ApiTimedLevelLimitResponse? TimedLevelUploadLimits { get; set; }
public required int UserFilesizeQuota { get; set; }

public static ApiRolePermissionsResponse FromOld(RolePermissions old)
{
return new()
{
BlockedAssetFlags = old.BlockedAssetFlags,
ReadOnlyMode = old.ReadOnlyMode,
TimedLevelUploadLimits = old.TimedLevelUploadLimits.Enabled ? new ApiTimedLevelLimitResponse()
{
TimeSpanHours = old.TimedLevelUploadLimits.TimeSpanHours,
LevelQuota = old.TimedLevelUploadLimits.LevelQuota,
} : null,
UserFilesizeQuota = old.UserFilesizeQuota,
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Refresh.Interfaces.APIv3.Endpoints.DataTypes.Response;

[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class ApiTimedLevelLimitResponse : IApiResponse
{
public required int TimeSpanHours { get; set; }
public required int LevelQuota { get; set; }
}
5 changes: 5 additions & 0 deletions Refresh.Interfaces.APIv3/Endpoints/InstanceApiEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public ApiResponse<ApiInstanceResponse> GetInstanceInformation(RequestContext co
GrafanaDashboardUrl = integrationConfig.GrafanaDashboardUrl,
WebsiteLogoUrl = integrationConfig.WebsiteLogoUrl,
WebsiteDefaultTheme = integrationConfig.WebsiteDefaultTheme,
IsPresenceServerEnabled = integrationConfig.PresenceEnabled,
ServerStatusUrl = integrationConfig.ServerStatusUrl,

NormalUserPermissions = ApiRolePermissionsResponse.FromOld(gameConfig.NormalUserPermissions),
TrustedUserPermissions = ApiRolePermissionsResponse.FromOld(gameConfig.TrustedUserPermissions),

ContactInfo = new ApiContactInfoResponse
{
Expand Down
Loading