Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions routers/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,39 @@ async def get_chat_info(chatId: str, request: Request, ndcId: int = 0):
)


# vvchat permission precheck
# [POST] /g/s/chat/thread/{chatId}/vvchat-permission
@chats.post("/g/s/chat/thread/{chatId}/vvchat-permission")
@chats.post("/x{ndcId}/s/chat/thread/{chatId}/vvchat-permission")
async def vvchat_permission(request: Request, chatId: str, ndcId: int = 0):
t1 = timestamp()
if not request.state.session["validsession"]:
return Errors.InvalidSession()

trigger_uid = request.state.session["uid"]
payload = await request.json()
vv_chat_join_type = payload.get("vvChatJoinType", 1)
if not isinstance(vv_chat_join_type, int):
return Errors.InvalidRequest(timestamp() - t1)

db = await Database().init()
table = await db.get(f"x{ndcId}", "Chats")
chat_info = await table.find_one({"id": chatId})
if not chat_info:
await db.close()
return Errors.DataNotExist(timestamp() - t1)

# AltAmino client only needs a successful ack for this request.
response = {
"threadId": chatId,
"ndcId": ndcId,
"uid": trigger_uid,
"vvChatJoinType": vv_chat_join_type,
}
await db.close()
return Base.Answer(response, spent_time=timestamp() - t1)


# edit chat
# [POST] /g/s/chat/thread/434cd5b4-a984-42c4-8375-46c1c6e0803d

Expand Down