Skip to content

Commit

Permalink
Merge pull request #800 from tidusjar/EAP
Browse files Browse the repository at this point in the history
Pushing V1.10.1 release
  • Loading branch information
Magikarplvl4 authored Dec 17, 2016
2 parents 16a0324 + 485d7e9 commit f5d7c81
Show file tree
Hide file tree
Showing 35 changed files with 728 additions and 94 deletions.
3 changes: 2 additions & 1 deletion PlexRequests.Core/ISecurityExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Nancy;
using Nancy.Security;
using Nancy.Session;
using PlexRequests.Helpers.Permissions;

namespace PlexRequests.Core
Expand Down Expand Up @@ -29,6 +30,6 @@ Response HasAnyPermissionsRedirect(NancyContext context, string routeName, HttpS
/// </summary>
/// <param name="username">The username.</param>
/// <returns><c>null</c> if we cannot find a user</returns>
string GetUsername(string username);
string GetUsername(string username, ISession session);
}
}
1 change: 1 addition & 0 deletions PlexRequests.Core/IStatusChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ namespace PlexRequests.Core
public interface IStatusChecker
{
Task<StatusModel> GetStatus();
Task<Issue> ReportBug(string title, string body);
}
}
1 change: 1 addition & 0 deletions PlexRequests.Core/PlexRequests.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<Compile Include="SettingModels\ExternalSettings.cs" />
<Compile Include="SettingModels\HeadphonesSettings.cs" />
<Compile Include="SettingModels\LandingPageSettings.cs" />
<Compile Include="SettingModels\CustomizationSettings.cs" />
<Compile Include="SettingModels\NewsletterSettings.cs" />
<Compile Include="SettingModels\NotificationSettings.cs" />
<Compile Include="SettingModels\NotificationSettingsV2.cs" />
Expand Down
9 changes: 7 additions & 2 deletions PlexRequests.Core/SecurityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using Nancy.Linker;
using Nancy.Responses;
using Nancy.Security;
using Nancy.Session;
using PlexRequests.Core.Models;
using PlexRequests.Helpers;
using PlexRequests.Helpers.Permissions;
Expand Down Expand Up @@ -91,7 +92,7 @@ public bool IsNormalUser(IUserIdentity user)
/// </summary>
/// <param name="username">The username.</param>
/// <returns><c>null</c> if we cannot find a user</returns>
public string GetUsername(string username)
public string GetUsername(string username, ISession session)
{
var plexUser = PlexUsers.GetUserByUsername(username);
if (plexUser != null)
Expand Down Expand Up @@ -119,7 +120,11 @@ public string GetUsername(string username)
return dbUser.UserName;
}
}
return null;

// could be a local user
var localName = session[SessionKeys.UsernameKey];

return localName as string;
}


Expand Down
39 changes: 39 additions & 0 deletions PlexRequests.Core/SettingModels/CustomizationSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: NewsletterSettings.cs
// Created By: Jim MacKenzie
//
// 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 CustomizationSettings : Settings
{
public string ApplicationName { get; set; }

/// <summary>
/// The CSS name of the theme we want
/// </summary>
public string ThemeName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public sealed class EmailNotificationSettings : NotificationSettings
public int EmailPort { get; set; }
public string EmailSender { get; set; }
public string EmailUsername { get; set; }
public bool Enabled { get; set; }
public bool Authentication { get; set; }
public bool EnableUserEmailNotifications { get; set; }
public string RecipientEmail { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions PlexRequests.Core/SettingModels/NotificationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public NotificationSettings()
};
}


public bool Enabled { get; set; }

