public override async Task <SendFriendRequestResponse> SendFriendRequest(SendFriendRequestRequest request, ServerCallContext context) { RedisUserModel user = context.UserState["user"] as RedisUserModel; if (user == null) { return new SendFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; RedisUserModel friend = await RedisUserModel.GetUserFromGuid(request.FriendId); if (friend == null) { return new SendFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.PLAYER_DOES_NOT_EXIST) } } ; if (await friend.HasFriendRequestFrom(user)) { return new SendFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.DUPLICATE) } } ; if (await friend.IsBlocked(user) || await user.IsBlocked(friend)) { return new SendFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.PLAYER_IS_BLOCKED) } } ; // Add request to the other player. await friend.AddFriendRequestFrom(user); return(new SendFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.SUCCESS) }); }
public override async Task <DenyFriendRequestResponse> DenyFriendRequest(DenyFriendRequestRequest request, ServerCallContext context) { RedisUserModel user = context.UserState["user"] as RedisUserModel; if (user == null) { return new DenyFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; RedisUserModel friend = await RedisUserModel.GetUserFromGuid(request.FriendId); if (friend == null) { return new DenyFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.PLAYER_DOES_NOT_EXIST) } } ; if (!await user.HasFriendRequestFrom(friend)) { return new DenyFriendRequestResponse() { Status = ResponseFactory.createResponse(ResponseType.FRIEND_REQUEST_DOES_NOT_EXIST) } } ; return(new DenyFriendRequestResponse() { Status = await user.RemoveFriendRequestFrom(friend), }); }