def get(request): interface_url = cgf_lambda_settings.get_service_url( "CloudGemPlayerAccount_banplayer_1_0_0") if not interface_url: return {"players": ban_handler.get_banned_players()} service_client = cgf_service_client.for_url( interface_url, verbose=True, session=boto3._get_default_session()) result = service_client.navigate('list').GET() return result.DATA
def is_player_banned(user): global BAN_TABLE interface_url = cgf_lambda_settings.get_service_url( "CloudGemPlayerAccount_banplayer_1_0_0") if interface_url: return check_player_account_gem_for_ban(interface_url, user) __init_globals() player_ban = __get_player_ban(user) if not player_ban: return False return True
def post(request, user = None): interface_url = cgf_lambda_settings.get_service_url("CloudGemPlayerAccount_banplayer_1_0_0") if not interface_url: return { "status": ban_handler.ban(user) } service_client = cgf_service_client.for_url(interface_url, verbose=True, session=boto3._get_default_session()) result = service_client.navigate('playerban').POST({"id": identity_validator.get_id_from_user(user)}) return result.DATA
def __send_communicator_broadcast(message): if not __do_communicator_updates(): return interface_url = cgf_lambda_settings.get_service_url("CloudGemWebCommunicator_sendmessage_1_0_0") if not interface_url: print 'Messaging interface not found' return client = cgf_service_client.for_url(interface_url, verbose=True, session=boto3._get_default_session()) try: result = client.navigate('broadcast').POST({"channel": "CloudGemDynamicContent", "message": message}) print 'Got send result {}'.format(result) except Exception as error: raise errors.ClientError('Failed to broadcast {} due to error: {}'.format(message, error))
def validate_user(user, cognito_id): if not cognito_id: return False interface_url = cgf_lambda_settings.get_service_url("CloudGemPlayerAccount_banplayer_1_0_0") if interface_url: if validate_using_player_account_gem(interface_url, user, cognito_id): record_user_id_mapping(user, cognito_id) return True return False init_resources() response = IDENTITY_MAP.get_item(Key={"user": user}) item = response.get("Item", {}) if not item: item["user"] = user item["cognito_id"] = cognito_id IDENTITY_MAP.put_item(Item=item) return True return item.get("cognito_id", "") == cognito_id
def delete(request, user=None): """ Call PlayerAccount to unban the player Player must be a registered uer in the PlayerAccount Gem and Leaderboards must have seen the player via a data request to have a mapping between the user name and the cognition identity (for get_id_from_user) """ print("Handling player unban for {}".format(user)) interface_url = cgf_lambda_settings.get_service_url( "CloudGemPlayerAccount_banplayer_1_0_0") if not interface_url: return {"status": ban_handler.lift_ban(user)} service_client = cgf_service_client.for_url( interface_url, verbose=True, session=boto3._get_default_session()) navigation = service_client.navigate('playerban') cog_id = identity_validator.get_id_from_user(user) if cog_id is None: raise errors.ClientError(UNKNOWN_PLAYER_ERROR_MESSAGE.format(user)) result = navigation.DELETE({"id": cog_id}) return result.DATA