Exemplo n.º 1
0
        public void AddMessage(
            string message, string channelName, string poster, MessageType messageType = MessageType.Normal)
        {
            var sender =
                characters.Find(poster == Constants.Arguments.ThisCharacter ? cm.CurrentCharacter.Name : poster);

            var channel = cm.CurrentChannels.FirstByIdOrNull(channelName)
                          ?? (ChannelModel)cm.CurrentPms.FirstByIdOrNull(channelName);

            if (channel == null)
            {
                return; // exception circumstance, swallow message
            }
            if (messageType == MessageType.Ad && characters.IsOnList(poster, ListKind.NotInterested, false))
            {
                return; // don't want these clogging up our filter or.. anything really
            }
            Dispatcher.InvokeWithRetry(() =>
            {
                var thisMessage = new MessageModel(sender, message, messageType);

                channel.AddMessage(thisMessage, characters.IsOfInterest(poster));

                if (channel.Settings.LoggingEnabled && ApplicationSettings.AllowLogging)
                {
                    // check if the user wants logging for this channel
                    logger.LogMessage(channel.Title, channel.Id, thisMessage);
                }

                if (poster == Constants.Arguments.ThisCharacter)
                {
                    return;
                }

                // don't push events for our own messages
                if (channel is GeneralChannelModel)
                {
                    events.GetEvent <NewMessageEvent>()
                    .Publish(
                        new Dictionary <string, object>
                    {
                        { Constants.Arguments.Message, thisMessage },
                        { Constants.Arguments.Channel, channel }
                    });
                }
                else
                {
                    events.GetEvent <NewPmEvent>().Publish(thisMessage);
                }
            });
        }
Exemplo n.º 2
0
 private bool IsOfInterest(string name, bool onlineOnly = true)
 {
     return(cm.CurrentPms.Any(x => x.Id.Equals(name)) || characters.IsOfInterest(name, onlineOnly));
 }
Exemplo n.º 3
0
        public void IsOfInterestWorksCorrectly()
        {
            Assert.IsTrue(characters.IsOfInterest(bookmarkCharacter.Name, false));
            Assert.IsTrue(characters.IsOfInterest(friendCharacter.Name, false));
            Assert.IsFalse(characters.IsOfInterest(otherCharacter.Name, false));

            Assert.IsFalse(characters.IsOfInterest(bookmarkCharacter.Name));
            Assert.IsFalse(characters.IsOfInterest(friendCharacter.Name));
            Assert.IsFalse(characters.IsOfInterest(otherCharacter.Name));

            SignOnAllTestCharacters();

            Assert.IsTrue(characters.IsOfInterest(bookmarkCharacter.Name));
            Assert.IsTrue(characters.IsOfInterest(friendCharacter.Name));
            Assert.IsFalse(characters.IsOfInterest(otherCharacter.Name));

            Assert.IsTrue(characters.IsOfInterest(bookmarkCharacter.Name, false));
            Assert.IsTrue(characters.IsOfInterest(friendCharacter.Name, false));
            Assert.IsFalse(characters.IsOfInterest(otherCharacter.Name));
        }