#387 trim the spaces from the api key. Tidied up the setting models a bit.

This commit is contained in:
tidusjar 2016-07-20 10:08:44 +01:00
parent c5ad97780f
commit 6392ee0bde
18 changed files with 287 additions and 297 deletions

View file

@ -81,6 +81,7 @@
<Compile Include="Models\StatusModel.cs" /> <Compile Include="Models\StatusModel.cs" />
<Compile Include="Models\UserProperties.cs" /> <Compile Include="Models\UserProperties.cs" />
<Compile Include="SettingModels\AuthenticationSettings.cs" /> <Compile Include="SettingModels\AuthenticationSettings.cs" />
<Compile Include="SettingModels\ExternalSettings.cs" />
<Compile Include="SettingModels\HeadphonesSettings.cs" /> <Compile Include="SettingModels\HeadphonesSettings.cs" />
<Compile Include="SettingModels\LandingPageSettings.cs" /> <Compile Include="SettingModels\LandingPageSettings.cs" />
<Compile Include="SettingModels\NotificationSettings.cs" /> <Compile Include="SettingModels\NotificationSettings.cs" />

View file

@ -31,10 +31,11 @@ using Newtonsoft.Json;
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class AuthenticationSettings : Settings public sealed class AuthenticationSettings : Settings
{ {
public bool UserAuthentication { get; set; } public bool UserAuthentication { get; set; }
public bool UsePassword { get; set; } public bool UsePassword { get; set; }
[JsonProperty("PlexAuthToken")] [JsonProperty("PlexAuthToken")]
[Obsolete("This should be migrated over into the Plex Settings and then removed in the next release")] [Obsolete("This should be migrated over into the Plex Settings and then removed in the next release")]
public string OldPlexAuthToken { get; set; } public string OldPlexAuthToken { get; set; }

View file

@ -24,38 +24,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
using System;
using Newtonsoft.Json;
using PlexRequests.Helpers;
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class CouchPotatoSettings : Settings public sealed class CouchPotatoSettings : ExternalSettings
{ {
public bool Enabled { get; set; } public bool Enabled { get; set; }
public string Ip { get; set; }
public int Port { get; set; }
public string ApiKey { get; set; } public string ApiKey { get; set; }
public bool Ssl { get; set; }
public string ProfileId { get; set; } public string ProfileId { get; set; }
public string SubDir { get; set; }
public string Username { get; set; } public string Username { get; set; }
public string Password { get; set; } public string Password { get; set; }
[JsonIgnore]
public Uri FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}
}
} }
} }

View file

@ -26,7 +26,7 @@
#endregion #endregion
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class EmailNotificationSettings : NotificationSettings public sealed class EmailNotificationSettings : NotificationSettings
{ {
public string EmailHost { get; set; } public string EmailHost { get; set; }
public string EmailPassword { get; set; } public string EmailPassword { get; set; }

View file

@ -0,0 +1,57 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: ExternalSettings.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
using System;
using Newtonsoft.Json;
using PlexRequests.Helpers;
namespace PlexRequests.Core.SettingModels
{
public abstract class ExternalSettings : Settings
{
public bool Ssl { get; set; }
public string SubDir { get; set; }
public string Ip { get; set; }
public int Port { get; set; }
[JsonIgnore]
public virtual Uri FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}
}
}
}

View file

@ -1,58 +1,34 @@
#region Copyright #region Copyright
// /************************************************************************ // /************************************************************************
// Copyright (c) 2016 Jamie Rees // Copyright (c) 2016 Jamie Rees
// File: CouchPotatoSettings.cs // File: CouchPotatoSettings.cs
// Created By: Jamie Rees // Created By: Jamie Rees
// //
// Permission is hereby granted, free of charge, to any person obtaining // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the // a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including // "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish, // without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to // distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to // permit persons to whom the Software is furnished to do so, subject to
// the following conditions: // the following conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
namespace PlexRequests.Core.SettingModels
using System; {
using Newtonsoft.Json; public sealed class HeadphonesSettings : ExternalSettings
using PlexRequests.Helpers; {
public bool Enabled { get; set; }
namespace PlexRequests.Core.SettingModels public string ApiKey { get; set; }
{ }
public class HeadphonesSettings : Settings
{
public bool Enabled { get; set; }
public string Ip { get; set; }
public int Port { get; set; }
public string ApiKey { get; set; }
public bool Ssl { get; set; }
public string SubDir { get; set; }
[JsonIgnore]
public Uri FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}
}
}
} }

View file

