fix(guild): /guild/join returns guild_status per branch (APPLYING for approval path, JOINING otherwise)
GuildJoinTask.Parse() reads data[guild_status].ToInt() directly; hardcoding 2 for the APPROVAL path was wrong. GuildOpResult gains nullable GuildStatus; JoinAsync sets 1 (APPLYING) for the pending-request path and 2 (JOINING) for instant joins. Controller reads r.GuildStatus. Two new tests assert the wire value per path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -275,7 +275,7 @@ public sealed class GuildService : IGuildService
|
||||
if (existing is { Status: GuildJoinRequestStatus.Pending })
|
||||
{
|
||||
// Already pending — idempotent, no-op.
|
||||
return GuildOpResult.Ok;
|
||||
return new(GuildOpResultCode.Ok, GuildStatus: 1); // APPLYING
|
||||
}
|
||||
|
||||
if (existing is not null)
|
||||
@@ -296,11 +296,11 @@ public sealed class GuildService : IGuildService
|
||||
CreatedAt = now,
|
||||
}, ct);
|
||||
}
|
||||
return GuildOpResult.Ok;
|
||||
return new(GuildOpResultCode.Ok, GuildStatus: 1); // APPLYING
|
||||
}
|
||||
|
||||
await CommitJoinAsync(viewerId, guildId, now, ct);
|
||||
return GuildOpResult.Ok;
|
||||
return new(GuildOpResultCode.Ok, GuildStatus: 2); // JOINING
|
||||
}
|
||||
|
||||
private async Task CommitJoinAsync(long viewerId, int guildId, DateTime now, CancellationToken ct)
|
||||
|
||||
@@ -22,7 +22,7 @@ public enum GuildOpResultCode
|
||||
InvalidRoleTransition,
|
||||
}
|
||||
|
||||
public sealed record GuildOpResult(GuildOpResultCode Code, int? GuildId = null, string? Detail = null)
|
||||
public sealed record GuildOpResult(GuildOpResultCode Code, int? GuildId = null, string? Detail = null, int? GuildStatus = null)
|
||||
{
|
||||
public static readonly GuildOpResult Ok = new(GuildOpResultCode.Ok);
|
||||
public bool IsOk => Code == GuildOpResultCode.Ok;
|
||||
|
||||
Reference in New Issue
Block a user