예제 #1
0
        private async Task AddUserToGroups(string userPath, string nameGroup, string typeGroup, User user)
        {
            string partPath;

            switch (typeGroup)
            {
            case "public":
                partPath = "userGroups.json";
                break;

            case "secret":
                partPath = "secretGroups.json";
                break;

            default:
                return;
            }
            await FileMaster.UpdateFile(Path.Combine(userPath, partPath), FileMaster.AddData(nameGroup));

            await FileMaster.UpdateFile <string>(Path.Combine(PathChat, "users.json"), users =>
            {
                return(new List <string>()
                {
                    user.Nickname
                }, true);
            });
예제 #2
0
        private async Task ReadWriteInvitationOrGroup(string path, string nameGroup, string typeGroup)
        {
            string data;

            if (typeGroup == "pg")
            {
                data = $"public: {nameGroup}";
            }
            else if (typeGroup == "sg")
            {
                data = $"secret: {nameGroup}";
            }
            else
            {
                data = nameGroup;
            }
            await FileMaster.UpdateFile(path, FileMaster.AddData(data));
        }
예제 #3
0
        private async Task <string> AddGroup(string nameGroup, string typeGroup, List <string> invitedPeople)
        {
            string pathGroup;

            switch (typeGroup)
            {
            case "pg":
                pathGroup = Path.Combine(messenger.Server.PublicGroupPath, nameGroup);
                break;

            default:     //(sg)
                pathGroup = Path.Combine(messenger.Server.SecretGroupPath, nameGroup);
                break;
            }
            FileMaster.CreateDirectory(pathGroup);
            await FileMaster.UpdateFile(Path.Combine(pathGroup, "users.json"), FileMaster.AddData(user.Nickname));

            await FileMaster.UpdateFile(Path.Combine(pathGroup, "invitation.json"), FileMaster.AddSomeData(invitedPeople));

            return(pathGroup);
        }
예제 #4
0
        private async Task AddInvites(string namePerson)
        {
            string partInvitation;

            switch (TypeChat)
            {
            case "pg":
            case "ug":
                partInvitation = "public: ";
                break;

            case "sg":
                partInvitation = "secret: ";
                break;

            default:
                partInvitation = "";
                break;
            }
            await FileMaster.UpdateFile(Path.Combine(messenger.Server.UsersPath, namePerson, "invitation.json"), FileMaster.AddData($"{partInvitation}{NameChat}"));

            await FileMaster.UpdateFile(Path.Combine(PathChat, "invitation.json"), FileMaster.AddData(namePerson));
        }
예제 #5
0
 private async Task AddInvitation(string path, string data)
 {
     await FileMaster.UpdateFile(path, FileMaster.AddData(data));
 }
예제 #6
0
 private async void WriteNewPerson(string path, PersonChat personChat)
 {
     await FileMaster.UpdateFile(path, FileMaster.AddData(personChat));
 }
예제 #7
0
        private async void BanOnNickname(UserNicknameAndPasswordAndIPs user)
        {
            await FileMaster.UpdateFile(Path.Combine(messenger.Server.BansPath, "nicknamesBun.json"), FileMaster.AddData(user.Nickname));

            lock (messenger.OnlineLock)
            {
                foreach (var userOnline in messenger.online)
                {
                    if (userOnline.Nickname == user.Nickname)
                    {
                        userOnline.communication.EndTask = true;
                        break;
                    }
                }
            }
            await userDeleter.Run(user.Nickname, true);
        }