Added the 'enable user notifications' to the email settings view and model.

pull/193/head
tidusjar 9 years ago
parent 83bbd3fd88
commit 54ab4854e6

@ -1,14 +1,41 @@
namespace PlexRequests.Core.SettingModels
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: EmailNotificationSettings.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
namespace PlexRequests.Core.SettingModels
{
public class EmailNotificationSettings : Settings
{
public string EmailHost { get; set; }
public string EmailPassword { get; set; }
public int EmailPort { get; set; }
public bool Ssl { get; set; }
public string RecipientEmail { get; set; }
public string EmailSender { get; set; }
public string EmailUsername { get; set; }
public string EmailPassword { get; set; }
public bool Enabled { get; set; }
public bool EnableUserEmailNotifications { get; set; }
public string RecipientEmail { get; set; }
public bool Ssl { get; set; }
}
}

@ -163,10 +163,10 @@ namespace PlexRequests.UI.Modules
private Response ProcessMovies(MovieSearchType searchType, string searchTerm)
{
List<Task> taskList = new List<Task>();
var taskList = new List<Task>();
List<MovieResult> apiMovies = new List<MovieResult>();
taskList.Add(Task.Factory.StartNew<List<MovieResult>>(() =>
var apiMovies = new List<MovieResult>();
taskList.Add(Task.Factory.StartNew(() =>
{
switch(searchType)
{
@ -212,13 +212,13 @@ namespace PlexRequests.UI.Modules
Task.WaitAll(taskList.ToArray());
int[] cpCached = CpCacher.QueuedIds();
var cpCached = CpCacher.QueuedIds();
var plexMovies = Checker.GetPlexMovies();
List<SearchMovieViewModel> viewMovies = new List<SearchMovieViewModel>();
var viewMovies = new List<SearchMovieViewModel>();
foreach (MovieResult movie in apiMovies)
{
var viewMovie = new SearchMovieViewModel()
var viewMovie = new SearchMovieViewModel
{
Adult = movie.Adult,
BackdropPath = movie.BackdropPath,
@ -293,8 +293,8 @@ namespace PlexRequests.UI.Modules
return Response.AsJson("");
}
int[] sonarrCached = SonarrCacher.QueuedIds();
int[] sickRageCache = SickRageCacher.QueuedIds(); // consider just merging sonarr/sickrage arrays
var sonarrCached = SonarrCacher.QueuedIds();
var sickRageCache = SickRageCacher.QueuedIds(); // consider just merging sonarr/sickrage arrays
var plexTvShows = Checker.GetPlexTvShows();
var viewTv = new List<SearchTvShowViewModel>();
@ -322,7 +322,7 @@ namespace PlexRequests.UI.Modules
{
viewT.Available = true;
}
else if (t.show.externals.thetvdb != null)
else if (t.show?.externals?.thetvdb != null)
{
int tvdbid = (int)t.show.externals.thetvdb;
@ -350,9 +350,9 @@ namespace PlexRequests.UI.Modules
private Response SearchMusic(string searchTerm)
{
List<Task> taskList = new List<Task>();
var taskList = new List<Task>();
List<Release> apiAlbums = new List<Release>();
var apiAlbums = new List<Release>();
taskList.Add(Task.Factory.StartNew(() =>
{
return MusicBrainzApi.SearchAlbum(searchTerm);
@ -362,7 +362,7 @@ namespace PlexRequests.UI.Modules
apiAlbums = t.Result.releases ?? new List<Release>();
}));
Dictionary<string, RequestedModel> dbAlbum = new Dictionary<string, RequestedModel>();
var dbAlbum = new Dictionary<string, RequestedModel>();
taskList.Add(Task.Factory.StartNew(() =>
{
return RequestService.GetAll().Where(x => x.Type == RequestType.Album);
@ -486,7 +486,7 @@ namespace PlexRequests.UI.Modules
if (result)
{
model.Approved = true;
Log.Debug("Adding movie to database requests (No approval required)");
Log.Info("Adding movie to database (No approval required)");
RequestService.AddRequest(model);
var notificationModel = new NotificationModel
@ -511,7 +511,7 @@ namespace PlexRequests.UI.Modules
else
{
model.Approved = true;
Log.Debug("Adding movie to database requests (No approval required)");
Log.Info("Adding movie to database (No approval required)");
RequestService.AddRequest(model);
var notificationModel = new NotificationModel
@ -529,7 +529,7 @@ namespace PlexRequests.UI.Modules
try
{
Log.Debug("Adding movie to database requests");
Log.Info("Adding movie to database");
var id = RequestService.AddRequest(model);
var notificationModel = new NotificationModel { Title = model.Title, User = Username, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };

@ -45,7 +45,22 @@
</div>
</div>
<div class="form-group">
<label for="EmailHost" class="control-label">SMTP Hostname or IP</label>
<div class="checkbox">
<label>
@if (Model.EnableUserEmailNotifications)
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications" checked="checked"><text>Enable user email notifications</text>
}
else
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications"><text>Enable user email notifications</text>
}
</label>
</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">
<label for="EmailHost" class="control-label">SMTP Host name or IP</label>
<div class="">
<input type="text" class="form-control form-control-custom " id="EmailHost" name="EmailHost" placeholder="localhost" value="@Model.EmailHost">
</div>

Loading…
Cancel
Save