Added the ability to send newsletter out to users that are not in Ombi

pull/2142/head
Jamie 7 years ago
parent 386f5b1550
commit 5942645045

@ -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<Task>();
foreach (var user in users)
{

@ -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<string> ExternalEmails { get; set; }
}
}

@ -59,6 +59,7 @@ export interface INewsletterNotificationSettings extends INotificationSettings {
notificationTemplate: INotificationTemplates;
disableMovies: boolean;
disableTv: boolean;
externalEmails: string[];
}
export interface ITelegramNotifcationSettings extends INotificationSettings {

@ -53,6 +53,31 @@
<br/>
<small>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.</small>
<br/>
<br/>
<div class="form-group row">
<div class="col-md-12">
<label for="emailToAdd" class="control-label">Add External Email (For users that are not in Ombi)</label>
</div>
<div class="col-md-9">
<input type="text" [(ngModel)]="emailToAdd" class="form-control form-control-custom " id="emailToAdd"
email name="emailToAdd" value="{{emailToAdd}}">
</div>
<div class="col-md-3">
<button class="btn btn-primary-outline" (click)="addEmail()" pTooltip="Don't forget to press the Submit button!">Add</button>
</div>
</div>
<div class="row">
<div *ngFor="let email of settings.externalEmails">
<div class="col-md-9">
{{email}}
</div>
<div class="col-md-3">
<button class="btn btn-sm btn-danger-outline" (click)="deleteEmail(email)">Delete</button>
</div>
</div>
</div>
</div>
</fieldset>
</div>

@ -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 <IE9
if (index !== -1) {
this.settings.externalEmails.splice(index, 1);
}
}
}

Loading…
Cancel
Save