Jump to content

Notification settings being ignored


mutu310

Recommended Posts

mutu310

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?

 

58a59e7bbdac3_emby2.png

 

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

mutu310

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

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

  • 2 weeks later...
mutu310

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

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

mutu310

 

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:

 

58c7f310f27ce_newreleasenotification.jpg

 

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

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

mutu310

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

mutu310

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

mutu310

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:

 

58cfa1948aa84_notifications.png

Link to comment
Share on other sites

mutu310

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

mutu310

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

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

mutu310

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

No, those are just the defaults, they get replaced with the data in the config file.

Link to comment
Share on other sites

mutu310

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

  • 2 months later...
mutu310

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...