Grab links from the sign
This commit is contained in:
parent
f25fa9f025
commit
4b5d0181b5
|
@ -30,6 +30,7 @@ DEFAULTS = {
|
||||||
'track': {},
|
'track': {},
|
||||||
'alarm': {},
|
'alarm': {},
|
||||||
'sign': '',
|
'sign': '',
|
||||||
|
'link': '',
|
||||||
'autoscan': '',
|
'autoscan': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -576,15 +576,19 @@ class StatsViewSet(viewsets.ViewSet, List):
|
||||||
def sign(self, request):
|
def sign(self, request):
|
||||||
try:
|
try:
|
||||||
sign = request.data['sign'][:500]
|
sign = request.data['sign'][:500]
|
||||||
cache.set('sign', sign)
|
|
||||||
|
|
||||||
if secrets.SIGN_TOKEN:
|
if sign.startswith('https://') or sign.startswith('http://'):
|
||||||
try:
|
cache.set('link', sign)
|
||||||
post_data = dict(access_token=secrets.SIGN_TOKEN, args=sign)
|
else:
|
||||||
r = requests.post('https://api.particle.io/v1/devices/200042000647343232363230/text/', data=post_data, timeout=5)
|
cache.set('sign', sign)
|
||||||
r.raise_for_status()
|
|
||||||
except:
|
if secrets.SIGN_TOKEN:
|
||||||
raise exceptions.ValidationError(dict(sign='Something went wrong :('))
|
try:
|
||||||
|
post_data = dict(access_token=secrets.SIGN_TOKEN, args=sign)
|
||||||
|
r = requests.post('https://api.particle.io/v1/devices/200042000647343232363230/text/', data=post_data, timeout=5)
|
||||||
|
r.raise_for_status()
|
||||||
|
except:
|
||||||
|
raise exceptions.ValidationError(dict(sign='Something went wrong :('))
|
||||||
|
|
||||||
return Response(200)
|
return Response(200)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user