Table of Contents

Interface ISupportTicketService

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

Support tickets: filed by players in the game, worked by staff in the Control Panel.

public interface ISupportTicketService

Remarks

Whether internal notes are returned is decided here, not by the caller. Every read takes an explicit includeInternal, and a player-facing caller passes false. Making it the caller's job to filter afterwards is the shape in which internal notes eventually leak: it only takes one endpoint that forgets, and the failure is silent until a player quotes a game master's private note back at them.

Nothing here checks who is asking. Authorization is the panel's, because it depends on the caller's access level, which this layer cannot see — but every read that can reach a player forces the decision to be made.

Methods

AppendMessageAsync(long, string, bool, bool, string, byte, CancellationToken)

Appends a message and moves the activity timestamp.

Task<DatabaseResult<long>> AppendMessageAsync(long ticketId, string authorAccount, bool authorIsStaff, bool internalNote, string body, byte actorAccessLevel, CancellationToken cancellationToken = default)

Parameters

ticketId long

The ticket.

authorAccount string

Who wrote it.

authorIsStaff bool

Whether they were acting as staff.

internalNote bool

Whether the player must never see it.

body string

The text.

actorAccessLevel byte

The staff author's access level, checked against the ticket's tier. Ignored for a player's reply, which is never tier-gated.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<long>>

Remarks

One method for a player's reply and a staff note alike, because they are the same row with different flags — and because two methods would be two places for the internal flag to be got wrong.

AssignAsync(long, string, byte, CancellationToken)

Assigns a ticket, or clears the assignment when staffAccount is null.

Task<DatabaseResult> AssignAsync(long ticketId, string staffAccount, byte actorAccessLevel, CancellationToken cancellationToken = default)

Parameters

ticketId long

The ticket.

staffAccount string

The new assignee, or null to return it to the queue.

actorAccessLevel byte

The acting staff member's level, checked against the ticket's tier.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

Remarks

Moves an Open ticket to InProgress as a side effect, because taking a ticket and saying you are working on it are the same act, and a queue where those are two clicks is a queue full of assigned tickets still marked open.

CountOpenForAccountAsync(string, CancellationToken)

Counts a player's unfinished tickets, for showing them why they cannot file another.

Task<DatabaseResult<int>> CountOpenForAccountAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

CreateAsync(SupportTicketCreate, CancellationToken)

Files a ticket.

Task<DatabaseResult<long>> CreateAsync(SupportTicketCreate ticket, CancellationToken cancellationToken = default)

Parameters

ticket SupportTicketCreate

The ticket as filed.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<long>>

The new ticket's id.

Remarks

Refuses when the account already holds too many unfinished tickets, or filed one moments ago. A support queue with no such limit is one a single annoyed player can make unusable for everybody, and the limit belongs here rather than in one caller because the game and the panel can both file.

FetchAsync(long, bool, CancellationToken)

Fetches one ticket and its conversation.

Task<DatabaseResult<SupportTicketData>> FetchAsync(long ticketId, bool includeInternal, CancellationToken cancellationToken = default)

Parameters

ticketId long

The ticket.

includeInternal bool

Whether staff-only notes are included. False for anything a player can reach.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<SupportTicketData>>

SearchAsync(SupportTicketQuery, CancellationToken)

Searches tickets.

Task<DatabaseResult<SupportTicketPage>> SearchAsync(SupportTicketQuery query, CancellationToken cancellationToken = default)

Parameters

query SupportTicketQuery

Filters. Every field is optional.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<SupportTicketPage>>

SetPriorityAsync(long, int, byte, CancellationToken)

Sets the staff priority.

Task<DatabaseResult> SetPriorityAsync(long ticketId, int priority, byte actorAccessLevel, CancellationToken cancellationToken = default)

Parameters

ticketId long
priority int
actorAccessLevel byte
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

SetStatusAsync(long, SupportTicketStatus, string, string, byte, CancellationToken)

Sets the status, and the resolution when finishing.

Task<DatabaseResult> SetStatusAsync(long ticketId, SupportTicketStatus status, string staffAccount, string resolution, byte actorAccessLevel, CancellationToken cancellationToken = default)

Parameters

ticketId long
status SupportTicketStatus
staffAccount string
resolution string
actorAccessLevel byte
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

Remarks

A ticket moved to Resolved or Closed must carry a resolution: the whole value of a closed ticket is being able to answer "what was decided" a month later.

SetTierAsync(long, byte, string, string, byte, CancellationToken)

Moves a ticket to another support tier, clearing its assignee.

Task<DatabaseResult> SetTierAsync(long ticketId, byte requiredAccessLevel, string staffAccount, string reason, byte actorAccessLevel, CancellationToken cancellationToken = default)

Parameters

ticketId long

The ticket.

requiredAccessLevel byte

The new tier, as an access level.

staffAccount string

Who is moving it.

reason string

Why. Required, and written onto the ticket as an internal note in the same transaction.

actorAccessLevel byte

Their access level.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

Remarks

A tier is the lowest access level that may see and work the ticket: GameMaster or Admin. Every staff write on this service refuses an actor below the ticket's tier with Forbidden, so a promoted ticket cannot be worked through a typed ticket number.

The actor must be allowed to work the ticket at its current tier. A game master may therefore promote a first-tier ticket, and only an administrator may hand one back down. The assignee is cleared and an in-progress ticket returns to open, because whoever held it is handing it on. The activity clock is not moved.