user.settings: fix json encoding when patching settings

should fix issues with restricted_guilds and the overall guild position.
This commit is contained in:
Luna Mendes 2018-11-22 16:05:42 -03:00
parent a784d100e7
commit 1b529c4af3
1 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,5 @@
import json
from quart import Blueprint, jsonify, request, current_app as app
from litecord.auth import token_check
@ -25,7 +27,14 @@ async def patch_current_settings():
user_id = await token_check()
j = validate(await request.get_json(), USER_SETTINGS)
json_fields = ['guild_positions', 'restricted_guilds']
for key in j:
val = j[key]
if key in json_fields:
val = json.dumps(val)
await app.db.execute(f"""
UPDATE user_settings
SET {key}=$1