< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.WebApi.Email.MailgunRegistrationLinkSender
Assembly: ArturRios.Heimdall.WebApi
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Email/MailgunRegistrationLinkSender.cs
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 45
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage
100%
Covered methods: 3
Fully covered methods: 3
Total methods: 3
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Purpose()100%11100%
SendAsync(...)100%44100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Email/MailgunRegistrationLinkSender.cs

#LineLine coverage
 1using ArturRios.Heimdall.Command.Services;
 2using ArturRios.Messaging.Email;
 3
 4namespace ArturRios.Heimdall.WebApi.Email;
 5
 6/// <summary>
 7///     Delivers UC-47's registration link through Mailgun. It tells the registrant that the link alone
 8///     finishes nothing: the password chosen at sign-up must accompany it. A failure is logged by
 9///     <see cref="MailgunSender" /> and never propagated.
 10/// </summary>
 11public class MailgunRegistrationLinkSender(
 12    IEmailService emailService,
 13    EmailDeliveryOptions options,
 14    ILogger<MailgunRegistrationLinkSender> logger)
 415    : MailgunSender(emailService, logger), IRegistrationLinkSender
 16{
 17    private const string Subject = "Finish creating your account";
 18
 419    protected override string Purpose => "registration link";
 20
 21    public Task SendAsync(string email, string token, string? linkBase)
 22    {
 23        // The scope's own link wins; without one the deployment-wide setting applies.
 424        var link = EmailDeliveryOptions.BuildLink(
 425            string.IsNullOrWhiteSpace(linkBase) ? options.VerificationUrl : linkBase, token);
 26
 427        var body = string.IsNullOrEmpty(link)
 428            ? $"""
 429               Someone asked to create an account with this address.
 430
 431               Use this token, with the password you chose when you signed up: {token}
 432
 433               If you did not ask for this, ignore this email. No account is created unless the link is used with that p
 434               """
 435            : $"""
 436               Someone asked to create an account with this address.
 437
 438               To finish, open this link and enter the password you chose when you signed up: {link}
 439
 440               If you did not ask for this, ignore this email. No account is created unless the link is used with that p
 441               """;
 42
 443        return DeliverAsync(email, Subject, body);
 44    }
 45}