forked from mtusi2026/mtusi2026lab2
finished
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from uuid import UUID
|
||||
|
||||
from .timeutil import fmt_dt
|
||||
|
||||
|
||||
def user_json(row) -> dict:
|
||||
return {
|
||||
"id": str(row["id"]),
|
||||
"username": row["username"],
|
||||
"display_name": row["display_name"],
|
||||
"created_at": fmt_dt(row["created_at"]),
|
||||
}
|
||||
|
||||
|
||||
def chat_json(row, member_ids: list[UUID]) -> dict:
|
||||
return {
|
||||
"id": str(row["id"]),
|
||||
"title": row["title"],
|
||||
"member_ids": [str(x) for x in member_ids],
|
||||
"created_at": fmt_dt(row["created_at"]),
|
||||
}
|
||||
|
||||
|
||||
def message_json(row) -> dict:
|
||||
return {
|
||||
"id": str(row["id"]),
|
||||
"chat_id": str(row["chat_id"]),
|
||||
"sender_id": str(row["sender_id"]),
|
||||
"text": row["text"],
|
||||
"created_at": fmt_dt(row["created_at"]),
|
||||
}
|
||||
Reference in New Issue
Block a user