Exemplo n.º 1
0
        public void LogMessage(string title, NotificationModel model)
        {
            using (var writer = AccessLog(title, title))
            {
                var thisMessage = HttpUtility.HtmlDecode(model.ToString());
                var timestamp   = model.TimeStamp;

                writer.WriteLine(timestamp + ' ' + thisMessage);
            }
        }
Exemplo n.º 2
0
 private bool MeetsFilter(NotificationModel item)
 {
     return item.ToString().ContainsOrdinal(search);
 }
Exemplo n.º 3
0
        private void HandleNotification(NotificationModel notification)
        {
            // TODO: I'M DYIN' OVER HERE! REFACTOR ME!

            // character update models will be *most* of the notification the user will see
            var model = notification as CharacterUpdateModel;
            if (model != null)
            {
                var targetCharacter = model.TargetCharacter.Name;
                var args = model.Arguments;

                // handle if the notification involves a character being promoted or demoted
                var eventArgs = args as CharacterUpdateModel.PromoteDemoteEventArgs;
                if (eventArgs != null)
                {
                    var channelId = eventArgs.TargetChannelId;

                    // find by ID, not name
                    var channel = cm.CurrentChannels.FirstByIdOrNull(channelId);

                    if (channel == null)
                        return;

                    if (channel.Settings.PromoteDemoteNotifyOnlyForInteresting)
                    {
                        if (!IsOfInterest(targetCharacter))
                            return; // if we only want to know interesting people, no need to evalute further
                    }

                    ConvertNotificationLevelToAction(
                        channel.Settings.PromoteDemoteNotifyLevel, channelId, model);
                }
                else if (args is CharacterUpdateModel.JoinLeaveEventArgs)
                {
                    // special check for this as it has settings per channel
                    var target = ((CharacterUpdateModel.JoinLeaveEventArgs) args).TargetChannelId;

                    // find by ID, not name
                    var channel = cm.CurrentChannels.FirstByIdOrNull(target);

                    if (channel == null)
                        return;

                    if (channel.Settings.JoinLeaveNotifyOnlyForInteresting)
                    {
                        if (!IsOfInterest(targetCharacter))
                            return;
                    }

                    ConvertNotificationLevelToAction(channel.Settings.JoinLeaveNotifyLevel, target, model);
                }
                else if (args is CharacterUpdateModel.NoteEventArgs || args is CharacterUpdateModel.CommentEventArgs)
                {
                    AddNotification(model);

                    var link = args is CharacterUpdateModel.NoteEventArgs
                        ? ((CharacterUpdateModel.NoteEventArgs) args).Link
                        : ((CharacterUpdateModel.CommentEventArgs) args).Link;

                    NotifyUser(false, false, notification.ToString(), link);
                }
                else if (args is CharacterUpdateModel.ListChangedEventArgs)
                {
                    AddNotification(model);
                    NotifyUser(false, false, notification.ToString(), targetCharacter);
                }
                else if (args is CharacterUpdateModel.ReportHandledEventArgs)
                {
                    AddNotification(model);
                    NotifyUser(true, true, notification.ToString(), targetCharacter);
                }
                else if (args is CharacterUpdateModel.ReportFiledEventArgs)
                {
                    AddNotification(model);
                    NotifyUser(true, true, notification.ToString(), targetCharacter, "report");
                }
                else if (args is CharacterUpdateModel.BroadcastEventArgs)
                {
                    AddNotification(model);
                    NotifyUser(true, true, notification.ToString(), targetCharacter);
                }
                else if (IsOfInterest(targetCharacter, false) && !model.TargetCharacter.IgnoreUpdates)
                {
                    AddNotification(model);

                    if (cm.CurrentChannel is PmChannelModel)
                    {
                        if ((cm.CurrentChannel as PmChannelModel).Id.Equals(
                            targetCharacter, StringComparison.OrdinalIgnoreCase))
                            return; // don't make a toast if we have their tab focused as it is redundant
                    }

                    NotifyUser(false, false, notification.ToString(), targetCharacter);
                }
            }
            else
            {
                var channelUpdate = (ChannelUpdateModel) notification;

                if (!channelUpdate.TargetChannel.Settings.AlertAboutUpdates) return;

                AddNotification(notification);
                NotifyUser(false, false, notification.ToString(), channelUpdate.TargetChannel.Id);
            }
        }
Exemplo n.º 4
0
        private void ConvertNotificationLevelToAction(
            int notificationLevel, string actionId, NotificationModel notification)
        {
            switch ((ChannelSettingsModel.NotifyLevel) notificationLevel)
            {
                    // convert our int into an enum to avoid magic numbers
                case ChannelSettingsModel.NotifyLevel.NoNotification:
                    return;

                case ChannelSettingsModel.NotifyLevel.NotificationOnly:
                    AddNotification(notification);
                    return;

                case ChannelSettingsModel.NotifyLevel.NotificationAndToast:
                    AddNotification(notification);
                    NotifyUser(false, false, notification.ToString(), actionId);
                    return;

                case ChannelSettingsModel.NotifyLevel.NotificationAndSound:
                    AddNotification(notification);
                    NotifyUser(true, true, notification.ToString(), actionId);
                    return;
            }
        }
Exemplo n.º 5
0
 private bool MeetsFilter(NotificationModel item)
 {
     return(item.ToString().ContainsOrdinal(search));
 }
Exemplo n.º 6
0
        public void LogMessage(string title, NotificationModel model)
        {
            using (var writer = AccessLog(title, title))
            {
                var thisMessage = HttpUtility.HtmlDecode(model.ToString());
                var timestamp = model.TimeStamp;

                writer.WriteLine(timestamp + ' ' + thisMessage);
            }
        }