diff --git a/Ombi.Core/SecurityExtensions.cs b/Ombi.Core/SecurityExtensions.cs index a68884009..7a244554a 100644 --- a/Ombi.Core/SecurityExtensions.cs +++ b/Ombi.Core/SecurityExtensions.cs @@ -114,9 +114,13 @@ namespace Ombi.Core } // could be a local user - var localName = session[SessionKeys.UsernameKey]; + var hasSessionKey = session[SessionKeys.UsernameKey] != null; + if (hasSessionKey) + { + return (string)session[SessionKeys.UsernameKey]; + } - return localName as string; + return string.Empty; } diff --git a/Ombi.Core/Users/UserHelperModel.cs b/Ombi.Core/Users/UserHelperModel.cs index 1b08d9fb1..ace42d4f9 100644 --- a/Ombi.Core/Users/UserHelperModel.cs +++ b/Ombi.Core/Users/UserHelperModel.cs @@ -25,6 +25,7 @@ // ************************************************************************/ #endregion +using Newtonsoft.Json; using Ombi.Helpers; using Ombi.Helpers.Permissions; @@ -38,5 +39,8 @@ namespace Ombi.Core.Users public Features Features { get; set; } public string EmailAddress { get; set; } public UserType Type { get; set; } + + [JsonIgnore] + public string UsernameOrAlias => string.IsNullOrEmpty(UserAlias) ? Username : UserAlias; } } \ No newline at end of file diff --git a/Ombi.Services/Notification/NotificationEngine.cs b/Ombi.Services/Notification/NotificationEngine.cs index 7a119cca1..01b50898b 100644 --- a/Ombi.Services/Notification/NotificationEngine.cs +++ b/Ombi.Services/Notification/NotificationEngine.cs @@ -152,8 +152,18 @@ namespace Ombi.Services.Notification var users = UserHelper.GetUsersWithFeature(Features.RequestAddedNotification).ToList(); Log.Debug("Notifying Users Count {0}", users.Count); - var selectedUsers = users.Select(x => x.Username).Intersect(model.RequestedUsers, StringComparer.CurrentCultureIgnoreCase); - foreach (var user in selectedUsers) + // Get the usernames or alias depending if they have an alias + var userNamesWithFeature = users.Select(x => x.UsernameOrAlias).ToList(); + + var usersToNotify = userNamesWithFeature.Intersect(model.AllUsers, StringComparer.CurrentCultureIgnoreCase).ToList(); + + if (!usersToNotify.Any()) + { + Log.Debug("Could not find any users after the .Intersect()"); + } + + Log.Debug("Users being notified for this request count {0}", users.Count); + foreach (var user in usersToNotify) { Log.Info("Notifying user {0}", user); if (user.Equals(adminUsername, StringComparison.CurrentCultureIgnoreCase)) diff --git a/Ombi.Store/Models/PlexUsers.cs b/Ombi.Store/Models/PlexUsers.cs index b61b2a99e..0a3b735d1 100644 --- a/Ombi.Store/Models/PlexUsers.cs +++ b/Ombi.Store/Models/PlexUsers.cs @@ -26,6 +26,7 @@ #endregion using Dapper.Contrib.Extensions; +using Newtonsoft.Json; namespace Ombi.Store.Models { diff --git a/Ombi.Store/RequestedModel.cs b/Ombi.Store/RequestedModel.cs index 89c30e21e..6d0342a14 100644 --- a/Ombi.Store/RequestedModel.cs +++ b/Ombi.Store/RequestedModel.cs @@ -65,7 +65,7 @@ namespace Ombi.Store u.Add(RequestedBy); } - if (RequestedUsers.Any()) + if (RequestedUsers != null && RequestedUsers.Any()) { u.AddRange(RequestedUsers.Where(requestedUser => requestedUser != RequestedBy)); } diff --git a/Ombi.UI/Helpers/BaseUrlHelper.cs b/Ombi.UI/Helpers/BaseUrlHelper.cs index 37482005c..99c37459e 100644 --- a/Ombi.UI/Helpers/BaseUrlHelper.cs +++ b/Ombi.UI/Helpers/BaseUrlHelper.cs @@ -199,7 +199,7 @@ namespace Ombi.UI.Helpers var assetLocation = GetBaseUrl(); var content = GetContentUrl(assetLocation); - + sb.AppendLine($""); return helper.Raw(sb.ToString()); @@ -226,9 +226,9 @@ namespace Ombi.UI.Helpers sb.Append($""); sb.Append($""); sb.Append($""); - sb.Append($""); - sb.Append($""); - sb.Append($""); + sb.Append($""); + sb.Append($""); + sb.Append($""); return helper.Raw(sb.ToString()); } @@ -290,17 +290,19 @@ namespace Ombi.UI.Helpers return helper.Raw(asset); } - public static IHtmlString GetSidebarUrl(this HtmlHelpers helper, NancyContext context, string url, string title, bool dropdown = false) + public static IHtmlString GetSidebarUrl(this HtmlHelpers helper, NancyContext context, string url, string title, string icon = null) { var content = GetLinkUrl(GetBaseUrl()); if (!string.IsNullOrEmpty(content)) { url = $"/{content}{url}"; } - var dropdownClass = dropdown ? "list-group-item-dropdown" : string.Empty; - var returnString = context.Request.Path == url - ? $"{title}" - : $"{title}"; + + + var iconHtml = string.IsNullOrEmpty(icon) ? "" : $""; + var returnString = context.Request.Path == url + ? $"{title} {iconHtml}" + : $"{title} {iconHtml}"; return helper.Raw(returnString); } @@ -312,8 +314,8 @@ namespace Ombi.UI.Helpers { url = $"/{content}{url}"; } - var returnString = context.Request.Path == url ? - $"