Table of Contents

Class SupportTicketService

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

Support tickets and their conversations.

public sealed class SupportTicketService : BaseService<SupportTicketEntity>, ISupportTicketService
Inheritance
SupportTicketService
Implements
Inherited Members

Remarks

EF throughout, as AdminAuditService is and for the same reason: an unqualified raw statement resolves against the connection's search_path rather than the model's schema, and silently affects nothing where those differ.

Constructors

SupportTicketService(INpgsqlDbContextFactory)

public SupportTicketService(INpgsqlDbContextFactory dbContextFactory)

Parameters

dbContextFactory INpgsqlDbContextFactory

Methods

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

Appends a message and moves the activity timestamp.

public 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.

public 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.

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

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

CreateAsync(SupportTicketCreate, CancellationToken)

Files a ticket.

public 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.

public 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.

public 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.

public 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.

public 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.

public 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.