Table of Contents

Interface IGuildApplicationService

Namespace
FishMMO.Database.Npgsql.Services.Interfaces
Assembly
FishMMO-DB.dll

Service interface for the guild recruitment directory and its application queue.

public interface IGuildApplicationService

Methods

ApplyAsync(long, long, string, int, int, CancellationToken)

Submits an application, refusing duplicates, non-recruiting guilds and full guilds.

Task<DatabaseResult> ApplyAsync(long guildId, long characterId, string message, int maxCapacity, int maxPendingPerCharacter, CancellationToken cancellationToken = default)

Parameters

guildId long

Guild applied to.

characterId long

Applying character.

message string

Applicant message.

maxCapacity int

Guild member cap.

maxPendingPerCharacter int

Most outstanding applications one character may hold.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

A result indicating success or the reason for refusal.

Remarks

Every one of those conditions is tested inside the INSERT. Checking them in application code and inserting afterwards is a time-of-check-to-time-of-use gap the applicant controls the timing of: apply to a guild with one seat left, twice, from two clients.

DeleteAsync(long, long, CancellationToken)

Deletes one application by ID.

Task<DatabaseResult<bool>> DeleteAsync(long applicationId, long guildId, CancellationToken cancellationToken = default)

Parameters

applicationId long

Application ID.

guildId long

The guild the caller believes the application belongs to.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<bool>>

True when a row was actually removed.

Remarks

The guild is part of the WHERE clause, not merely validated beforehand: it is the last line that stops an officer of one guild resolving another guild's application by ID. The boolean result is what the accept path uses to claim the application exactly once — two officers pressing Accept simultaneously, only one of whom gets true.

DeleteManyByCharacterAsync(long, CancellationToken)

Deletes every application a character has outstanding.

Task<DatabaseResult<int>> DeleteManyByCharacterAsync(long characterId, CancellationToken cancellationToken = default)

Parameters

characterId long

Character ID.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<int>>

The number of rows removed.

Remarks

Run when a character joins any guild. An application that outlives the applicant's guildless state is an accept waiting to fail.

FetchAsync(long, CancellationToken)

Fetches one application by ID.

Task<DatabaseResult<GuildApplicationData?>> FetchAsync(long applicationId, CancellationToken cancellationToken = default)

Parameters

applicationId long

Application ID.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<GuildApplicationData?>>

The application, or null.

FetchManyAsync(long, int, CancellationToken)

Fetches the pending applications for one guild, oldest first.

Task<DatabaseResult<IReadOnlyList<GuildApplicationData>>> FetchManyAsync(long guildId, int limit, CancellationToken cancellationToken = default)

Parameters

guildId long

Guild ID.

limit int

Maximum rows to return.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<IReadOnlyList<GuildApplicationData>>>

The pending queue.

SearchDirectoryAsync(string, int, CancellationToken)

Searches the recruitment directory.

Task<DatabaseResult<IReadOnlyList<GuildDirectoryEntryData>>> SearchDirectoryAsync(string searchTerm, int limit, CancellationToken cancellationToken = default)

Parameters

searchTerm string

Optional case-insensitive term matched against name, blurb and tags.

limit int

Maximum rows to return.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<IReadOnlyList<GuildDirectoryEntryData>>>

Matching recruiting guilds with their current member counts.