Exemple #1
0
        public bool NewsWorthy(ulong id, uint project, bool localRegionOnly)
        {
            //crit - if in buddy list, if non-local self
            //should really be done per compontnt (board only cares about local, mail doesnt care at all, neither does chat)

            // if not self, higher, adjacent or lower direct then true
            if (id == UserID || Trust.LocalTrust == null)
            {
                return(false);
            }

            if (!localRegionOnly && Trust.IsHigher(id, project))
            {
                return(true);
            }

            if (localRegionOnly && Trust.IsHigherDirect(id, project))
            {
                return(true);
            }

            if (Trust.IsAdjacent(id, project))
            {
                return(true);
            }

            if (Trust.IsLowerDirect(id, project))
            {
                return(true);
            }

            return(false);
        }
Exemple #2
0
        private void ReceiveMessage(ChatText message, RudpSession session)
        {
            if (Core.Buddies.IgnoreList.SafeContainsKey(session.UserID))
            {
                return;
            }

            // remote's command low, is my command high
            // do here otherwise have to send custom roomID packets to selfs/lowers/highers

            if (Trust != null && session.UserID != Core.UserID)
            {
                // if check fails then it is loop node sending data, keep it unchanged
                if (message.Kind == RoomKind.Command_High && Trust.IsLowerDirect(session.UserID, message.ProjectID))
                {
                    message.Kind = RoomKind.Command_Low;
                }

                else if (message.Kind == RoomKind.Command_Low && Trust.IsHigher(session.UserID, message.ProjectID))
                {
                    message.Kind = RoomKind.Command_High;
                }

                else if (message.Kind == RoomKind.Live_High)
                {
                    message.Kind = RoomKind.Live_Low;
                }

                else if (message.Kind == RoomKind.Live_Low)
                {
                    message.Kind = RoomKind.Live_High;
                }
            }

            ulong id = IsCommandRoom(message.Kind) ? GetRoomID(message.ProjectID, message.Kind) : message.RoomID;

            ChatRoom room = null;

            // if not in room let remote user know
            if (!RoomMap.TryGetValue(id, out room) ||
                !room.Active)
            {
                SendStatus(session);
                return;
            }

            // if sender not in room
            if (!room.Members.SafeContains(session.UserID))
            {
                return;
            }

            if (!ChatNewsUpdate)
            {
                ChatNewsUpdate = true;
                Core.MakeNews(ServiceIDs.Chat, Core.GetName(session.UserID) + " is chatting", session.UserID, 0, false);
            }

            ProcessMessage(room, new ChatMessage(Core, session, message));
        }