Skip to content

Commit 8f2e4f0

Browse files
committed
Fix access to invalid attributes when parsing a chat dc_id
1 parent b39f2c4 commit 8f2e4f0

File tree

1 file changed

+3
-3
lines changed
  • pyrogram/types/user_and_chats

1 file changed

+3
-3
lines changed

pyrogram/types/user_and_chats/chat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _parse_user_chat(client, user: raw.types.User) -> "Chat":
180180
last_name=user.last_name,
181181
photo=types.ChatPhoto._parse(client, user.photo, peer_id, user.access_hash),
182182
restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None,
183-
dc_id=getattr(user.photo, "dc_id", None),
183+
dc_id=getattr(getattr(user, "photo", None), "dc_id", None),
184184
client=client
185185
)
186186

@@ -196,7 +196,7 @@ def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
196196
photo=types.ChatPhoto._parse(client, getattr(chat, "photo", None), peer_id, 0),
197197
permissions=types.ChatPermissions._parse(getattr(chat, "default_banned_rights", None)),
198198
members_count=getattr(chat, "participants_count", None),
199-
dc_id=getattr(chat.photo, "dc_id", None),
199+
dc_id=getattr(getattr(chat, "photo", None), "dc_id", None),
200200
client=client
201201
)
202202

@@ -218,7 +218,7 @@ def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
218218
restrictions=types.List([types.Restriction._parse(r) for r in restriction_reason]) or None,
219219
permissions=types.ChatPermissions._parse(getattr(channel, "default_banned_rights", None)),
220220
members_count=getattr(channel, "participants_count", None),
221-
dc_id=getattr(channel.photo, "dc_id", None),
221+
dc_id=getattr(getattr(channel, "photo", None), "dc_id", None),
222222
client=client
223223
)
224224

0 commit comments

Comments
 (0)