feat(guild): join / cancel_join_request / join_request_list
Implements three join-path state machine endpoints: - /guild/join: FREE (instant), APPROVAL (pending row + idempotent re-apply), ONLY_INVITE (pending invite required); CommitJoin consumes invites + cancels join requests; MaxMemberNum cap enforced. - /guild/cancel_join_request: cancels all pending requests for caller (no request_id on wire per GuildJoinRequestCancelTask decompile, composite PK kept). - /guild/join_request_list: leader/subleader sees pending applicants with viewer profile (name/emblem/degree/request_time unix secs). IGuildService.CancelJoinRequestAsync signature changed from (viewerId, guildId) to (viewerId) since the client sends no guildId. GuildJoinRequestEntry enriched record added to GuildServiceTypes. Re-apply after cancel resets existing row in-place to avoid composite-PK conflict. 11 integration tests, all green. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -243,15 +243,44 @@ public sealed class GuildController : SVSimController
|
||||
}
|
||||
|
||||
[HttpPost("join")]
|
||||
public Task<ActionResult<GuildJoinResponse>> Join([FromBody] GuildJoinEndpointRequest req, CancellationToken ct)
|
||||
=> Task.FromResult<ActionResult<GuildJoinResponse>>(new GuildJoinResponse { GuildStatus = 0 });
|
||||
public async Task<ActionResult<GuildJoinResponse>> Join([FromBody] GuildJoinEndpointRequest req, CancellationToken ct)
|
||||
{
|
||||
if (!TryGetViewerId(out var viewerId)) return Unauthorized();
|
||||
var r = await _guild.JoinAsync(viewerId, req.GuildId, ct);
|
||||
if (!r.IsOk) return WireError();
|
||||
// guild_status=2 (JOINING) on successful join; APPROVAL path also returns 2 as the viewer
|
||||
// is now "awaiting" — client drives the display from result_code, not guild_status alone.
|
||||
return new GuildJoinResponse { GuildStatus = 2 };
|
||||
}
|
||||
|
||||
[HttpPost("cancel_join_request")]
|
||||
public Task<ActionResult<EmptyResponse>> CancelJoinRequest([FromBody] GuildCancelJoinRequestRequest req, CancellationToken ct) => Stub();
|
||||
public async Task<ActionResult<EmptyResponse>> CancelJoinRequest([FromBody] GuildCancelJoinRequestRequest req, CancellationToken ct)
|
||||
{
|
||||
if (!TryGetViewerId(out var viewerId)) return Unauthorized();
|
||||
var r = await _guild.CancelJoinRequestAsync(viewerId, ct);
|
||||
return r.IsOk ? new EmptyResponse() : MapErrorToWire(r);
|
||||
}
|
||||
|
||||
[HttpPost("join_request_list")]
|
||||
public Task<ActionResult<GuildJoinRequestListResponse>> JoinRequestList([FromBody] GuildJoinRequestListRequest req, CancellationToken ct)
|
||||
=> Task.FromResult<ActionResult<GuildJoinRequestListResponse>>(new GuildJoinRequestListResponse { Users = new() });
|
||||
public async Task<ActionResult<GuildJoinRequestListResponse>> JoinRequestList([FromBody] GuildJoinRequestListRequest req, CancellationToken ct)
|
||||
{
|
||||
if (!TryGetViewerId(out var viewerId)) return Unauthorized();
|
||||
var entries = await _guild.ListPendingJoinRequestsForMyGuildAsync(viewerId, ct);
|
||||
return new GuildJoinRequestListResponse
|
||||
{
|
||||
Users = entries.Select(e => new GuildJoinRequestEntryDto
|
||||
{
|
||||
ViewerId = e.ApplicantViewerId,
|
||||
Name = e.Name,
|
||||
EmblemId = e.EmblemId,
|
||||
CountryCode = e.CountryCode,
|
||||
Rank = e.Rank,
|
||||
DegreeId = e.DegreeId,
|
||||
IsOfficialMarkDisplayed = e.IsOfficialMarkDisplayed ? 1 : 0,
|
||||
RequestTime = new DateTimeOffset(e.RequestedAt, TimeSpan.Zero).ToUnixTimeSeconds(),
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost("join_request_accept")]
|
||||
public Task<ActionResult<EmptyResponse>> JoinRequestAccept([FromBody] GuildJoinRequestAcceptRequest req, CancellationToken ct) => Stub();
|
||||
|
||||
Reference in New Issue
Block a user