mutu310 70 Posted February 16, 2017 Share Posted February 16, 2017 In my BlurN plugin, I am sending notifications, however even if I disable the Pushover Notifications and disable the notification in the Notifications section (as can be seen below), I still get notifications. Is this a bug or am I doing something wrong? my code is below: var variables = new Dictionary<string, string>(); variables.Add("Title", omdb.Title); variables.Add("Year", omdb.Year.ToString()); variables.Add("IMDbRating", omdb.ImdbRating.ToString()); await Plugin.NotificationManager.SendNotification(new NotificationRequest() { Variables = variables, Date = DateTime.Now, Level = NotificationLevel.Normal, SendToUserMode = SendToUserType.All, NotificationType = "BlurNNewRelease" }, cancellationToken).ConfigureAwait(false); and the notificationtype: using MediaBrowser.Controller.Notifications; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Notifications; namespace MediaBrowser.Channels.BlurN.Helpers { class BlurNNotificationType : INotificationTypeFactory { public IEnumerable<NotificationTypeInfo> GetNotificationTypes() { var knownTypes = new List<NotificationTypeInfo>() { new NotificationTypeInfo() { Category = "BlurN", DefaultDescription = "Year: {Year}, IMDb Rating: {IMDbRating}", DefaultTitle = "[BlurN] New movie released: {Title}", Enabled = true, IsBasedOnUserEvent = false, Name = "New release notification", Type = "BlurNNewRelease", Variables = new List<string> {"Title", "Year", "IMDbRating" } } }; return knownTypes; } } } Link to comment Share on other sites More sharing options...
mutu310 70 Posted February 17, 2017 Author Share Posted February 17, 2017 Bump Link to comment Share on other sites More sharing options...
Luke 37167 Posted February 17, 2017 Share Posted February 17, 2017 I haven't had a chance to test this yet, sorry. Link to comment Share on other sites More sharing options...
mutu310 70 Posted February 22, 2017 Author Share Posted February 22, 2017 I haven't had a chance to test this yet, sorry.Gentle reminder Link to comment Share on other sites More sharing options...
mutu310 70 Posted February 28, 2017 Author Share Posted February 28, 2017 @@Luke, any chance for this please? Link to comment Share on other sites More sharing options...
Luke 37167 Posted February 28, 2017 Share Posted February 28, 2017 How are you sending a notification? the code on the server looks fine to me. Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 4, 2017 Author Share Posted March 4, 2017 How are you sending a notification? the code on the server looks fine to me.I posted the source code on the first post in the thread... Link to comment Share on other sites More sharing options...
Luke 37167 Posted March 4, 2017 Share Posted March 4, 2017 In your first example, SendToUserType is nullable. When you leave it null it goes by the settings in the server dashboard. When you specify usertype all, you are effectively overriding that. Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 13, 2017 Author Share Posted March 13, 2017 In your first example, SendToUserType is nullable. When you leave it null it goes by the settings in the server dashboard. When you specify usertype all, you are effectively overriding that. Sorry for the late reply but missed your reply. I tried commenting out this line: SendToUserMode = SendToUserType.All, The end result is that Emby Server is crashing and closing down, so I have re-enabled the line of code. Some last log lines: 2017-03-13 11:07:28.5742 Debug NotificationManager: Sending notification via Dashboard Notifications to user Mark 2017-03-13 11:07:28.5742 Info HttpServer: HTTP GET http://localhost:8096/emby/Notifications/c0ebcad535c8498eba28963104fabeb0/Summary. UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 2017-03-13 11:07:28.6328 Error HttpServer: Error processing request *** Error Report *** Version: 3.2.7.0 Command line: E:\emby.windows\System\MediaBrowser.ServerApplication.exe Operating system: Microsoft Windows NT 6.2.9200.0 64-Bit OS: True 64-Bit Process: True Processor count: 8 Program data path: E:\emby.windows Application directory: E:\emby.windows\System Corrupt: database disk image is malformed SQLitePCL.pretty.SQLiteException: Exception of type 'SQLitePCL.pretty.SQLiteException' was thrown. at SQLitePCL.pretty.SQLiteException.CheckOk(sqlite3 db, Int32 rc) at SQLitePCL.pretty.StatementImpl.MoveNext() at Emby.Server.Implementations.Data.SqliteExtensions.<ExecuteQuery>d__36.MoveNext() at Emby.Server.Implementations.Notifications.SqliteNotificationsRepository.GetNotificationsSummary(String userId) at MediaBrowser.Api.NotificationsService.Get(GetNotificationsSummary request) at Emby.Server.Implementations.Services.ServiceExecGeneral.<Execute>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Emby.Server.Implementations.Services.ServiceController.<Execute>d__13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Emby.Server.Implementations.Services.ServiceHandler.<ProcessRequestAsync>d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Emby.Server.Implementations.HttpServer.HttpListenerHost.<RequestHandler>d__74.MoveNext() SQLitePCL.pretty.SQLiteException at SQLitePCL.pretty.SQLiteException.CheckOk(sqlite3 db, Int32 rc) at SQLitePCL.pretty.StatementImpl.MoveNext() at Emby.Server.Implementations.Data.SqliteExtensions.<ExecuteQuery>d__36.MoveNext() at Emby.Server.Implementations.Notifications.SqliteNotificationsRepository.GetNotificationsSummary(String userId) at MediaBrowser.Api.NotificationsService.Get(GetNotificationsSummary request) at Emby.Server.Implementations.Services.ServiceExecGeneral.<Execute>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Emby.Server.Implementations.Services.ServiceController.<Execute>d__13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Emby.Server.Implementations.Services.ServiceHandler.<ProcessRequestAsync>d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Emby.Server.Implementations.HttpServer.HttpListenerHost.<RequestHandler>d__74.MoveNext() 2017-03-13 11:07:28.6348 Info HttpServer: HTTP Response 500 to ::1. Time: 60ms. http://localhost:8096/emby/Notifications/c0ebcad535c8498eba28963104fabeb0/Summary Link to comment Share on other sites More sharing options...
Luke 37167 Posted March 13, 2017 Share Posted March 13, 2017 I would try it again and/or delete your notifications.db file. Here is an example from the core: var type = NotificationType.TaskFailed.ToString(); var notification = new NotificationRequest { Description = result.ErrorMessage, Level = NotificationLevel.Error, NotificationType = type }; notification.Variables["Name"] = result.Name; notification.Variables["ErrorMessage"] = result.ErrorMessage; await SendNotification(notification).ConfigureAwait(false); Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 14, 2017 Author Share Posted March 14, 2017 I would try it again and/or delete your notifications.db file. Here is an example from the core: var type = NotificationType.TaskFailed.ToString(); var notification = new NotificationRequest { Description = result.ErrorMessage, Level = NotificationLevel.Error, NotificationType = type }; notification.Variables["Name"] = result.Name; notification.Variables["ErrorMessage"] = result.ErrorMessage; await SendNotification(notification).ConfigureAwait(false); I deleted the notifications.db file as you suggested and then commented out the SendToUserMode line as you suggested. With the following settings I still received notifications on Pushover: With two checkboxes I expect 3 modes: Mode 1 (both unchecked): no notifications at all Mode 2 (Notification enabled, service disabled, as per screenshot above): notifications in dashboard only Mode 3 (Notification enabled, service enabled): notifications in both dashboard and notification service. Link to comment Share on other sites More sharing options...
Luke 37167 Posted March 14, 2017 Share Posted March 14, 2017 That's exactly how the built in notifications work so it's just a matter of finding out what the difference is here. thanks. Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 14, 2017 Author Share Posted March 14, 2017 That's exactly how the built in notifications work so it's just a matter of finding out what the difference is here. thanks. Could you please rephrase? Do you mean that it's normal behavior for services to still be used even when disabled? Link to comment Share on other sites More sharing options...
Luke 37167 Posted March 14, 2017 Share Posted March 14, 2017 On other words the built in notifications match your expectations Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 14, 2017 Author Share Posted March 14, 2017 On other words the built in notifications match your expectations Would you be able to debug my issue please? It will be hard for me to fix a problem when my code looks OK and I can't debug. Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 20, 2017 Author Share Posted March 20, 2017 I followed the code on Github and tried the following: NotificationOptions options = _serverConfigurationManager.GetConfiguration<NotificationOptions>("notifications"); if (options.IsServiceEnabled("Pushover Notifications", BlurNNotificationType.NewRelease)) await Plugin.NotificationManager.SendNotification(new NotificationRequest() { Variables = variables, Date = DateTime.Now, Level = NotificationLevel.Normal, NotificationType = BlurNNotificationType.NewRelease, Url = "http://www.imdb.com/title/" + blurNItem.ImdbId + "/" }, cancellationToken).ConfigureAwait(false); I still got the notifications despite the service being disabled for my notificationtype, as can be seen below: Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 20, 2017 Author Share Posted March 20, 2017 Also check out the code in NotificationOptions.cs: public bool IsServiceEnabled(string service, string notificationType) { NotificationOption opt = GetOptions(notificationType); return opt == null || !ListHelper.ContainsIgnoreCase(opt.DisabledServices, service); } The above calls GetOptions... public NotificationOption GetOptions(string type) { foreach (NotificationOption i in Options) { if (StringHelper.EqualsIgnoreCase(type, i.Type)) return i; } return null; } Which in return calls Options: Options = new[] { new NotificationOption { Type = NotificationType.TaskFailed.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.ServerRestartRequired.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.ApplicationUpdateAvailable.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.ApplicationUpdateInstalled.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.PluginUpdateInstalled.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.PluginUninstalled.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.InstallationFailed.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.PluginInstalled.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.PluginError.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins }, new NotificationOption { Type = NotificationType.UserLockedOut.ToString(), Enabled = true, SendToUserMode = SendToUserType.Admins } }; Since my custom notificationtype is not included in "Options", then GetOptions("BlurNNewRelease") will return null, and if GetOptions returns null then IsServiceEnabled returns true. Hence, this is a bug in Emby Server. Anyone who makes custom notification types may not disable services for them. Link to comment Share on other sites More sharing options...
Luke 37167 Posted March 20, 2017 Share Posted March 20, 2017 can you attach the contents of your notifications config file? thanks. Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 20, 2017 Author Share Posted March 20, 2017 can you attach the contents of your notifications config file? thanks. <?xml version="1.0"?> <NotificationOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Options> <NotificationOption> <Type>TaskFailed</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>ServerRestartRequired</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>ApplicationUpdateAvailable</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>ApplicationUpdateInstalled</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>PluginUpdateInstalled</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>PluginUninstalled</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>InstallationFailed</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>PluginInstalled</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>PluginError</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>UserLockedOut</Type> <DisabledMonitorUsers /> <SendToUsers /> <Enabled>true</Enabled> <DisabledServices /> <SendToUserMode>Admins</SendToUserMode> </NotificationOption> <NotificationOption> <Type>BlurNNewRelease</Type> <DisabledMonitorUsers /> <SendToUsers> <string>c0ebcad535c8498eba28963104fabeb0</string> </SendToUsers> <Enabled>true</Enabled> <DisabledServices> <string>c6253c0098053aa355a91635db05b017</string> </DisabledServices> <SendToUserMode>Custom</SendToUserMode> </NotificationOption> </Options> </NotificationOptions> Link to comment Share on other sites More sharing options...
Luke 37167 Posted March 20, 2017 Share Posted March 20, 2017 Well it's in the list if the config page is able to save and respect the setting. So now we just have to find out why it's not in the list when sending the notification. Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 20, 2017 Author Share Posted March 20, 2017 Well it's in the list if the config page is able to save and respect the setting. So now we just have to find out why it's not in the list when sending the notification.Looks like "Options" is hardcoded and not being populated with the custom notification types? Link to comment Share on other sites More sharing options...
Luke 37167 Posted March 20, 2017 Share Posted March 20, 2017 No, those are just the defaults, they get replaced with the data in the config file. Link to comment Share on other sites More sharing options...
mutu310 70 Posted March 20, 2017 Author Share Posted March 20, 2017 No, those are just the defaults, they get replaced with the data in the config file.Oh in that case you need to debug the issue, I don't have a setup where I can debug. Link to comment Share on other sites More sharing options...
mutu310 70 Posted June 8, 2017 Author Share Posted June 8, 2017 Oh in that case you need to debug the issue, I don't have a setup where I can debug. Any news on this please? Link to comment Share on other sites More sharing options...
Luke 37167 Posted June 8, 2017 Share Posted June 8, 2017 I have not been able to look at this yet. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now