parent
269c0e449f
commit
aaf4c0b876
6
main.py
6
main.py
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user