fix(userbot): encode absent pyrogram raw payloads as empty json

This commit is contained in:
hh committed 2026-09-06 21:26:13 +02:00
1 parent 6a6e63ff75
commit 676680319b
15 files changed
+63 -25

No files matched your search

+7 -4
View File
@@ -7,6 +7,7 @@ from userbot.modules.avatars import capture_avatar
from userbot.modules.profiles import active_username, snapshot_from_user
from userbot.modules.profiles.parse import ProfileFields
from userbot.modules.profiles.repository import get_peer, write_profile
from userbot.modules.raw_json import raw_json
HANDLES = (raw.types.UpdateUserName, raw.types.UpdateUser, raw.types.UpdateUserPhone)
@@ -24,7 +25,9 @@ async def _handle_user(
current = await get_peer(ctx.pool, ctx.account_id, update.user_id)
if current == fields:
return
await write_profile(ctx.pool, ctx.account_id, update.user_id, fields, str(raw_user))
await write_profile(
ctx.pool, ctx.account_id, update.user_id, fields, raw_json(raw_user)
)
changed_photo = current is None or current.photo_unique_id != photo_unique_id
if photo_file_id and photo_unique_id and changed_photo:
await capture_avatar(
@@ -34,7 +37,7 @@ async def _handle_user(
"peer",
photo_file_id,
photo_unique_id,
str(raw_user),
raw_json(raw_user),
)
@@ -65,9 +68,9 @@ async def handle(
"last_name": update.last_name or None,
"username": active_username(update.usernames),
},
str(update),
raw_json(update),
)
elif isinstance(update, raw.types.UpdateUserPhone):
await _merge_partial(
client, update.user_id, {"phone": update.phone or None}, str(update)
client, update.user_id, {"phone": update.phone or None}, raw_json(update)
)