@ -30,7 +30,7 @@ using Newtonsoft.Json;
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class LandingPageSettings : Settings public sealed class LandingPageSettings : Settings
{ {
public bool Enabled { get; set; } public bool Enabled { get; set; }
public bool BeforeLogin { get; set; } public bool BeforeLogin { get; set; }

View file

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

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class PlexRequestSettings : Settings public sealed class PlexRequestSettings : Settings
{ {
public PlexRequestSettings() public PlexRequestSettings()
{ {

View file

@ -24,36 +24,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
using System;
using Newtonsoft.Json;
using PlexRequests.Helpers;
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class PlexSettings : Settings public sealed class PlexSettings : ExternalSettings
{ {
public string Ip { get; set; }
public int Port { get; set; }
public bool Ssl { get; set; }
public string SubDir { get; set; }
public bool AdvancedSearch { get; set; } public bool AdvancedSearch { get; set; }
public string PlexAuthToken { get; set; } public string PlexAuthToken { get; set; }
[JsonIgnore]
public Uri FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}
}
} }
} }

View file

@ -1,9 +1,35 @@
namespace PlexRequests.Core.SettingModels #region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: PushBulletNotificationSettings.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 PushbulletNotificationSettings : NotificationSettings public sealed class PushbulletNotificationSettings : NotificationSettings
{ {
public bool Enabled { get; set; }
public string AccessToken { get; set; } public string AccessToken { get; set; }
public string DeviceIdentifier { get; set; } public string DeviceIdentifier { get; set; }
public bool Enabled { get; set; }
} }
} }

View file

@ -1,9 +1,35 @@
namespace PlexRequests.Core.SettingModels #region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: PushoverNotificationSettings.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 PushoverNotificationSettings : NotificationSettings public sealed class PushoverNotificationSettings : NotificationSettings
{ {
public bool Enabled { get; set; }
public string AccessToken { get; set; } public string AccessToken { get; set; }
public bool Enabled { get; set; }
public string UserToken { get; set; } public string UserToken { get; set; }
} }
} }

View file

