Class SupportTicketService
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
dbContextFactoryINpgsqlDbContextFactory
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
ticketIdlongThe ticket.
authorAccountstringWho wrote it.
authorIsStaffboolWhether they were acting as staff.
internalNoteboolWhether the player must never see it.
bodystringThe text.
actorAccessLevelbyteThe staff author's access level, checked against the ticket's tier. Ignored for a player's reply, which is never tier-gated.
cancellationTokenCancellationTokenCancellation token.
Returns
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
ticketIdlongThe ticket.
staffAccountstringThe new assignee, or null to return it to the queue.
actorAccessLevelbyteThe acting staff member's level, checked against the ticket's tier.
cancellationTokenCancellationTokenCancellation token.
Returns
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
accountNamestringcancellationTokenCancellationToken
Returns
CreateAsync(SupportTicketCreate, CancellationToken)
Files a ticket.
public Task<DatabaseResult<long>> CreateAsync(SupportTicketCreate ticket, CancellationToken cancellationToken = default)
Parameters
ticketSupportTicketCreateThe ticket as filed.
cancellationTokenCancellationTokenCancellation 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
ticketIdlongThe ticket.
includeInternalboolWhether staff-only notes are included. False for anything a player can reach.
cancellationTokenCancellationTokenCancellation token.
Returns
SearchAsync(SupportTicketQuery, CancellationToken)
Searches tickets.
public Task<DatabaseResult<SupportTicketPage>> SearchAsync(SupportTicketQuery query, CancellationToken cancellationToken = default)
Parameters
querySupportTicketQueryFilters. Every field is optional.
cancellationTokenCancellationTokenCancellation token.
Returns
SetPriorityAsync(long, int, byte, CancellationToken)
Sets the staff priority.
public Task<DatabaseResult> SetPriorityAsync(long ticketId, int priority, byte actorAccessLevel, CancellationToken cancellationToken = default)
Parameters
ticketIdlongpriorityintactorAccessLevelbytecancellationTokenCancellationToken
Returns
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
ticketIdlongstatusSupportTicketStatusstaffAccountstringresolutionstringactorAccessLevelbytecancellationTokenCancellationToken
Returns
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
ticketIdlongThe ticket.
requiredAccessLevelbyteThe new tier, as an access level.
staffAccountstringWho is moving it.
reasonstringWhy. Required, and written onto the ticket as an internal note in the same transaction.
actorAccessLevelbyteTheir access level.
cancellationTokenCancellationTokenCancellation token.
Returns
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.