< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Command.Services.ErasedPersonInvitations
Assembly: ArturRios.Heimdall.Command
File(s): /home/ci/agent/workspace/heimdall-api-docs_main/app/src/Application/ArturRios.Heimdall.Command/Services/ErasedPersonInvitations.cs
Line coverage
72%
Covered lines: 8
Uncovered lines: 3
Coverable lines: 11
Total lines: 56
Line coverage: 72.7%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage
100%
Covered methods: 1
Fully covered methods: 0
Total methods: 1
Method coverage: 100%
Full method coverage: 0%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ForgetAsync()100%4472.72%

File(s)

/home/ci/agent/workspace/heimdall-api-docs_main/app/src/Application/ArturRios.Heimdall.Command/Services/ErasedPersonInvitations.cs

#LineLine coverage
 1using ArturRios.Heimdall.Command.Auditing;
 2using ArturRios.Heimdall.Domain.Persistence;
 3using Microsoft.Extensions.Logging;
 4
 5namespace ArturRios.Heimdall.Command.Services;
 6
 7/// <summary>
 8///     Forgets erased persons in the scope owner invitations (FR-SC-17): voids their unended invitations,
 9///     clears them as the inviter of every other, and records each void in the audit trail
 10///     (<c>ScopeOwnerInvitationVoided</c>, NFR-09) on the invitation it ended.
 11/// </summary>
 12/// <remarks>
 13///     <para>
 14///         Shared by the scheduled anonymisation pass (NFR-20) and the re-application of erasures (NFR-25),
 15///         so the two cannot disagree about what an erased person's invitations become.
 16///     </para>
 17///     <para>
 18///         <b>Why the voids are audited here, and at once.</b> <see cref="IScopeOwnerInvitations.ForgetPersonsAsync" />
 19///         commits on its own. Left to the run's outcome, a later step failing would lose the entries for
 20///         good: the decorator records a refused run's refusal only, and a retry finds the invitations
 21///         already ended, with no id left to return. Like the decorator, a failed audit write is logged and
 22///         the run goes on.
 23///     </para>
 24/// </remarks>
 25public static class ErasedPersonInvitations
 26{
 27    /// <returns>The public ids of the invitations voided, in no particular order.</returns>
 28    public static async Task<IReadOnlyList<Guid>> ForgetAsync(
 29        IScopeOwnerInvitations invitations,
 30        IAuditLogWriter auditLog,
 31        ILogger logger,
 32        IReadOnlyCollection<long> personIds,
 33        DateTime now)
 34    {
 11435        if (personIds.Count == 0)
 36        {
 6137            return [];
 38        }
 39
 5340        var voided = await invitations.ForgetPersonsAsync(personIds, now);
 41
 13242        foreach (var invitationId in voided)
 43        {
 44            try
 45            {
 1346                await auditLog.WriteAsync(ScopeOwnerInvitationAuditActions.Voided, invitationId, true, null);
 1347            }
 048            catch (Exception exception)
 49            {
 050                logger.LogWarning(exception, "Failed to audit the void of invitation {InvitationId}", invitationId);
 051            }
 52        }
 53
 5354        return voided;
 11455    }
 56}

Methods/Properties

ForgetAsync()