@ -26,7 +26,7 @@
#endregion #endregion
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class ScheduledJobsSettings : Settings public sealed class ScheduledJobsSettings : Settings
{ {
public ScheduledJobsSettings() public ScheduledJobsSettings()
{ {

View file

@ -1,77 +1,50 @@
#region Copyright #region Copyright
// /************************************************************************ // /************************************************************************
// Copyright (c) 2016 Jamie Rees // Copyright (c) 2016 Jamie Rees
// File: SickRageSettings.cs // File: SickRageSettings.cs
// Created By: Jamie Rees // Created By: Jamie Rees
// //
// Permission is hereby granted, free of charge, to any person obtaining // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the // a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including // "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish, // without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to // distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to // permit persons to whom the Software is furnished to do so, subject to
// the following conditions: // the following conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
using System.Collections.Generic;
using System;
using Newtonsoft.Json; namespace PlexRequests.Core.SettingModels
using PlexRequests.Helpers; {
using System.Collections.Generic; public sealed class SickRageSettings : ExternalSettings
{
namespace PlexRequests.Core.SettingModels public bool Enabled { get; set; }
{ public string ApiKey { get; set; }
public class SickRageSettings : Settings public string QualityProfile { get; set; }
{
public bool Enabled { get; set; } public Dictionary<string, string> Qualities => new Dictionary<string, string>
public string Ip { get; set; } {
public int Port { get; set; } { "default", "Use Deafult" },
public string ApiKey { get; set; } { "sdtv", "SD TV" },
public string QualityProfile { get; set; } { "sddvd", "SD DVD" },
public bool Ssl { get; set; } { "hdtv", "HD TV" },
public string SubDir { get; set; } { "rawhdtv", "Raw HD TV" },
public Dictionary<string, string> Qualities { "hdwebdl", "HD Web DL" },
{ { "fullhdwebdl", "Full HD Web DL" },
get { "hdbluray", "HD Bluray" },
{ { "fullhdbluray", "Full HD Bluray" }
return new Dictionary<string, string>() { };
{ "default", "Use Deafult" }, }
{ "sdtv", "SD TV" },
{ "sddvd", "SD DVD" },
{ "hdtv", "HD TV" },
{ "rawhdtv", "Raw HD TV" },
{ "hdwebdl", "HD Web DL" },
{ "fullhdwebdl", "Full HD Web DL" },
{ "hdbluray", "HD Bluray" },
{ "fullhdbluray", "Full HD Bluray" }
};
}
}
[JsonIgnore]
public Uri FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}
}
}
} }

View file

@ -4,7 +4,7 @@ using Newtonsoft.Json;
namespace PlexRequests.Core.SettingModels namespace PlexRequests.Core.SettingModels
{ {
public class SlackNotificationSettings : NotificationSettings public sealed class SlackNotificationSettings : NotificationSettings
{ {
public bool Enabled { get; set; } public bool Enabled { get; set; }
public string WebhookUrl { get; set; } public string WebhookUrl { get; set; }

View file

@ -1,61 +1,38 @@
#region Copyright #region Copyright
// /************************************************************************ // /************************************************************************
// Copyright (c) 2016 Jamie Rees // Copyright (c) 2016 Jamie Rees
// File: SonarrSettings.cs // File: SonarrSettings.cs
// Created By: Jamie Rees // Created By: Jamie Rees
// //
// Permission is hereby granted, free of charge, to any person obtaining // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the // a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including // "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish, // without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to // distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to // permit persons to whom the Software is furnished to do so, subject to
// the following conditions: // the following conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
namespace PlexRequests.Core.SettingModels
using System; {
using Newtonsoft.Json; public sealed class SonarrSettings : ExternalSettings
using PlexRequests.Helpers; {
public bool Enabled { get; set; }
namespace PlexRequests.Core.SettingModels public string ApiKey { get; set; }
{ public string QualityProfile { get; set; }
public class SonarrSettings : Settings public bool SeasonFolders { get; set; }
{ public string RootPath { get; set; }
public bool Enabled { get; set; }
public string Ip { get; set; } }
public int Port { get; set; }
public string ApiKey { get; set; }
public string QualityProfile { get; set; }
public bool SeasonFolders { get; set; }
public string RootPath { get; set; }
public bool Ssl { get; set; }
public string SubDir { get; set; }
[JsonIgnore]
public Uri FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}
}
}
} }

View file

@ -30,7 +30,6 @@ using Newtonsoft.Json;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.Helpers; using PlexRequests.Helpers;
using PlexRequests.Store;
using PlexRequests.Store.Models; using PlexRequests.Store.Models;
using PlexRequests.Store.Repository; using PlexRequests.Store.Repository;
@ -46,8 +45,8 @@ namespace PlexRequests.Core
EntityName = typeof(T).Name; EntityName = typeof(T).Name;
} }
private ISettingsRepository Repo { get; set; } private ISettingsRepository Repo { get; }
private string EntityName { get; set; } private string EntityName { get; }
public T GetSettings() public T GetSettings()
{ {
@ -78,7 +77,7 @@ namespace PlexRequests.Core
public bool SaveSettings(T model) public bool SaveSettings(T model)
{ {
var entity = Repo.Get(EntityName); var entity = Repo.Get(EntityName);
if (entity == null) if (entity == null)
{ {
var newEntity = model; var newEntity = model;

View file

@ -171,7 +171,7 @@ namespace PlexRequests.UI.Modules
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles(); Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
Post["/cpprofiles", true] = async (x,ct) => await GetCpProfiles(); Post["/cpprofiles", true] = async (x,ct) => await GetCpProfiles();
Post["/cpapikey", true] = async (x,ct) => await GetCpApiKey(); Post["/cpapikey"] = x => GetCpApiKey();
Get["/emailnotification"] = _ => EmailNotifications(); Get["/emailnotification"] = _ => EmailNotifications();
Post["/emailnotification"] = _ => SaveEmailNotifications(); Post["/emailnotification"] = _ => SaveEmailNotifications();
@ -362,6 +362,7 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(valid.SendJsonError()); return Response.AsJson(valid.SendJsonError());
} }
couchPotatoSettings.ApiKey = couchPotatoSettings.ApiKey.Trim();
var result = CpService.SaveSettings(couchPotatoSettings); var result = CpService.SaveSettings(couchPotatoSettings);
return Response.AsJson(result return Response.AsJson(result
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for CouchPotato!" } ? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for CouchPotato!" }
@ -413,6 +414,7 @@ namespace PlexRequests.UI.Modules
{ {
return Response.AsJson(new JsonResponseModel { Result = false, Message = "SickRage is enabled, we cannot enable Sonarr and SickRage" }); return Response.AsJson(new JsonResponseModel { Result = false, Message = "SickRage is enabled, we cannot enable Sonarr and SickRage" });
} }
sonarrSettings.ApiKey = sonarrSettings.ApiKey.Trim();
var result = SonarrService.SaveSettings(sonarrSettings); var result = SonarrService.SaveSettings(sonarrSettings);
return Response.AsJson(result return Response.AsJson(result
@ -442,6 +444,7 @@ namespace PlexRequests.UI.Modules
{ {
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Sonarr is enabled, we cannot enable Sonarr and SickRage" }); return Response.AsJson(new JsonResponseModel { Result = false, Message = "Sonarr is enabled, we cannot enable Sonarr and SickRage" });
} }
sickRageSettings.ApiKey = sickRageSettings.ApiKey.Trim();
var result = SickRageService.SaveSettings(sickRageSettings); var result = SickRageService.SaveSettings(sickRageSettings);
return Response.AsJson(result return Response.AsJson(result
@ -697,7 +700,7 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(profiles); return Response.AsJson(profiles);
} }
private async Task<Response> GetCpApiKey() private Response GetCpApiKey()
{ {
var settings = this.Bind<CouchPotatoSettings>(); var settings = this.Bind<CouchPotatoSettings>();
@ -767,7 +770,7 @@ namespace PlexRequests.UI.Modules
Log.Info("Error validating Headphones settings, message: {0}", error.Message); Log.Info("Error validating Headphones settings, message: {0}", error.Message);
return Response.AsJson(error); return Response.AsJson(error);
} }
settings.ApiKey = settings.ApiKey.Trim();
var result = HeadphonesService.SaveSettings(settings); var result = HeadphonesService.SaveSettings(settings);
Log.Info("Saved headphones settings, result: {0}", result); Log.Info("Saved headphones settings, result: {0}", result);