diff options
Diffstat (limited to 'Emby.Server.Implementations/Notifications')
5 files changed, 32 insertions, 27 deletions
diff --git a/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs b/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs index f9fb98f85..849e02d81 100644 --- a/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs +++ b/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs @@ -28,21 +28,21 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.ApplicationUpdateInstalled.ToString(), DefaultDescription = "{ReleaseNotes}", DefaultTitle = "A new version of Emby Server has been installed.", - Variables = new List<string>{"Version"} + Variables = new string[]{"Version"} }, new NotificationTypeInfo { Type = NotificationType.InstallationFailed.ToString(), DefaultTitle = "{Name} installation failed.", - Variables = new List<string>{"Name", "Version"} + Variables = new string[]{"Name", "Version"} }, new NotificationTypeInfo { Type = NotificationType.PluginInstalled.ToString(), DefaultTitle = "{Name} was installed.", - Variables = new List<string>{"Name", "Version"} + Variables = new string[]{"Name", "Version"} }, new NotificationTypeInfo @@ -50,14 +50,14 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.PluginError.ToString(), DefaultTitle = "{Name} has encountered an error.", DefaultDescription = "{ErrorMessage}", - Variables = new List<string>{"Name", "ErrorMessage"} + Variables = new string[]{"Name", "ErrorMessage"} }, new NotificationTypeInfo { Type = NotificationType.PluginUninstalled.ToString(), DefaultTitle = "{Name} was uninstalled.", - Variables = new List<string>{"Name", "Version"} + Variables = new string[]{"Name", "Version"} }, new NotificationTypeInfo @@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.PluginUpdateInstalled.ToString(), DefaultTitle = "{Name} was updated.", DefaultDescription = "{ReleaseNotes}", - Variables = new List<string>{"Name", "ReleaseNotes", "Version"} + Variables = new string[]{"Name", "ReleaseNotes", "Version"} }, new NotificationTypeInfo @@ -79,70 +79,70 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.TaskFailed.ToString(), DefaultTitle = "{Name} failed.", DefaultDescription = "{ErrorMessage}", - Variables = new List<string>{"Name", "ErrorMessage"} + Variables = new string[]{"Name", "ErrorMessage"} }, new NotificationTypeInfo { Type = NotificationType.NewLibraryContent.ToString(), DefaultTitle = "{Name} has been added to your media library.", - Variables = new List<string>{"Name"} + Variables = new string[]{"Name"} }, new NotificationTypeInfo { Type = NotificationType.AudioPlayback.ToString(), DefaultTitle = "{UserName} is playing {ItemName} on {DeviceName}.", - Variables = new List<string>{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.GamePlayback.ToString(), DefaultTitle = "{UserName} is playing {ItemName} on {DeviceName}.", - Variables = new List<string>{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.VideoPlayback.ToString(), DefaultTitle = "{UserName} is playing {ItemName} on {DeviceName}.", - Variables = new List<string>{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.AudioPlaybackStopped.ToString(), DefaultTitle = "{UserName} has finished playing {ItemName} on {DeviceName}.", - Variables = new List<string>{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.GamePlaybackStopped.ToString(), DefaultTitle = "{UserName} has finished playing {ItemName} on {DeviceName}.", - Variables = new List<string>{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.VideoPlaybackStopped.ToString(), DefaultTitle = "{UserName} has finished playing {ItemName} on {DeviceName}.", - Variables = new List<string>{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.CameraImageUploaded.ToString(), DefaultTitle = "A new camera image has been uploaded from {DeviceName}.", - Variables = new List<string>{"DeviceName"} + Variables = new string[]{"DeviceName"} }, new NotificationTypeInfo { Type = NotificationType.UserLockedOut.ToString(), DefaultTitle = "{UserName} has been locked out.", - Variables = new List<string>{"UserName"} + Variables = new string[]{"UserName"} } }; diff --git a/Emby.Server.Implementations/Notifications/NotificationManager.cs b/Emby.Server.Implementations/Notifications/NotificationManager.cs index db7980497..f49d5a1d1 100644 --- a/Emby.Server.Implementations/Notifications/NotificationManager.cs +++ b/Emby.Server.Implementations/Notifications/NotificationManager.cs @@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Notifications _typeFactories = notificationTypeFactories.ToArray(); } - public IEnumerable<NotificationTypeInfo> GetNotificationTypes() + public List<NotificationTypeInfo> GetNotificationTypes() { var list = _typeFactories.Select(i => { diff --git a/Emby.Server.Implementations/Notifications/Notifications.cs b/Emby.Server.Implementations/Notifications/Notifications.cs index f95b3f701..09c1f07e0 100644 --- a/Emby.Server.Implementations/Notifications/Notifications.cs +++ b/Emby.Server.Implementations/Notifications/Notifications.cs @@ -422,7 +422,7 @@ namespace Emby.Server.Implementations.Notifications { var artists = hasArtist.AllArtists; - if (artists.Count > 0) + if (artists.Length > 0) { name = hasArtist.AllArtists[0] + " - " + name; } @@ -440,7 +440,7 @@ namespace Emby.Server.Implementations.Notifications name = item.SeriesName + " - " + name; } - if (item.Artists != null && item.Artists.Count > 0) + if (item.Artists != null && item.Artists.Length > 0) { name = item.Artists[0] + " - " + name; } @@ -551,6 +551,7 @@ namespace Emby.Server.Implementations.Notifications _deviceManager.CameraImageUploaded -= _deviceManager_CameraImageUploaded; _userManager.UserLockedOut -= _userManager_UserLockedOut; + GC.SuppressFinalize(this); } private void DisposeLibraryUpdateTimer() diff --git a/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs b/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs index 40752db80..ff152c9e9 100644 --- a/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs +++ b/Emby.Server.Implementations/Notifications/SqliteNotificationsRepository.cs @@ -12,6 +12,7 @@ using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Notifications; using SQLitePCL.pretty; +using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.Notifications { @@ -83,13 +84,13 @@ namespace Emby.Server.Implementations.Notifications clauses.Add("UserId=?"); paramList.Add(query.UserId.ToGuidBlob()); - var whereClause = " where " + string.Join(" And ", clauses.ToArray()); + var whereClause = " where " + string.Join(" And ", clauses.ToArray(clauses.Count)); using (WriteLock.Read()) { using (var connection = CreateConnection(true)) { - result.TotalRecordCount = connection.Query("select count(Id) from Notifications" + whereClause, paramList.ToArray()).SelectScalarInt().First(); + result.TotalRecordCount = connection.Query("select count(Id) from Notifications" + whereClause, paramList.ToArray(paramList.Count)).SelectScalarInt().First(); var commandText = string.Format("select Id,UserId,Date,Name,Description,Url,Level,IsRead,Category,RelatedId from Notifications{0} order by IsRead asc, Date desc", whereClause); @@ -110,12 +111,12 @@ namespace Emby.Server.Implementations.Notifications var resultList = new List<Notification>(); - foreach (var row in connection.Query(commandText, paramList.ToArray())) + foreach (var row in connection.Query(commandText, paramList.ToArray(paramList.Count))) { resultList.Add(GetNotification(row)); } - result.Notifications = resultList.ToArray(); + result.Notifications = resultList.ToArray(resultList.Count); } } @@ -280,7 +281,7 @@ namespace Emby.Server.Implementations.Notifications public async Task MarkRead(IEnumerable<string> notificationIdList, string userId, bool isRead, CancellationToken cancellationToken) { var list = notificationIdList.ToList(); - var idArray = list.Select(i => new Guid(i)).ToArray(); + var idArray = list.Select(i => new Guid(i)).ToArray(list.Count); await MarkReadInternal(idArray, userId, isRead, cancellationToken).ConfigureAwait(false); @@ -290,7 +291,7 @@ namespace Emby.Server.Implementations.Notifications { NotificationsMarkedRead(this, new NotificationReadEventArgs { - IdList = list.ToArray(), + IdList = list.ToArray(list.Count), IsRead = isRead, UserId = userId }); diff --git a/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs b/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs index 0239ee336..6e57e7f81 100644 --- a/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs +++ b/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs @@ -1,7 +1,9 @@ -using MediaBrowser.Controller.Net; +using System; +using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Notifications; using MediaBrowser.Controller.Plugins; using System.Linq; +using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.Notifications { @@ -33,7 +35,7 @@ namespace Emby.Server.Implementations.Notifications list.Add(e.UserId); list.Add(e.IsRead.ToString().ToLower()); - var msg = string.Join("|", list.ToArray()); + var msg = string.Join("|", list.ToArray(list.Count)); _serverManager.SendWebSocketMessage("NotificationsMarkedRead", msg); } @@ -48,6 +50,7 @@ namespace Emby.Server.Implementations.Notifications public void Dispose() { _notificationsRepo.NotificationAdded -= _notificationsRepo_NotificationAdded; + GC.SuppressFinalize(this); } } } |
