mirror of https://gitlab.com/litecord/litecord.git
add support for user.bio, user.accent_color CRUD
This commit is contained in:
parent
266bb0a07b
commit
0a429ee47e
|
|
@ -227,6 +227,28 @@ async def patch_me():
|
||||||
user_id,
|
user_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if to_update(j, user, "bio"):
|
||||||
|
await app.db.execute(
|
||||||
|
"""
|
||||||
|
UPDATE users
|
||||||
|
SET bio = $1
|
||||||
|
WHERE id = $2
|
||||||
|
""",
|
||||||
|
j["bio"],
|
||||||
|
user_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
if to_update(j, user, "accent_color"):
|
||||||
|
await app.db.execute(
|
||||||
|
"""
|
||||||
|
UPDATE users
|
||||||
|
SET accent_color = $1
|
||||||
|
WHERE id = $2
|
||||||
|
""",
|
||||||
|
j["accent_color"],
|
||||||
|
user_id,
|
||||||
|
)
|
||||||
|
|
||||||
if user["email"] is None and "new_password" not in j:
|
if user["email"] is None and "new_password" not in j:
|
||||||
raise BadRequest("missing password", {"password": "Please set a password."})
|
raise BadRequest("missing password", {"password": "Please set a password."})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,8 @@ class Storage:
|
||||||
"flags",
|
"flags",
|
||||||
"bot",
|
"bot",
|
||||||
"premium_since",
|
"premium_since",
|
||||||
|
"bio",
|
||||||
|
"accent_color",
|
||||||
]
|
]
|
||||||
|
|
||||||
if secure:
|
if secure:
|
||||||
|
|
|
||||||
|
|
@ -102,3 +102,21 @@ async def test_create_user(test_cli):
|
||||||
""",
|
""",
|
||||||
int(rjson["id"]),
|
int(rjson["id"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
WANTED_BIO = "hello world!"
|
||||||
|
WANTED_ACCENT_COLOR = 0x424242
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_patch_me_bio_accent_color(test_cli_user):
|
||||||
|
resp = await test_cli_user.patch(
|
||||||
|
"/api/v6/users/@me",
|
||||||
|
json={"bio": WANTED_BIO, "accent_color": WANTED_ACCENT_COLOR},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert resp.status_code == 200
|
||||||
|
rjson = await resp.json
|
||||||
|
assert isinstance(rjson, dict)
|
||||||
|
assert rjson["bio"] == WANTED_BIO
|
||||||
|
assert rjson["accent_color"] == WANTED_ACCENT_COLOR
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue