< Summary

Information
Class: Syki.Daemon.Emails.EmailsService
Assembly: Daemon
File(s): /home/runner/work/syki/syki/Daemon/Emails/EmailsService.cs
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 82
Coverable lines: 82
Total lines: 106
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
SendResetPasswordEmail()0%620%
SendUserRegisterEmailConfirmation()0%620%
GetContent(...)100%210%

File(s)

/home/runner/work/syki/syki/Daemon/Emails/EmailsService.cs

#LineLine coverage
 1using Syki.Daemon.Settings;
 2
 3namespace Syki.Daemon.Emails;
 4
 5public class EmailsService : IEmailsService
 6{
 7    private readonly HttpClient _client;
 8    private readonly EmailSettings _settings;
 09    public EmailsService(EmailSettings settings)
 10    {
 011        _settings = settings;
 012        _client = new HttpClient { BaseAddress = new Uri(settings.ApiUrl) };
 013        _client.DefaultRequestHeaders.Add("api-key", settings.ApiKey);
 014    }
 15
 16    public async Task SendResetPasswordEmail(string to, string token)
 17    {
 018    if (to.Contains("@syki")) return;
 19
 020        var link = $"{_settings.FrontUrl}/reset-password?token={token}";
 021        var body = new BrevoEmailMessage(
 022            sender: "syki@zaqbit.com",
 023            to: to,
 024            subject: "Syki - Redefinição de senha",
 025            content: GetContent("Redefinição de senha", "Para redefinir sua senha, clique no botão abaixo e siga as inst
 026        );
 27
 028        await _client.PostAsJsonAsync("", body);
 029    }
 30
 31    public async Task SendUserRegisterEmailConfirmation(string to, string token)
 32    {
 033    if (to.Contains("@syki")) return;
 34
 035        var link = $"{_settings.FrontUrl}/register-setup?token={token}";
 036        var body = new BrevoEmailMessage(
 037            sender: "syki@zaqbit.com",
 038            to: to,
 039            subject: "Syki - Cadastro",
 040            content: GetContent("Cadastro", "Para finalizar seu cadastro, clique no botão abaixo e siga as instruções.",
 041        );
 42
 043        await _client.PostAsJsonAsync("", body);
 044    }
 45
 46  private string GetContent(string title, string description, string button, string link)
 47  {
 048    return """
 049      <!doctype html>
 050      <html lang="pt-BR">
 051      <head>
 052        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
 053      </head>
 054      <body marginheight="0" topmargin="0" marginwidth="0" style="margin: 0px; background-color: #f2f3f8;" leftmargin="0
 055        <table cellspacing="0" border="0" cellpadding="0" width="100%" bgcolor="#f2f3f8"
 056          style="@import url(https://fonts.googleapis.com/css?family=Rubik:300,400,500,700|Open+Sans:300,400,600,700); f
 057          <tr>
 058            <td>
 059              <table style="background-color: #f2f3f8; max-width:670px;  margin:0 auto;" width="100%" border="0" align="
 060                <tr>
 061                  <td style="height:80px;">&nbsp;</td>
 062                </tr>
 063                <tr>
 064                  <td>
 065                    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"
 066                      style="max-width:670px;background:#fff; border-radius:3px; text-align:center;-webkit-box-shadow:0 
 067                      <tr>
 068                        <td style="height:40px;">&nbsp;</td>
 069                      </tr>
 070                      <tr>
 071                        <td style="padding:0 35px;">
 072                          <h1 style="color:#1e1e2d; font-weight:500; margin:0;font-size:32px;font-family:'Rubik',sans-se
 073                            SykiTitle</h1>
 074                          <span
 075                            style="display:inline-block; vertical-align:middle; margin:29px 0 26px; border-bottom:1px so
 076                          <p style="color:#455056; font-size:15px;line-height:24px; margin:0;">
 077                            SykiDescription
 078                          </p>
 079                          <a href="SykiFrontendLink"
 080                            style="background:#4caf50;text-decoration:none !important; font-weight:500; margin-top:35px;
 081                            SykiButton
 082                          </a>
 083                        </td>
 084                      </tr>
 085                      <tr>
 086                        <td style="height:40px;">&nbsp;</td>
 087                      </tr>
 088                    </table>
 089                  </td>
 090                </tr>
 091                <tr>
 092                  <td style="height:80px;">&nbsp;</td>
 093                </tr>
 094              </table>
 095            </td>
 096          </tr>
 097        </table>
 098      </body>
 099      </html>
 0100    """
 0101        .Replace("SykiTitle", title)
 0102        .Replace("SykiDescription", description)
 0103        .Replace("SykiButton", button)
 0104        .Replace("SykiFrontendLink", link);
 105  }
 106}