Skip to content

Commit 0a44c96

Browse files
authored
Merge branch 'main' into asset-blocker-again
2 parents 9cd25d9 + 22dd35f commit 0a44c96

File tree

7 files changed

+57
-3
lines changed

7 files changed

+57
-3
lines changed

Refresh.Core/Configuration/IntegrationConfig.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Refresh.Core.Configuration;
77
/// </summary>
88
public class IntegrationConfig : Config
99
{
10-
public override int CurrentConfigVersion => 8;
10+
public override int CurrentConfigVersion => 9;
1111
public override int Version { get; set; }
1212
protected override void Migrate(int oldVer, dynamic oldConfig)
1313
{
@@ -69,6 +69,7 @@ protected override void Migrate(int oldVer, dynamic oldConfig)
6969
#endregion
7070

7171
public string? GrafanaDashboardUrl { get; set; }
72+
public string? ServerStatusUrl { get; set; }
7273

7374
/// <summary>
7475
/// A link to a .SVG or .PNG containing the logo to use for branding.

Refresh.Database/GameDatabaseContext.Notifications.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void DeleteNotification(GameNotification notification)
8181
});
8282
}
8383

84-
public IEnumerable<GameAnnouncement> GetAnnouncements() => this.GameAnnouncements;
84+
public IEnumerable<GameAnnouncement> GetAnnouncements() => this.GameAnnouncements.OrderByDescending(a => a.CreatedAt);
8585

8686
public GameAnnouncement? GetAnnouncementById(ObjectId id) => this.GameAnnouncements.FirstOrDefault(a => a.AnnouncementId == id);
8787

Refresh.Interfaces.APIv3/Endpoints/DataTypes/Response/ApiInstanceResponse.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ public class ApiInstanceResponse : IApiResponse
4747

4848
public required bool MaintenanceModeEnabled { get; set; }
4949
public required string? GrafanaDashboardUrl { get; set; }
50+
public required string? ServerStatusUrl { get; set; }
5051

5152
public required string WebsiteLogoUrl { get; set; }
5253
public required string? WebsiteDefaultTheme { get; set; }
5354

5455
public required ApiContactInfoResponse ContactInfo { get; set; }
5556

5657
public required ApiContestResponse? ActiveContest { get; set; }
58+
59+
public required ApiRolePermissionsResponse NormalUserPermissions { get; set; }
60+
public required ApiRolePermissionsResponse TrustedUserPermissions { get; set; }
61+
62+
public required bool IsPresenceServerEnabled { get; set; }
63+
// TODO: similar attribute for CWLib integration
5764
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Refresh.Core.Configuration;
2+
3+
namespace Refresh.Interfaces.APIv3.Endpoints.DataTypes.Response;
4+
5+
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
6+
public class ApiRolePermissionsResponse : IApiResponse
7+
{
8+
public required ConfigAssetFlags BlockedAssetFlags { get; set; }
9+
public required bool ReadOnlyMode { get; set; }
10+
public required ApiTimedLevelLimitResponse? TimedLevelUploadLimits { get; set; }
11+
public required int UserFilesizeQuota { get; set; }
12+
13+
public static ApiRolePermissionsResponse FromOld(RolePermissions old)
14+
{
15+
return new()
16+
{
17+
BlockedAssetFlags = old.BlockedAssetFlags,
18+
ReadOnlyMode = old.ReadOnlyMode,
19+
TimedLevelUploadLimits = old.TimedLevelUploadLimits.Enabled ? new ApiTimedLevelLimitResponse()
20+
{
21+
TimeSpanHours = old.TimedLevelUploadLimits.TimeSpanHours,
22+
LevelQuota = old.TimedLevelUploadLimits.LevelQuota,
23+
} : null,
24+
UserFilesizeQuota = old.UserFilesizeQuota,
25+
};
26+
}
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Refresh.Interfaces.APIv3.Endpoints.DataTypes.Response;
2+
3+
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
4+
public class ApiTimedLevelLimitResponse : IApiResponse
5+
{
6+
public required int TimeSpanHours { get; set; }
7+
public required int LevelQuota { get; set; }
8+
}

Refresh.Interfaces.APIv3/Endpoints/InstanceApiEndpoints.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public ApiResponse<ApiStatisticsResponse> GetStatistics(RequestContext context,
4141
};
4242
}
4343

44+
[ApiV3Endpoint("announcements"), Authentication(false), AllowDuringMaintenance]
45+
[DocSummary("Retrieves all current announcements.")]
46+
[RateLimitSettings(300, 60, 240, "announcements-api")]
47+
public ApiResponse<List<ApiGameAnnouncementResponse>> GetAllAnnouncements(RequestContext context, DataContext dataContext)
48+
=> ApiGameAnnouncementResponse.FromOldList(dataContext.Database.GetAnnouncements().ToArray(), dataContext).ToList();
49+
4450
[ApiV3Endpoint("instance"), Authentication(false), AllowDuringMaintenance]
4551
[ClientCacheResponse(3600)] // One hour
4652
[DocSummary("Retrieves various information and metadata about the Refresh instance.")]
@@ -72,6 +78,11 @@ public ApiResponse<ApiInstanceResponse> GetInstanceInformation(RequestContext co
7278
GrafanaDashboardUrl = integrationConfig.GrafanaDashboardUrl,
7379
WebsiteLogoUrl = integrationConfig.WebsiteLogoUrl,
7480
WebsiteDefaultTheme = integrationConfig.WebsiteDefaultTheme,
81+
IsPresenceServerEnabled = integrationConfig.PresenceEnabled,
82+
ServerStatusUrl = integrationConfig.ServerStatusUrl,
83+
84+
NormalUserPermissions = ApiRolePermissionsResponse.FromOld(gameConfig.NormalUserPermissions),
85+
TrustedUserPermissions = ApiRolePermissionsResponse.FromOld(gameConfig.TrustedUserPermissions),
7586

7687
ContactInfo = new ApiContactInfoResponse
7788
{

Refresh.Interfaces.Game/Endpoints/AnnouncementEndpoints.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static bool AnnounceGetAnnouncements(StringBuilder output, GameDatabaseC
4747
{
4848
IEnumerable<GameAnnouncement> announcements = database.GetAnnouncements().ToList();
4949
foreach (GameAnnouncement announcement in announcements)
50-
output.Append($"{announcement.Title}: {announcement.Text}\n");
50+
output.Append($"{announcement.Title}: {announcement.Text}\n\n");
5151

5252
return announcements.Any();
5353
}

0 commit comments

Comments
 (0)