Added option to publish Articles silently, without newsletter distribution
This commit is contained in:
parent
b8373c6e8e
commit
4c9fcf754c
|
@ -63,6 +63,14 @@
|
||||||
<form @formname="submit-for-publish" method="post" @onsubmit="SubmitForPublish" class="max-sm:w-full">
|
<form @formname="submit-for-publish" method="post" @onsubmit="SubmitForPublish" class="max-sm:w-full">
|
||||||
<AntiforgeryToken />
|
<AntiforgeryToken />
|
||||||
<button type="submit" class="btn btn-primary w-full sm:btn-wide">@Localizer["Publish_Submit"]</button>
|
<button type="submit" class="btn btn-primary w-full sm:btn-wide">@Localizer["Publish_Submit"]</button>
|
||||||
|
@if (Features.Value.EmailSubscriptions) {
|
||||||
|
<div class="form-control">
|
||||||
|
<label class="label cursor-pointer">
|
||||||
|
<span class="label-text">@Localizer["Publish_Silent_Label"]</span>
|
||||||
|
<InputCheckbox @bind-Value="PublishSilently" class="checkbox" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -108,6 +116,9 @@
|
||||||
#endregion
|
#endregion
|
||||||
private Article? Article { get; set; }
|
private Article? Article { get; set; }
|
||||||
|
|
||||||
|
[Parameter, SupplyParameterFromForm(FormName = "submit-for-publish")]
|
||||||
|
public bool PublishSilently { get; set; }
|
||||||
|
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
public HttpContext HttpContext { get; set; } = default!;
|
public HttpContext HttpContext { get; set; } = default!;
|
||||||
|
|
||||||
|
@ -221,7 +232,7 @@
|
||||||
context.Update(Article);
|
context.Update(Article);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
if (Features.Value.EmailSubscriptions) {
|
if (!PublishSilently && Features.Value.EmailSubscriptions) {
|
||||||
try {
|
try {
|
||||||
var newsletter = new EmailNewsletter {
|
var newsletter = new EmailNewsletter {
|
||||||
Article = Article,
|
Article = Article,
|
||||||
|
@ -238,6 +249,11 @@
|
||||||
await EmailService.ConnectAsync(CancellationToken.None);
|
await EmailService.ConnectAsync(CancellationToken.None);
|
||||||
var author = Article.Author;
|
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(
|
var email = await Email.CreateDefaultEmail(
|
||||||
author.Email!,
|
author.Email!,
|
||||||
author.Name,
|
author.Name,
|
||||||
|
@ -246,7 +262,7 @@
|
||||||
$"<p>The Article '{Article.Title}' has been checked and approved by a reviewer.</p>" +
|
$"<p>The Article '{Article.Title}' has been checked and approved by a reviewer.</p>" +
|
||||||
$"<p>It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}.</p>",
|
$"<p>It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}.</p>",
|
||||||
$"The Article '{Article.Title}' has been checked and approved by a reviewer. " +
|
$"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)
|
// TODO check if they enabled email notifications (property currently not implemented)
|
||||||
await EmailService.SendEmailAsync(email);
|
await EmailService.SendEmailAsync(email);
|
||||||
|
|
||||||
|
|
|
@ -134,4 +134,7 @@
|
||||||
<data name="ToggleReader_Label" xml:space="preserve">
|
<data name="ToggleReader_Label" xml:space="preserve">
|
||||||
<value>Enge Leseansicht umschalten</value>
|
<value>Enge Leseansicht umschalten</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Publish_Silent_Label" xml:space="preserve">
|
||||||
|
<value>Ohne E-Mail Veröffentlichen</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -123,7 +123,7 @@
|
||||||
<value>Submit for Review</value>
|
<value>Submit for Review</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Publish_Submit" xml:space="preserve">
|
<data name="Publish_Submit" xml:space="preserve">
|
||||||
<value>Approv for Publishing</value>
|
<value>Approve for Publishing</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Meta_Description" xml:space="preserve">
|
<data name="Meta_Description" xml:space="preserve">
|
||||||
<value>{1} Continue reading on {0}. </value>
|
<value>{1} Continue reading on {0}. </value>
|
||||||
|
@ -134,4 +134,7 @@
|
||||||
<data name="ToggleReader_Label" xml:space="preserve">
|
<data name="ToggleReader_Label" xml:space="preserve">
|
||||||
<value>Toggle narrow reading view</value>
|
<value>Toggle narrow reading view</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Publish_Silent_Label" xml:space="preserve">
|
||||||
|
<value>Publish without Email</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in a new issue