fix bug ocurring when user has no cc posts, only request a single post for ccc_a
This commit is contained in:
parent
cb30496d62
commit
145492690b
1 changed files with 2 additions and 2 deletions
4
web.py
4
web.py
|
@ -193,7 +193,7 @@ def cc_connect():
|
||||||
|
|
||||||
@app.route('/internal/ccc_a', methods=['POST'])
|
@app.route('/internal/ccc_a', methods=['POST'])
|
||||||
def ccc_a(): #step one of curiouscat connection: retreive details
|
def ccc_a(): #step one of curiouscat connection: retreive details
|
||||||
r = requests.get("https://curiouscat.me/api/v2/profile?username={}".format(request.form['cc']))
|
r = requests.get("https://curiouscat.me/api/v2/profile?username={}&count=1".format(request.form['cc']))
|
||||||
j = r.json()
|
j = r.json()
|
||||||
if 'error' in j:
|
if 'error' in j:
|
||||||
return redirect('/cc_connect?invalid')
|
return redirect('/cc_connect?invalid')
|
||||||
|
@ -201,7 +201,7 @@ def ccc_a(): #step one of curiouscat connection: retreive details
|
||||||
"cc":j['userData']['username'],
|
"cc":j['userData']['username'],
|
||||||
"ccavi":j['userData']['avatar'],
|
"ccavi":j['userData']['avatar'],
|
||||||
"ccid":j['userData']['id'],
|
"ccid":j['userData']['id'],
|
||||||
"latest_post":j['posts'][0]['timestamp'] #only post new answers from this point onwards, rather than posting all the old ones
|
"latest_post":j['posts'][0]['timestamp'] if len(j['posts']) != 0 else 0 #only post new answers from this point onwards, rather than posting all the old ones
|
||||||
}
|
}
|
||||||
return redirect('/cc_connect/confirm')
|
return redirect('/cc_connect/confirm')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue