From 5942645045a3469bf53aa77b45c1feb8e27974f6 Mon Sep 17 00:00:00 2001 From: Jamie Date: Sat, 7 Apr 2018 00:26:05 +0100 Subject: [PATCH] Added the ability to send newsletter out to users that are not in Ombi --- src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs | 10 ++++++++ .../Notifications/NewsletterSettings.cs | 5 +++- .../app/interfaces/INotificationSettings.ts | 1 + .../notifications/newsletter.component.html | 25 +++++++++++++++++++ .../notifications/newsletter.component.ts | 21 ++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs index 31138e012..1a8b21fbd 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using MailKit; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Ombi.Api.TheMovieDb; @@ -120,6 +121,15 @@ namespace Ombi.Schedule.Jobs.Ombi { return; } + + foreach (var emails in settings.ExternalEmails) + { + users.Add(new OmbiUser + { + UserName = emails, + Email = emails + }); + } var emailTasks = new List(); foreach (var user in users) { diff --git a/src/Ombi.Settings/Settings/Models/Notifications/NewsletterSettings.cs b/src/Ombi.Settings/Settings/Models/Notifications/NewsletterSettings.cs index 0fed1418e..f043cd74c 100644 --- a/src/Ombi.Settings/Settings/Models/Notifications/NewsletterSettings.cs +++ b/src/Ombi.Settings/Settings/Models/Notifications/NewsletterSettings.cs @@ -1,9 +1,12 @@ -namespace Ombi.Settings.Settings.Models.Notifications +using System.Collections.Generic; + +namespace Ombi.Settings.Settings.Models.Notifications { public class NewsletterSettings : Settings { public bool DisableTv { get; set; } public bool DisableMovies { get; set; } public bool Enabled { get; set; } + public List ExternalEmails { get; set; } } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts b/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts index 5105ef13c..da1e147da 100644 --- a/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/INotificationSettings.ts @@ -59,6 +59,7 @@ export interface INewsletterNotificationSettings extends INotificationSettings { notificationTemplate: INotificationTemplates; disableMovies: boolean; disableTv: boolean; + externalEmails: string[]; } export interface ITelegramNotifcationSettings extends INotificationSettings { diff --git a/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.html b/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.html index b2c9ea179..0a7c27b64 100644 --- a/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.html +++ b/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.html @@ -53,6 +53,31 @@
When testing, the test newsletter will go to all users that have the Admin role, please ensure that there are valid email addresses for this. The test will also only grab the latest 10 movies and 10 shows just to give you an example. +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ {{email}} +
+
+ +
+
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.ts b/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.ts index 460c54955..fda23208f 100644 --- a/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.ts +++ b/src/Ombi/ClientApp/app/settings/notifications/newsletter.component.ts @@ -11,6 +11,7 @@ export class NewsletterComponent implements OnInit { public NotificationType = NotificationType; public settings: INewsletterNotificationSettings; + public emailToAdd: string; constructor(private settingsService: SettingsService, private notificationService: NotificationService, @@ -48,4 +49,24 @@ export class NewsletterComponent implements OnInit { }); } + public addEmail() { + + if(this.emailToAdd) { + const emailRegex = "[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}"; + const match = this.emailToAdd.match(emailRegex)!; + if(match && match.length > 0) { + this.settings.externalEmails.push(this.emailToAdd); + this.emailToAdd = ""; + } else{ + this.notificationService.error("Please enter a valid email address") + } + } + } + + public deleteEmail(email: string) { + var index = this.settings.externalEmails.indexOf(email); // <-- Not supported in