public List<NotificationMessage> Message { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ public sealed class PushbulletNotificationSettings : NotificationSettings
{
public string AccessToken { get; set; }
public string DeviceIdentifier { get; set; }
public bool Enabled { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace PlexRequests.Core.SettingModels
public sealed class PushoverNotificationSettings : NotificationSettings
{
public string AccessToken { get; set; }
public bool Enabled { get; set; }
public string UserToken { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace PlexRequests.Core.SettingModels
{
public sealed class SlackNotificationSettings : NotificationSettings
{
public bool Enabled { get; set; }
public string WebhookUrl { get; set; }
public string Channel { get; set; }
public string Username { get; set; }
Expand Down
11 changes: 11 additions & 0 deletions PlexRequests.Core/StatusChecker/StatusChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,16 @@ private StatusModel GetAppveyorRelease(Branches branch)

return model;
}

public async Task<Issue> ReportBug(string title, string body)
{
var issue = new NewIssue(title)
{
Body = body
};
var result = await Git.Issue.Create(Owner, RepoName, issue);

return result;
}
}
}
76 changes: 76 additions & 0 deletions PlexRequests.Helpers/OperatingSystemHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: OperatingSystemHelper.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.Helpers
{
public static class OperatingSystemHelper
{
public static string GetOs()
{
var os = System.Environment.OSVersion;
var osVersion = os.Version;
if (osVersion.Major.Equals(10))
{
return "Windows 10/Windows Server 2016";
}
if (osVersion.Major.Equals(6))
{
if (osVersion.Minor.Equals(3))
{
return "Windows 8.1/Windows Server 2012 R2";
}
if (osVersion.Minor.Equals(2))
{
return "Windows 8/Windows Server 2012";
}
if (osVersion.Minor.Equals(1))
{
return "Windows 7/Windows Server 2008 R2";
}
if (osVersion.Minor.Equals(0))
{
return "Windows Vista/Windows Server 2008";
}
}
if (osVersion.Major.Equals(5))
{
if (osVersion.Minor.Equals(2))
{
return "Windows XP 64-Bit Edition/Windows Server 2003";
}
if (osVersion.Minor.Equals(1))
{
return "Windows XP";
}
if (osVersion.Minor.Equals(0))
{
return "Windows 2000";
}
}
return os.VersionString;
}
}
}
1 change: 1 addition & 0 deletions PlexRequests.Helpers/PlexRequests.Helpers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Compile Include="LoggingHelper.cs" />
<Compile Include="MemoryCacheProvider.cs" />
<Compile Include="ObjectCopier.cs" />
<Compile Include="OperatingSystemHelper.cs" />
<Compile Include="PasswordHasher.cs" />
<Compile Include="EnumExtensions.cs" />
<Compile Include="Permissions\Features.cs" />
Expand Down
39 changes: 1 addition & 38 deletions PlexRequests.UI/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@
using Mono.Data.Sqlite;

using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Bootstrapper;
using Nancy.Bootstrappers.Ninject;
using Nancy.Conventions;
using Nancy.Cryptography;
using Nancy.Diagnostics;
using Nancy.Hosting.Self;
using Nancy.Session;

using PlexRequests.Api.Interfaces;
Expand All @@ -53,6 +51,7 @@

using Ninject;
using PlexRequests.UI.Authentication;
using Nancy.Hosting.Self;

namespace PlexRequests.UI
{
Expand Down Expand Up @@ -105,9 +104,6 @@ protected override void ApplicationStartup(IKernel container, IPipelines pipelin
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => true;

SubscribeAllObservers(container);

}

#if DEBUG
Expand Down Expand Up @@ -142,39 +138,6 @@ protected override void ConfigureConventions(NancyConventions nancyConventions)

protected override DiagnosticsConfiguration DiagnosticsConfiguration => new DiagnosticsConfiguration { Password = @"password" };

private void SubscribeAllObservers(IKernel container)
{
var notificationService = container.Get<INotificationService>();

var emailSettingsService = container.Get<ISettingsService<EmailNotificationSettings>>();
var emailSettings = emailSettingsService.GetSettings();
if (emailSettings.Enabled)
{
notificationService.Subscribe(new EmailMessageNotification(emailSettingsService));
}

var pushbulletService = container.Get<ISettingsService<PushbulletNotificationSettings>>();
var pushbulletSettings = pushbulletService.GetSettings();
if (pushbulletSettings.Enabled)
{
notificationService.Subscribe(new PushbulletNotification(container.Get<IPushbulletApi>(), pushbulletService));
}

var pushoverService = container.Get<ISettingsService<PushoverNotificationSettings>>();
var pushoverSettings = pushoverService.GetSettings();
if (pushoverSettings.Enabled)
{
notificationService.Subscribe(new PushoverNotification(container.Get<IPushoverApi>(), pushoverService));
}

var slackService = container.Get<ISettingsService<SlackNotificationSettings>>();
var slackSettings = slackService.GetSettings();
if (slackSettings.Enabled)
{
notificationService.Subscribe(new SlackNotification(container.Get<ISlackApi>(), slackService));
}
}

protected override void RequestStartup(IKernel container, IPipelines pipelines, NancyContext context)
{
//CORS Enable
Expand Down
Loading

0 comments on commit f5d7c81

Please sign in to comment.