public async Task SendMessage(Question question, string title, string text, string html, Message.Author author, string template = null) { html ??= text; Message message = new() { Date = DateTime.Now, MessageAuthor = author, MessageHtml = html, MessageText = text, MessageTitle = string.IsNullOrWhiteSpace(title) ? "Nachricht von " + (author == Message.Author.Answerer ? "Finn" : question.Name) : title, Question = question }; database.Messages.Add(message); if (!string.IsNullOrWhiteSpace(question.Email)) { notificationBuilder.PushForMessage(template ?? "NewMessage" + (author == Message.Author.Asker ? "Admin" : "User"), message, author == Message.Author.Asker); } await database.SaveChangesAsync(); }
public Task SendMessageMarkdown(Question question, string title, string markdown, Message.Author author, bool sanitize = true, string template = null) { string html = Markdown.ToHtml(markdown, markdownPipeline); if (sanitize) { html = sanitizer.Sanitize(html); } string text = Markdown.ToPlainText(markdown, markdownPipeline); return(SendMessage(question, title, text, html, author, template)); }