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>
43 lines
3.0 KiB
C#
43 lines
3.0 KiB
C#
namespace SVSim.Database.Services.Guild;
|
|
|
|
/// <summary>
|
|
/// Single dispatch surface for guild business operations. Enforces:
|
|
/// - one viewer ≤1 guild
|
|
/// - MaxMemberNum / MaxSubLeaderNum caps (from GuildConfig)
|
|
/// - role-based permissions per docs/superpowers/specs/2026-06-27-guild-functionality-design.md
|
|
/// - leader-leaves-with-members blocked
|
|
/// - auto-routing single-member leader leave -> breakup
|
|
/// - clear pending invites + cancel pending join_requests on successful join
|
|
/// - emit system chat events via IGuildChatService
|
|
/// </summary>
|
|
public interface IGuildService
|
|
{
|
|
Task<GuildFullView?> GetMyGuildAsync(long viewerId, CancellationToken ct = default);
|
|
Task<Entities.Guild.Guild?> GetActiveAsync(int guildId, CancellationToken ct = default);
|
|
Task<IReadOnlyList<GuildSearchEntry>> SearchAsync(string name, int activity, int joinCondition, int memberBucket, CancellationToken ct = default);
|
|
|
|
Task<GuildOpResult> CreateAsync(long viewerId, CreateGuildRequest req, CancellationToken ct = default);
|
|
Task<GuildOpResult> UpdateAsync(long viewerId, UpdateGuildRequest req, CancellationToken ct = default);
|
|
Task<GuildOpResult> UpdateDescriptionAsync(long viewerId, string description, CancellationToken ct = default);
|
|
Task<GuildOpResult> UpdateEmblemAsync(long viewerId, long emblemId, CancellationToken ct = default);
|
|
Task<GuildOpResult> BreakupAsync(long viewerId, CancellationToken ct = default);
|
|
|
|
Task<GuildOpResult> InviteAsync(long callerViewerId, long targetViewerId, CancellationToken ct = default);
|
|
Task<GuildOpResult> CancelInviteAsync(long callerViewerId, long inviteId, CancellationToken ct = default);
|
|
Task<GuildOpResult> RejectInviteAsync(long callerViewerId, long inviteId, CancellationToken ct = default);
|
|
|
|
Task<GuildOpResult> JoinAsync(long viewerId, int guildId, CancellationToken ct = default);
|
|
Task<GuildOpResult> CancelJoinRequestAsync(long viewerId, CancellationToken ct = default);
|
|
Task<GuildOpResult> AcceptJoinRequestAsync(long callerViewerId, long applicantViewerId, CancellationToken ct = default);
|
|
Task<GuildOpResult> RejectJoinRequestAsync(long callerViewerId, long applicantViewerId, CancellationToken ct = default);
|
|
|
|
Task<GuildOpResult> LeaveAsync(long viewerId, CancellationToken ct = default);
|
|
Task<GuildOpResult> RemoveAsync(long callerViewerId, long targetViewerId, CancellationToken ct = default);
|
|
Task<GuildOpResult> ChangeRoleAsync(long callerViewerId, long targetViewerId, int newRoleId, CancellationToken ct = default);
|
|
|
|
Task<IReadOnlyList<Entities.Guild.GuildInvite>> ListPendingInvitesForMeAsync(long viewerId, CancellationToken ct = default);
|
|
Task<IReadOnlyList<GuildOutgoingInviteEntry>> ListOutgoingInvitesAsync(long callerViewerId, CancellationToken ct = default);
|
|
Task<IReadOnlyList<GuildReceivedInviteEntry>> ListInvitedGuildsAsync(long viewerId, CancellationToken ct = default);
|
|
Task<IReadOnlyList<GuildJoinRequestEntry>> ListPendingJoinRequestsForMyGuildAsync(long viewerId, CancellationToken ct = default);
|
|
}
|