Some general improvements

pull/1011/head
tidusjar 8 years ago
parent a8dd6905fd
commit a1eb944f83

@ -34,7 +34,6 @@ namespace Ombi.Core.SettingModels
public string EmailSender { get; set; } public string EmailSender { get; set; }
public string EmailUsername { get; set; } public string EmailUsername { get; set; }
public bool Authentication { get; set; } public bool Authentication { get; set; }
public bool EnableUserEmailNotifications { get; set; }
public string RecipientEmail { get; set; } public string RecipientEmail { get; set; }
} }
} }

@ -66,7 +66,15 @@ namespace Ombi.Services.Jobs
var movies = RadarrApi.GetMovies(settings.ApiKey, settings.FullUri); var movies = RadarrApi.GetMovies(settings.ApiKey, settings.FullUri);
if (movies != null) if (movies != null)
{ {
var movieIds = movies.Select(x => x.tmdbId).ToList(); var movieIds = new List<int>();
foreach (var m in movies)
{
if (m.tmdbId > 0)
{
movieIds.Add(m.tmdbId);
}
}
//var movieIds = movies.Select(x => x.tmdbId).ToList();
Cache.Set(CacheKeys.RadarrMovies, movieIds, CacheKeys.TimeFrameMinutes.SchedulerCaching); Cache.Set(CacheKeys.RadarrMovies, movieIds, CacheKeys.TimeFrameMinutes.SchedulerCaching);
} }
} }

