fix bug ocurring when user has no cc posts, only request a single post for ccc_a

This commit is contained in:
Lynne Megido 2018-11-13 21:14:57 +10:00
parent cb30496d62
commit 145492690b
Signed by: lynnesbian
GPG key ID: FB7B970303ACE499

4
web.py
View file

@ -193,7 +193,7 @@ def cc_connect():
@app.route('/internal/ccc_a', methods=['POST'])
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()
if 'error' in j:
return redirect('/cc_connect?invalid')
@ -201,7 +201,7 @@ def ccc_a(): #step one of curiouscat connection: retreive details
"cc":j['userData']['username'],
"ccavi":j['userData']['avatar'],
"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')