From 4c9fcf754ccf13f77dbdd25e2048078a56864efb Mon Sep 17 00:00:00 2001 From: Mia Winter Date: Mon, 26 Feb 2024 13:23:31 +0100 Subject: [PATCH] Added option to publish Articles silently, without newsletter distribution --- Wave/Components/Pages/ArticleView.razor | 20 +++++++++++++++++-- .../Components/Pages/ArticleView.de-DE.resx | 3 +++ .../Components/Pages/ArticleView.resx | 9 ++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Wave/Components/Pages/ArticleView.razor b/Wave/Components/Pages/ArticleView.razor index 10e647a..653f58d 100644 --- a/Wave/Components/Pages/ArticleView.razor +++ b/Wave/Components/Pages/ArticleView.razor @@ -63,6 +63,14 @@
+ @if (Features.Value.EmailSubscriptions) { +
+ +
+ } } @@ -108,6 +116,9 @@ #endregion private Article? Article { get; set; } + [Parameter, SupplyParameterFromForm(FormName = "submit-for-publish")] + public bool PublishSilently { get; set; } + [CascadingParameter] public HttpContext HttpContext { get; set; } = default!; @@ -221,7 +232,7 @@ context.Update(Article); await context.SaveChangesAsync(); - if (Features.Value.EmailSubscriptions) { + if (!PublishSilently && Features.Value.EmailSubscriptions) { try { var newsletter = new EmailNewsletter { Article = Article, @@ -238,6 +249,11 @@ await EmailService.ConnectAsync(CancellationToken.None); var author = Article.Author; + string publishMessage = + Article.PublishDate >= DateTimeOffset.Now ? + "Is is now publicly available." : + $"It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}."; + var email = await Email.CreateDefaultEmail( author.Email!, author.Name, @@ -246,7 +262,7 @@ $"

The Article '{Article.Title}' has been checked and approved by a reviewer.

" + $"

It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}.

", $"The Article '{Article.Title}' has been checked and approved by a reviewer. " + - $"It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}."); + publishMessage); // TODO check if they enabled email notifications (property currently not implemented) await EmailService.SendEmailAsync(email); diff --git a/Wave/Resources/Components/Pages/ArticleView.de-DE.resx b/Wave/Resources/Components/Pages/ArticleView.de-DE.resx index 736af07..267b839 100644 --- a/Wave/Resources/Components/Pages/ArticleView.de-DE.resx +++ b/Wave/Resources/Components/Pages/ArticleView.de-DE.resx @@ -134,4 +134,7 @@ Enge Leseansicht umschalten + + Ohne E-Mail Veröffentlichen + \ No newline at end of file diff --git a/Wave/Resources/Components/Pages/ArticleView.resx b/Wave/Resources/Components/Pages/ArticleView.resx index 7eccdbb..d34586b 100644 --- a/Wave/Resources/Components/Pages/ArticleView.resx +++ b/Wave/Resources/Components/Pages/ArticleView.resx @@ -122,9 +122,9 @@ Submit for Review - - Approv for Publishing - + + Approve for Publishing + {1} Continue reading on {0}. @@ -134,4 +134,7 @@ Toggle narrow reading view + + Publish without Email + \ No newline at end of file