示例#1
0
        public async Task HandleNSChg(string[] contents, NSClient client)
        {
            await RequireNSAuthentication(contents, client);

            var presence = FromPresenceAcronym(contents[2]);

            if (presence == null)
            {
                client.Connection.Client.Close();
            }

            client.Presence = presence;

            await client.SendAsync("CHG " + contents[1] + " " + contents[2]);

            foreach (var x in client.Database.Contacts.Where(x => x.User == client.UserID && x.ContactList == ContactList.ReverseList))
            {
                var target = NSClients.Find(y => y.UserID == x.Target);
                if (target != null)
                {
                    var user = await client.Database.Users.FindAsync(x.User);

                    var uc = NSClients.Find(x => x.UserID == user.ID);
                    if (uc.Presence == Presence.Hidden)
                    {
                        await target.SendAsync($"FLN {user.Email}");
                    }

                    else
                    {
                        await target.SendAsync($"NLN {ToPresenceAcronym(uc.Presence)} {user.Email} {user.SafeNickname}");
                    }
                }
            }
        }
示例#2
0
        public async Task HandleNSOut(string[] contents, NSClient client)
        {
            foreach (var target in from x in client.Database.Contacts.AsEnumerable().Where(x => x.User == client.UserID && x.ContactList == ContactList.ReverseList)
                     let target = NSClients.Find(y => y.UserID == x.Target)
                                  where target != null
                                  where target != client
                                  select target)
            {
                await target.SendAsync($"FLN {client.UserHandle}");
            }

            client.Connection.Client.Close();
        }
示例#3
0
        public async Task HandleNSSyn(string[] contents, NSClient client)
        {
            await RequireNSAuthentication(contents, client);

            if (!uint.TryParse(contents[2], out var count))
            {
                await client.SendAsync("715 " + contents[1], true);
            }

            var user = client.Database.Users.Where(x => x.ID == client.UserID).First();

            await client.SendAsync("SYN " + contents[1] + " " + user.SyncID);

            var fl = client.Database.Contacts.Where(x => x.ContactList == ContactList.ForwardList && x.User == client.UserID).ToArray();

            if (count != user.SyncID)
            {
                await client.SendAsync($"GTC {contents[1]} {user.SyncID} {(user.Notify ? "A" : "N")}");

                await client.SendAsync($"BLP {contents[1]} {user.SyncID} {(user.MessagePrivacy ? "AL" : "BL")}");

                await SendList(contents, user, client, ContactList.ForwardList);
                await SendList(contents, user, client, ContactList.AllowList);
                await SendList(contents, user, client, ContactList.BlockList);
                await SendList(contents, user, client, ContactList.ReverseList);
            }

            foreach (var forward in fl)
            {
                var u        = client.Database.Users.Find(forward.Target);
                var uc       = NSClients.Find(x => x.UserID == u.ID);
                var presence = uc != null?ToPresenceAcronym(uc.Presence) : "FLN";

                await client.SendAsync($"ILN {contents[1]} {presence} {u.Email} {u.SafeNickname}");
            }
        }