def add_device_token(tokens, request): """ Adds a user device token Adds a new user device linked to a user. If the token already exists for any user, we'll assume that the new user is using the old user's device, so we'll delete all the previous tokens and replace them with the new one. """ newtoken = Token.from_request(request) if '_id' in newtoken: newtoken.delete() newtoken = Token.from_request(request) # insert the token always newtoken.insert() handler = JSONResourceEntity(request, newtoken.flatten(), status_code=201) return handler.buildResponse()
def add_device_token(tokens, request): """ Adds a user device token Adds a new user device linked to a user. If the token already exists for any user, we'll assume that the new user is using the old user's device, so we'll delete all the previous tokens and replace them with the new one. 16/07/2018 Si este WS nos devuelve un 404 y no entra, es que no tenemos en el nginx del max el /tokens la nueva APP Utalk lo utiliza la antigua utiliza el fix_deprecated_add_token POST /people/{username}/device/{platform}/{token} """ newtoken = Token.from_request(request) if '_id' in newtoken: newtoken.delete() newtoken = Token.from_request(request) # insert the token always newtoken.insert() handler = JSONResourceEntity(request, newtoken.flatten(), status_code=201) return handler.buildResponse()