Table of Contents

Class AdminAuditService

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

Append-only operator audit log.

public sealed class AdminAuditService : BaseService<AdminAuditEntity>, IAdminAuditService
Inheritance
AdminAuditService
Implements
Inherited Members

Remarks

EF throughout and no raw SQL, for the same reason as WebSessionService: an unqualified raw statement resolves against the connection's search_path rather than the model's configured schema, and on a deployment where those differ it silently affects nothing. A log that silently writes nothing is worse than no log, because it is believed.

Constructors

AdminAuditService(INpgsqlDbContextFactory)

public AdminAuditService(INpgsqlDbContextFactory dbContextFactory)

Parameters

dbContextFactory INpgsqlDbContextFactory

Methods

AppendAsync(AdminAuditData, CancellationToken)

Records one action.

public Task<DatabaseResult<long>> AppendAsync(AdminAuditData entry, CancellationToken cancellationToken = default)

Parameters

entry AdminAuditData

The action. OccurredUtc is filled in when left at default.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<long>>

Remarks

Call this for refusals as well as successes. A log holding only what worked cannot distinguish an operator who never tried from one who tried and was stopped, and the second is the one worth knowing about.

Returns the new row's id. Callers that cannot usefully react to a failure should still check the result and log it: a write that silently did not happen is the one failure mode that makes the whole table untrustworthy.

FetchActionsAsync(CancellationToken)

The distinct action identifiers present in the log, for populating a filter.

public Task<DatabaseResult<IReadOnlyList<string>>> FetchActionsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<IReadOnlyList<string>>>

Remarks

Read from the data rather than from a constant list, so an action added by a future command appears in the filter without anybody remembering to register it.

SearchAsync(AdminAuditQuery, CancellationToken)

Reads a page of the log, newest first.

public Task<DatabaseResult<AdminAuditPage>> SearchAsync(AdminAuditQuery query, CancellationToken cancellationToken = default)

Parameters

query AdminAuditQuery

Filters. Every field is optional.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<AdminAuditPage>>