bug fixes and performance enhancements

This commit is contained in:
Lynne Megido 2018-11-13 00:16:51 +10:00
parent 0279b09690
commit 4bbc6ab393
Signed by: lynnesbian
GPG key ID: FB7B970303ACE499

9
web.py
View file

@ -6,7 +6,8 @@
#TODO: ADD RETROSPRING SUPPORT! #TODO: ADD RETROSPRING SUPPORT!
import requests, json, hashlib, urllib, time, re, random import json, hashlib, urllib, time, re, random
import requests
from mastodon import Mastodon from mastodon import Mastodon
from flask import Flask, render_template, request, session, redirect, url_for from flask import Flask, render_template, request, session, redirect, url_for
import mysql.connector import mysql.connector
@ -195,7 +196,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'] "latest_post":j['posts'][0]['timestamp'] #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')
@ -203,7 +204,7 @@ def ccc_a(): #step one of curiouscat connection: retreive details
def cc_connect_confirm(): def cc_connect_confirm():
return render_template('cc_connect_confirm.html', bg="background-image:url('{}')".format(session['cctemp']['ccavi'])) return render_template('cc_connect_confirm.html', bg="background-image:url('{}')".format(session['cctemp']['ccavi']))
@app.route('/internal/ccc_b') @app.route('/internal/ccc_b') #TODO: don't allow people to spam this
def ccc_b(): def ccc_b():
session['cctemp']['challenge'] = random.randint(100000, 999999) session['cctemp']['challenge'] = random.randint(100000, 999999)
session.modified = True session.modified = True
@ -230,7 +231,7 @@ def ccc_c():
return redirect('/cc_connect/code?invalid') return redirect('/cc_connect/code?invalid')
for item in ['cc', 'ccavi']: for item in ['cc', 'ccavi']:
session[item] = session['cctemp'][item] session[item] = session['cctemp'][item]
c.execute("UPDATE data SET cc = %s, ccavi = %s, latest_post = %s, time_between_checks = %s WHERE username = %s AND instance = %s", (session['cc'], session['ccavi'], session['cctemp']['latest_post'], 1, session['username'], session['instance'])) c.execute("UPDATE data SET cc = %s, ccavi = %s, latest_post = %s, time_between_checks = %s, last_check = %s WHERE username = %s AND instance = %s", (session['cc'], session['ccavi'], session['cctemp']['latest_post'], 1, 0, session['username'], session['instance']))
return redirect('/cc_connect/complete') return redirect('/cc_connect/complete')
@app.route('/cc_connect/complete') @app.route('/cc_connect/complete')