trig-ci
Some checks failed
deploy / deploy (push) Has been cancelled

This commit is contained in:
Untone 2023-11-28 23:13:42 +03:00
parent 269c0e449f
commit aaf4c0b876
2 changed files with 8 additions and 5 deletions

View File

@ -44,9 +44,13 @@ class WebhookEndpoint(HTTPEndpoint):
try:
data = await request.json()
if data:
auth = request.headers.get("Authorization")
if auth:
# TODO: check Authorization header
# Extract user_id and slug
user_id = data["user"]["id"]
slug = data["user"]["preferred_username"] or data["user"]["email"].replace(".", "-").split("@").pop()
email_slug = data["user"]["email"].replace(".", "-").split("@").pop()
slug = data["user"]["preferred_username"] or email_slug
await create_author(user_id, slug)
return JSONResponse({"status": "success"})
except Exception as e:

View File

@ -243,7 +243,6 @@ async def rate_author(_, info, rated_slug, value):
async def create_author(user_id: str, slug: str):
with local_session() as session:
# TODO: check Authorization header
new_author = Author(user=user_id, slug=slug)
session.add(new_author)
session.commit()