@ -119,14 +119,6 @@ namespace Ombi.Services.Notification
return false; return false;
} }
if (!settings.EnableUserEmailNotifications)
{
if (!settings.Enabled)
{
return false;
}
}
return true; return true;
} }
@ -237,10 +229,6 @@ namespace Ombi.Services.Notification
private async Task EmailAvailableRequest(NotificationModel model, EmailNotificationSettings settings) private async Task EmailAvailableRequest(NotificationModel model, EmailNotificationSettings settings)
{ {
if (!settings.EnableUserEmailNotifications)
{
await Task.FromResult(false);
}
var email = new EmailBasicTemplate(); var email = new EmailBasicTemplate();
var html = email.LoadTemplate( var html = email.LoadTemplate(
$"Ombi: {model.Title} is now available!", $"Ombi: {model.Title} is now available!",

@ -211,8 +211,8 @@ namespace Ombi.UI.Modules.Admin
Get["/headphones"] = _ => Headphones(); Get["/headphones"] = _ => Headphones();
Post["/headphones"] = _ => SaveHeadphones(); Post["/headphones"] = _ => SaveHeadphones();
Get["/newsletter"] = _ => Newsletter(); Get["/newsletter", true] = async (x, ct) => await Newsletter();
Post["/newsletter"] = _ => SaveNewsletter(); Post["/newsletter", true] = async (x, ct) => await SaveNewsletter();
Post["/createapikey"] = x => CreateApiKey(); Post["/createapikey"] = x => CreateApiKey();
@ -845,13 +845,13 @@ namespace Ombi.UI.Modules.Admin
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." }); : new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
} }
private Negotiator Newsletter() private async Task<Negotiator> Newsletter()
{ {
var settings = NewsLetterService.GetSettings(); var settings = await NewsLetterService.GetSettingsAsync();
return View["NewsletterSettings", settings]; return View["NewsletterSettings", settings];
} }
private Response SaveNewsletter() private async Task<Response> SaveNewsletter()
{ {
var settings = this.Bind<NewletterSettings>(); var settings = this.Bind<NewletterSettings>();
@ -859,9 +859,17 @@ namespace Ombi.UI.Modules.Admin
if (!valid.IsValid) if (!valid.IsValid)
{ {
var error = valid.SendJsonError(); var error = valid.SendJsonError();
Log.Info("Error validating Headphones settings, message: {0}", error.Message); Log.Info("Error validating Newsletter settings, message: {0}", error.Message);
return Response.AsJson(error); return Response.AsJson(error);
} }
// Make sure emails are setup
var emailSettings = await EmailService.GetSettingsAsync();
if (!emailSettings.Enabled)
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Please enable your email notifications" });
}
settings.SendRecentlyAddedEmail = settings.SendRecentlyAddedEmail; settings.SendRecentlyAddedEmail = settings.SendRecentlyAddedEmail;
var result = NewsLetterService.SaveSettings(settings); var result = NewsLetterService.SaveSettings(settings);

@ -31,20 +31,7 @@
</div> </div>
</div> </div>
<div class="form-group">
<div class="checkbox">
@if (Model.EnableUserEmailNotifications)
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications" checked="checked"><label for="EnableUserEmailNotifications">Enable user email notifications</label>
}
else
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications"><label for="EnableUserEmailNotifications">Enable user email notifications</label>
}
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@ -59,7 +46,7 @@
</div> </div>
</div> </div>
<small>Please note that if user notifications is enabled, the email will get sent with the SMTP set-up below.</small>
<div class="form-group"> <div class="form-group">
<label for="EmailHost" class="control-label">SMTP Host name or IP</label> <label for="EmailHost" class="control-label">SMTP Host name or IP</label>
<div class=""> <div class="">
@ -82,12 +69,15 @@
<input type="text" class="form-control form-control-custom " id="EmailSender" name="EmailSender" value="@Model.EmailSender"> <input type="text" class="form-control form-control-custom " id="EmailSender" name="EmailSender" value="@Model.EmailSender">
</div> </div>
</div> </div>
<small>The sender is who the email will be sent from, this can be for any email including user notification emails (if that is enabled).</small>
<div class="form-group"> <div class="form-group">
<label for="RecipientEmail" class="control-label">Email Recipient</label> <label for="RecipientEmail" class="control-label">Email Recipient</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="RecipientEmail" name="RecipientEmail" value="@Model.RecipientEmail"> <input type="text" class="form-control form-control-custom " id="RecipientEmail" name="RecipientEmail" value="@Model.RecipientEmail">
</div> </div>
</div> </div>
<small>The recipient email is used for emails going to the administrator.</small>

@ -16,35 +16,20 @@
<br /> <br />
@if (Model.SendRecentlyAddedEmail) @if (Model.SendRecentlyAddedEmail)
{ {
<input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail" checked="checked"><label for="SendRecentlyAddedEmail">Enable the newsletter of recently added content</label> <input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail" checked="checked"><label for="SendRecentlyAddedEmail">Enable newsletter</label>
} }
else else
{ {
<input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail"><label for="SendRecentlyAddedEmail">Enable the newsletter of recently added content</label> <input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail"><label for="SendRecentlyAddedEmail">Enable newslette</label>
} }
</div> </div>
</div> </div>
<div class="form-group">
<div class="checkbox">
@if (Model.SendToPlexUsers)
{
<input type="checkbox" id="SendToPlexUsers" name="SendToPlexUsers" checked="checked"><label for="SendToPlexUsers">Send to all of your Plex 'Friends'</label>
}
else
{
<input type="checkbox" id="SendToPlexUsers" name="SendToPlexUsers"><label for="SendToPlexUsers">Send to all of your Plex 'Friends'</label>
}
</div>
</div>
<div class="form-group"> <div class="form-group">
<br> <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 Plex Friends)</label>
<small>You can add multiple email address by using the ; delimiter</small> <small>You can add multiple email address 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">

@ -40,7 +40,6 @@
</div> </div>
</div> </div>
@Html.Checkbox(Model.Settings.NewSearch, "NewSearch", "Use New Search")
<div class="form-group"> <div class="form-group">
<label for="lang" class="control-label">Default Language</label> <label for="lang" class="control-label">Default Language</label>
@ -105,6 +104,7 @@
</div> </div>
</div> </div>
@Html.Checkbox(Model.Settings.NewSearch, "NewSearch", "Use New Search")
<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">Submit</button>

Loading…
Cancel
Save