mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
Begin Implementing Mass Email Section
This commit is contained in:
parent
0b64618438
commit
16823e2739
6 changed files with 110 additions and 18 deletions
9
Ombi.Services/Interfaces/IMassEmail.cs
Normal file
9
Ombi.Services/Interfaces/IMassEmail.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
using Quartz;
|
||||||
|
|
||||||
|
namespace Ombi.Services.Jobs
|
||||||
|
{
|
||||||
|
public interface IMassEmail
|
||||||
|
{
|
||||||
|
void MassEmailAdminTest();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ namespace Ombi.Services.Jobs
|
||||||
public interface IRecentlyAdded
|
public interface IRecentlyAdded
|
||||||
{
|
{
|
||||||
void Execute(IJobExecutionContext context);
|
void Execute(IJobExecutionContext context);
|
||||||
void Test();
|
void RecentlyAddedAdminTest();
|
||||||
void Start();
|
void Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,7 +48,7 @@ using Quartz;
|
||||||
|
|
||||||
namespace Ombi.Services.Jobs
|
namespace Ombi.Services.Jobs
|
||||||
{
|
{
|
||||||
public class RecentlyAdded : HtmlTemplateGenerator, IJob, IRecentlyAdded
|
public class RecentlyAdded : HtmlTemplateGenerator, IJob, IRecentlyAdded, IMassEmail
|
||||||
{
|
{
|
||||||
public RecentlyAdded(IPlexApi api, ISettingsService<PlexSettings> plexSettings,
|
public RecentlyAdded(IPlexApi api, ISettingsService<PlexSettings> plexSettings,
|
||||||
ISettingsService<EmailNotificationSettings> email, IJobRecord rec,
|
ISettingsService<EmailNotificationSettings> email, IJobRecord rec,
|
||||||
|
@ -105,7 +105,13 @@ namespace Ombi.Services.Jobs
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Test()
|
public void RecentlyAddedAdminTest()
|
||||||
|
{
|
||||||
|
Log.Debug("Starting Recently Added Newsletter Test");
|
||||||
|
var settings = NewsletterSettings.GetSettings();
|
||||||
|
Start(settings, true);
|
||||||
|
}
|
||||||
|
public void MassEmailAdminTest()
|
||||||
{
|
{
|
||||||
Log.Debug("Starting Test Newsletter");
|
Log.Debug("Starting Test Newsletter");
|
||||||
var settings = NewsletterSettings.GetSettings();
|
var settings = NewsletterSettings.GetSettings();
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Interfaces\IEmbyNotificationEngine.cs" />
|
<Compile Include="Interfaces\IEmbyNotificationEngine.cs" />
|
||||||
|
<Compile Include="Interfaces\IMassEmail.cs" />
|
||||||
<Compile Include="Interfaces\IPlexNotificationEngine.cs" />
|
<Compile Include="Interfaces\IPlexNotificationEngine.cs" />
|
||||||
<Compile Include="Interfaces\IRadarrCacher.cs" />
|
<Compile Include="Interfaces\IRadarrCacher.cs" />
|
||||||
<Compile Include="Interfaces\IWatcherCacher.cs" />
|
<Compile Include="Interfaces\IWatcherCacher.cs" />
|
||||||
|
|
|
@ -92,6 +92,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
private IJobRecord JobRecorder { get; }
|
private IJobRecord JobRecorder { get; }
|
||||||
private IAnalytics Analytics { get; }
|
private IAnalytics Analytics { get; }
|
||||||
private IRecentlyAdded RecentlyAdded { get; }
|
private IRecentlyAdded RecentlyAdded { get; }
|
||||||
|
private IMassEmail MassEmail { get; }
|
||||||
private ISettingsService<NotificationSettingsV2> NotifySettings { get; }
|
private ISettingsService<NotificationSettingsV2> NotifySettings { get; }
|
||||||
private ISettingsService<DiscordNotificationSettings> DiscordSettings { get; }
|
private ISettingsService<DiscordNotificationSettings> DiscordSettings { get; }
|
||||||
private IDiscordApi DiscordApi { get; }
|
private IDiscordApi DiscordApi { get; }
|
||||||
|
@ -222,6 +223,9 @@ namespace Ombi.UI.Modules.Admin
|
||||||
|
|
||||||
Get["/newsletter", true] = async (x, ct) => await Newsletter();
|
Get["/newsletter", true] = async (x, ct) => await Newsletter();
|
||||||
Post["/newsletter", true] = async (x, ct) => await SaveNewsletter();
|
Post["/newsletter", true] = async (x, ct) => await SaveNewsletter();
|
||||||
|
Post["/testnewsletteradminemail"] = x => TestNewsletterAdminEmail();
|
||||||
|
Post["/testmassadminemail"] = x => TestMassAdminEmail();
|
||||||
|
Post["/sendmassemail"] = x => SendMassEmail();
|
||||||
|
|
||||||
Post["/createapikey"] = x => CreateApiKey();
|
Post["/createapikey"] = x => CreateApiKey();
|
||||||
|
|
||||||
|
@ -246,7 +250,6 @@ namespace Ombi.UI.Modules.Admin
|
||||||
Get["/notificationsettings", true] = async (x, ct) => await NotificationSettings();
|
Get["/notificationsettings", true] = async (x, ct) => await NotificationSettings();
|
||||||
Post["/notificationsettings"] = x => SaveNotificationSettings();
|
Post["/notificationsettings"] = x => SaveNotificationSettings();
|
||||||
|
|
||||||
Post["/recentlyAddedTest"] = x => RecentlyAddedTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Negotiator> Authentication()
|
private async Task<Negotiator> Authentication()
|
||||||
|
@ -1229,13 +1232,41 @@ namespace Ombi.UI.Modules.Admin
|
||||||
var model = this.Bind<NotificationSettingsV2>();
|
var model = this.Bind<NotificationSettingsV2>();
|
||||||
return View["NotificationSettings", model];
|
return View["NotificationSettings", model];
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response RecentlyAddedTest()
|
private Response TestNewsletterAdminEmail()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.Debug("Clicked TEST");
|
Log.Debug("Clicked Admin Newsletter Email Test");
|
||||||
RecentlyAdded.Test();
|
RecentlyAdded.RecentlyAddedAdminTest();
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to administrator" });
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e);
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = e.Message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Response TestMassAdminEmail()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Log.Debug("Clicked Admin Mass Email Test");
|
||||||
|
RecentlyAdded.RecentlyAddedAdminTest();
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to administrator" });
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e);
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = e.Message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Response SendMassEmail()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Log.Debug("Clicked Send Mass Email");
|
||||||
|
RecentlyAdded.RecentlyAddedAdminTest();
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to administrator" });
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to administrator" });
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -28,17 +28,17 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<label for="CustomUsers" class="control-label">Email Addresses to Send to (For users that are not in your User Management section)</label>
|
<label for="CustomUsers" class="control-label">Email Addresses to Send to (For users that are not in your User Management section)</label>
|
||||||
<small>You can add multiple email addresses by using the ; delimiter</small>
|
<small>You can add multiple email addresses by using the ; delimiter</small>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" class="form-control form-control-custom " placeholder="first@address.com;second@address.com" id="CustomUsers" name="CustomUsers" value="@Model.CustomUsers">
|
<input type="text" class="form-control form-control-custom " placeholder="first@address.com;second@address.com" id="CustomUsers" name="CustomUsers" value="@Model.CustomUsers">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin <div id="spinner"></div></button>
|
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin <div id="testEmailSpinner"></div></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
<br />
|
<br />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" id="save" class="btn btn-primary-outline">Submit</button>
|
<button type="submit" id="save" class="btn btn-primary-outline">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Email Nofication Section -->
|
<!-- Email Nofication Section -->
|
||||||
|
@ -54,6 +54,23 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
<form id="massemail" class="form-horizontal">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Mass Email</legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="massEmailBody" class="control-label">Send mass email to all users who recieve newsletter</label>
|
||||||
|
|
||||||
|
<textarea id="massEmailBody" class="form-control" rows="5"></textarea>
|
||||||
|
<small>Supports HTML</small>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button id="sendMassEmailBtn" class="btn btn-primary-outline">Send Mass Email<div id="sendMassEmailSpinner"></div></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,8 +107,8 @@
|
||||||
$('#recentlyAddedBtn').click(function (e) {
|
$('#recentlyAddedBtn').click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var base = '@Html.GetBaseUrl()';
|
var base = '@Html.GetBaseUrl()';
|
||||||
var url = createBaseUrl(base, '/admin/recentlyAddedTest');
|
var url = createBaseUrl(base, '/admin/testnewsletteradminemail');
|
||||||
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
$('#testEmailSpinner').attr("class", "fa fa-spinner fa-spin");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
url: url,
|
url: url,
|
||||||
|
@ -99,17 +116,45 @@
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
generateNotify(response.message, "success");
|
generateNotify(response.message, "success");
|
||||||
$('#spinner').attr("class", "fa fa-check");
|
$('#testEmailSpinner').attr("class", "fa fa-check");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
generateNotify(response.message, "danger");
|
generateNotify(response.message, "danger");
|
||||||
$('#spinner').attr("class", "fa fa-times");
|
$('#testEmailSpinner').attr("class", "fa fa-times");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
generateNotify("Something went wrong!", "danger");
|
generateNotify("Something went wrong!", "danger");
|
||||||
$('#spinner').attr("class", "fa fa-times");
|
$('#testEmailSpinner').attr("class", "fa fa-times");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#sendMassEmailBtn').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var base = '@Html.GetBaseUrl()';
|
||||||
|
var url = createBaseUrl(base, '/admin/testmassadminemail');
|
||||||
|
$('#sendMassEmailSpinner').attr("class", "fa fa-spinner fa-spin");
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: url,
|
||||||
|
data: $("#massEmailBody").val(),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
if (response) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
$('#sendMassEmailSpinner').attr("class", "fa fa-check");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
generateNotify(response.message, "danger");
|
||||||
|
$('#sendMassEmailSpinner').attr("class", "fa fa-times");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
$('#sendMassEmailSpinner').attr("class", "fa fa-times");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue