Skip to content

Commit 4957f81

Browse files
feat: Implement TriggerPushMap method in ISyncApiClient and SyncApiClient for map synchronization
1 parent 0bbdd16 commit 4957f81

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/XtremeIdiots.Portal.Web/Controllers/MapManagerController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using XtremeIdiots.Portal.Repository.Api.Client.V1;
99
using XtremeIdiots.Portal.Web.Auth.Constants;
1010
using XtremeIdiots.Portal.Web.Extensions;
11+
using XtremeIdiots.Portal.Web.Services;
1112
using XtremeIdiots.Portal.Web.ViewModels;
1213

1314
namespace XtremeIdiots.Portal.Web.Controllers;
@@ -29,6 +30,7 @@ public class MapManagerController(
2930
IAuthorizationService authorizationService,
3031
IRepositoryApiClient repositoryApiClient,
3132
IServersApiClient serversApiClient,
33+
ISyncApiClient syncApiClient,
3234
TelemetryClient telemetryClient,
3335
ILogger<MapManagerController> logger,
3436
IConfiguration configuration) : BaseController(telemetryClient, logger, configuration)
@@ -135,15 +137,15 @@ public async Task<IActionResult> PushMapToRemote(PushMapToRemoteViewModel viewMo
135137
if (actionResult != null)
136138
return actionResult;
137139

138-
await serversApiClient.Maps.V1.PushServerMapToHost(viewModel.GameServerId, viewModel.MapName!).ConfigureAwait(false);
140+
await syncApiClient.TriggerPushMap(viewModel.GameServerId, viewModel.MapName!, cancellationToken).ConfigureAwait(false);
139141

140142
TrackSuccessTelemetry("MapPushedToRemote", nameof(PushMapToRemote), new Dictionary<string, string>
141143
{
142144
{ nameof(viewModel.GameServerId), viewModel.GameServerId.ToString() },
143145
{ nameof(viewModel.MapName), viewModel.MapName ?? "Unknown" }
144146
});
145147

146-
this.AddAlertSuccess($"Map '{viewModel.MapName}' has been successfully pushed to the remote server.");
148+
this.AddAlertSuccess($"Map '{viewModel.MapName}' push has been triggered. The map will be synced to the server shortly.");
147149
return RedirectToAction(nameof(Manage), new { id = viewModel.GameServerId });
148150
}, nameof(PushMapToRemote)).ConfigureAwait(false);
149151
}

src/XtremeIdiots.Portal.Web/Services/ISyncApiClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public interface ISyncApiClient
77
Task<SyncTriggerResult> TriggerDeactivate(Guid assignmentId, CancellationToken cancellationToken = default);
88
Task<SyncTriggerResult> TriggerRemove(Guid assignmentId, CancellationToken cancellationToken = default);
99
Task<SyncTriggerResult> TriggerVerify(Guid assignmentId, CancellationToken cancellationToken = default);
10+
Task<SyncTriggerResult> TriggerPushMap(Guid gameServerId, string mapName, CancellationToken cancellationToken = default);
1011
Task<OrchestrationStatusQueryResult> GetOrchestrationStatus(string instanceId, CancellationToken cancellationToken = default);
1112
Task<SyncTriggerResult> TerminateOrchestration(string instanceId, CancellationToken cancellationToken = default);
1213
}

src/XtremeIdiots.Portal.Web/Services/NoOpSyncApiClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public Task<SyncTriggerResult> TriggerVerify(Guid assignmentId, CancellationToke
2727
return Task.FromResult(new SyncTriggerResult(false, Error: "Sync API not configured"));
2828
}
2929

30+
public Task<SyncTriggerResult> TriggerPushMap(Guid gameServerId, string mapName, CancellationToken cancellationToken = default)
31+
{
32+
return Task.FromResult(new SyncTriggerResult(false, Error: "Sync API not configured"));
33+
}
34+
3035
public Task<OrchestrationStatusQueryResult> GetOrchestrationStatus(string instanceId, CancellationToken cancellationToken = default)
3136
{
3237
return Task.FromResult(new OrchestrationStatusQueryResult(OrchestrationStatusQueryOutcome.Error));

src/XtremeIdiots.Portal.Web/Services/SyncApiClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public Task<SyncTriggerResult> TriggerVerify(Guid assignmentId, CancellationToke
3636
return TriggerOrchestration($"/api/map-rotations/verify/{assignmentId}", cancellationToken);
3737
}
3838

39+
public Task<SyncTriggerResult> TriggerPushMap(Guid gameServerId, string mapName, CancellationToken cancellationToken = default)
40+
{
41+
return TriggerOrchestration($"/api/maps/push/{gameServerId}/{Uri.EscapeDataString(mapName)}", cancellationToken);
42+
}
43+
3944
public async Task<OrchestrationStatusQueryResult> GetOrchestrationStatus(string instanceId, CancellationToken cancellationToken = default)
4045
{
4146
try

0 commit comments

Comments
 (0)