feat(mission): /mission/receive_reward stub (refresh-only, no decomp)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-12 23:33:50 -04:00
parent e54e63a762
commit 025c2a8c56
3 changed files with 60 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ using SVSim.Database.Repositories.Mission;
using SVSim.EmulatedEntrypoint.Models.Dtos.Common.Mission;
using SVSim.EmulatedEntrypoint.Models.Dtos.Mission;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.Mission;
using SVSim.EmulatedEntrypoint.Services;
namespace SVSim.EmulatedEntrypoint.Controllers;
@@ -133,6 +134,22 @@ public class MissionController : SVSimController
return Ok(dto);
}
[HttpPost("receive_reward")]
public async Task<IActionResult> ReceiveReward(MissionReceiveRewardRequest _, CancellationToken ct)
{
if (!TryGetViewerId(out long viewerId)) return Unauthorized();
// Spec is INFERRED — no decomp task class. Safe stub: refresh MissionInfoDetail
// so the client sees its current state. Real reward granting deferred until we
// observe a wire call.
var viewer = await LoadViewer(viewerId, ct);
await _state.EnsureCurrentAsync(viewer.Id, ct);
await _db.SaveChangesAsync(ct);
var dto = await _assembler.BuildAsync(viewer, ct);
return Ok(dto);
}
private Task<Viewer> LoadViewer(long viewerId, CancellationToken ct) =>
_db.Viewers
.Include(v => v.MissionData)

View File

@@ -0,0 +1,17 @@
using MessagePack;
using System.Text.Json.Serialization;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.Mission;
/// <summary>
/// INFERRED shape — the spec at docs/api-spec/endpoints/post-login/mission-receive-reward.md
/// flags this as not present in the client decompilation. Almost certainly an id of the
/// mission to claim.
/// </summary>
[MessagePackObject]
public class MissionReceiveRewardRequest : BaseRequest
{
[JsonPropertyName("id")]
[Key("id")]
public long Id { get; set; }
}

View File

@@ -0,0 +1,26 @@
using System.Net;
using System.Text;
using NUnit.Framework;
using SVSim.UnitTests.Infrastructure;
namespace SVSim.UnitTests.Controllers;
public class MissionControllerReceiveRewardTests
{
[Test]
public async Task ReceiveReward_returns_ok()
{
using var factory = new SVSimTestFactory();
long viewerId = await factory.SeedViewerAsync(tutorialState: 0);
using var client = factory.CreateAuthenticatedClient(viewerId);
// INFERRED: id of the mission to claim. Defensive stub accepts even when
// the id doesn't match a current mission — there is no decomp Parse() to
// tell us how the server errors.
var requestJson = """{"id":1,"viewer_id":"0","steam_id":0,"steam_session_ticket":""}""";
var response = await client.PostAsync("/mission/receive_reward",
new StringContent(requestJson, Encoding.UTF8, "application/json"));
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}
}