Example #1
0
    public async Task SendCommentReplyNotificationAsync(CommentReplyPayload request)
    {
        _logger.LogInformation("Sending AdminReplyNotification mail");

        SetEmailInfo();

        var pipeline = new TemplatePipeline().Map(nameof(request.ReplyContentHtml), request.ReplyContentHtml)
                       .Map("RouteLink", request.PostLink)
                       .Map("PostTitle", request.Title)
                       .Map(nameof(request.CommentContent), request.CommentContent);

        await EmailHelper.ApplyTemplate(MailMesageTypes.AdminReplyNotification.ToString(), pipeline)
        .SendMailAsync(request.Email);
    }
Example #2
0
    public async Task Handle(CommentReplyNotification notification, CancellationToken cancellationToken)
    {
        var payload = new CommentReplyPayload(
            notification.Email,
            notification.CommentContent,
            notification.Title,
            notification.ReplyContentHtml,
            notification.PostLink);

        var response = await _client.SendNotification(MailMesageTypes.AdminReplyNotification, payload);

        var respBody = await response.Content.ReadAsStringAsync(cancellationToken);

        if (response.IsSuccessStatusCode)
        {
            _logger.LogInformation($"Test email is sent, server response: '{respBody}'");
        }
        else
        {
            throw new($"Test email sending failed, response code: '{response.StatusCode}', response body: '{respBody}'");
        }
    }