using Data.SeaHavenIndustries; using SeaHaven.DataServices.Dto; namespace SeaHaven.DataServices.Interfaces { /// /// Persistence for team member registration invites. Every state transition that /// guards a security limit is a single conditional update, so concurrent requests /// cannot exceed the limit; each returns whether the transition happened. /// public interface ITeamMemberInviteDataService { Task AddAsync(TeamMemberInvite invite, CancellationToken cancellationToken); /// Revokes every open invite for the invite's user and adds the new one, atomically. Task ReplaceOpenForUserAsync(TeamMemberInvite invite, DateTime now, CancellationToken cancellationToken); Task GetByTokenHashAsync(string tokenHash, CancellationToken cancellationToken); Task TryStartCodeAsync(StartTeamMemberInviteCodeCommand command, CancellationToken cancellationToken); /// Counts one verification attempt against a live code; false once the attempt limit is used up. Task TryReserveCodeAttemptAsync(int inviteId, int maxAttempts, DateTime now, CancellationToken cancellationToken); Task TryConfirmEmailAsync(int inviteId, string codeHash, DateTime now, CancellationToken cancellationToken); /// Marks an open, unexpired, email-confirmed invite as used; false when another request already did. Task TryClaimAsync(int inviteId, DateTime now, CancellationToken cancellationToken); } }