public void ConfirmBanUser() { var request = new BanRequest(); try { if (!string.IsNullOrEmpty(banTimeInHours.text)) { request.DurationInHours = uint.Parse(banTimeInHours.text); } } catch (System.Exception e) { request.DurationInHours = 0; } request.Reason = banReason.text; request.PlayFabId = lastPlayerIdentifier.playerID; var banList = new List <BanRequest>(); banList.Add(request); PlayFabAdminAPI.BanUsers(new BanUsersRequest { Bans = banList }, result => { banModal.SetActive(false); Debug.Log("BAN USER OK: " + result.ToJson().ToString()); Inform(string.Format("{0} was successfully banned for {1} hours for \"{2}\"", lastPlayerIdentifier.displayName, banTimeInHours.text, banReason.text)); }, error => { Debug.LogError("BAN PLAYER FAILED: " + error.ToString()); Inform("Unable to ban user! " + error.ErrorMessage); banModal.SetActive(false); }); }
public BanResponse Ban(ISession session, BanRequest request) { var response = request.CreateResponse <BanResponse>(); User targetUser = null; using (var uow = UnitOfWorkFactory.Create()) { targetUser = uow.UsersRepository.FirstMatching(UserSpecification.Id(request.TargetUserId)); if (targetUser != null) { try { if (request.Ban) { targetUser.Ban(session.User); } else { targetUser.UnBan(session.User); } response.Result = BanResponseType.Success; uow.Commit(); } catch (ModeratorsRightsRequiredException) { response.Result = BanResponseType.Failed; } } } if (response.Result == BanResponseType.Success && targetUser != null) { //let's kick him\her from the server! _sessionManager.CloseSessionByUserId(targetUser.Id); //send a notification to everybody that we've banned him\her _sessionManager.SendToEachChatSessions( new BanNotification { Ban = request.Ban, ActorName = session.User.Name, Reason = request.Reason, TargetId = session.User.Id, TargetName = targetUser.Name }); } return(response); }
public Task <BanResponse> Ban(BanRequest request) { return(ConnectionManager.SendRequestAndWaitResponse <BanResponse>(request)); }
// public override Task <BanReply> Ban(BanRequest request, ServerCallContext context) { }
public IActionResult Ban(BanRequest request) { throw new NotImplementedException(); }