コード例 #1
0
ファイル: NotificationOptions.cs プロジェクト: sxryt/jellyfin
        public bool IsEnabledToMonitorUser(string type, Guid userId)
        {
            NotificationOption opt = GetOptions(type);

            return(opt != null && opt.Enabled &&
                   !ListHelper.ContainsIgnoreCase(opt.DisabledMonitorUsers, userId.ToString("")));
        }
コード例 #2
0
ファイル: NotificationOptions.cs プロジェクト: sxryt/jellyfin
        public bool IsServiceEnabled(string service, string notificationType)
        {
            NotificationOption opt = GetOptions(notificationType);

            return(opt == null ||
                   !ListHelper.ContainsIgnoreCase(opt.DisabledServices, service));
        }
コード例 #3
0
        public bool IsServiceEnabled(string service, string notificationType)
        {
            NotificationOption opt = GetOptions(notificationType);

            return(opt == null ||
                   !opt.DisabledServices.Contains(service, StringComparer.OrdinalIgnoreCase));
        }
コード例 #4
0
        public bool IsEnabledToMonitorUser(string type, Guid userId)
        {
            NotificationOption opt = GetOptions(type);

            return(opt != null && opt.Enabled &&
                   !opt.DisabledMonitorUsers.Contains(userId.ToString(string.Empty), StringComparer.OrdinalIgnoreCase));
        }
コード例 #5
0
        private IEnumerable<string> GetUserIds(NotificationRequest request, NotificationOption options)
        {
            if (request.SendToUserMode.HasValue)
            {
                switch (request.SendToUserMode.Value)
                {
                    case SendToUserType.Admins:
                        return _userManager.Users.Where(i => i.Configuration.IsAdministrator)
                                .Select(i => i.Id.ToString("N"));
                    case SendToUserType.All:
                        return _userManager.Users.Select(i => i.Id.ToString("N"));
                    case SendToUserType.Custom:
                        return request.UserIds;
                    default:
                        throw new ArgumentException("Unrecognized SendToUserMode: " + request.SendToUserMode.Value);
                }
            }

            if (options != null && !string.IsNullOrWhiteSpace(request.NotificationType))
            {
                var config = GetConfiguration();

                return _userManager.Users
                    .Where(i => config.IsEnabledToSendToUser(request.NotificationType, i.Id.ToString("N"), i.Configuration))
                    .Select(i => i.Id.ToString("N"));
            }

            return request.UserIds;
        }
コード例 #6
0
ファイル: NotificationOptions.cs プロジェクト: sxryt/jellyfin
        public bool IsEnabledToSendToUser(string type, string userId, UserPolicy userPolicy)
        {
            NotificationOption opt = GetOptions(type);

            if (opt != null && opt.Enabled)
            {
                if (opt.SendToUserMode == SendToUserType.All)
                {
                    return(true);
                }

                if (opt.SendToUserMode == SendToUserType.Admins && userPolicy.IsAdministrator)
                {
                    return(true);
                }

                return(ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId));
            }

            return(false);
        }
コード例 #7
0
        public bool IsEnabledToSendToUser(string type, string userId, User user)
        {
            NotificationOption opt = GetOptions(type);

            if (opt != null && opt.Enabled)
            {
                if (opt.SendToUserMode == SendToUserType.All)
                {
                    return(true);
                }

                if (opt.SendToUserMode == SendToUserType.Admins && user.HasPermission(PermissionKind.IsAdministrator))
                {
                    return(true);
                }

                return(opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase));
            }

            return(false);
        }
コード例 #8
0
ファイル: NotificationOptions.cs プロジェクト: sxryt/jellyfin
        public bool IsEnabled(string type)
        {
            NotificationOption opt = GetOptions(type);

            return(opt != null && opt.Enabled);
        }
コード例 #9
0
        private string GetDescription(NotificationRequest request, NotificationOption options)
        {
            var text = request.Description;

            // If empty, grab from options 
            if (string.IsNullOrEmpty(text))
            {
                if (!string.IsNullOrEmpty(request.NotificationType))
                {
                    if (options != null)
                    {
                        text = options.Description;
                    }
                }
            }

            // If still empty, grab default
            if (string.IsNullOrEmpty(text))
            {
                if (!string.IsNullOrEmpty(request.NotificationType))
                {
                    var info = GetNotificationTypes().FirstOrDefault(i => string.Equals(i.Type, request.NotificationType, StringComparison.OrdinalIgnoreCase));

                    if (info != null)
                    {
                        text = info.DefaultDescription;
                    }
                }
            }

            text = text ?? string.Empty;

            foreach (var pair in request.Variables)
            {
                var token = "{" + pair.Key + "}";

                text = text.Replace(token, pair.Value, StringComparison.OrdinalIgnoreCase);
            }

            return text;
        }