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); });
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)); }
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); }
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)); }
private async Task AddInvitation(string path, string data) { await FileMaster.UpdateFile(path, FileMaster.AddData(data)); }
private async void WriteNewPerson(string path, PersonChat personChat) { await FileMaster.UpdateFile(path, FileMaster.AddData(personChat)); }
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); }