in sns_endpoint_lambda/lambda.py [0:0]
def delete_other_users_same_endpoint(device_push_endpoint, username, mobileOS):
result = table.query(
# Add the name of the index you want to use in your query.
IndexName="endpoint-index",
KeyConditionExpression=Key('endpoint').eq(device_push_endpoint),
)
for item in result['Items']:
if item['username'] != username and item['mobileOS'] == mobileOS:
print(f"deleting orphan item: username {username}, os {mobileOS}".format(username=item['username'], mobileOS=mobileOS))
table.delete_item(
Key={
'username': item['username'],
'mobileOS': mobileOS
},
)