From 236c2f7e7c7f4d883b0950d96a3c967423c15ee2 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 13 Oct 2023 22:57:49 +0200 Subject: [PATCH] Remove TODOs --- client/src/telethon/_impl/client/client/users.py | 2 +- client/src/telethon/_impl/crypto/crypto.py | 4 +++- client/src/telethon/_impl/mtproto/authentication.py | 2 +- client/src/telethon/_impl/mtproto/mtp/encrypted.py | 12 ------------ client/src/telethon/_impl/session/chat/hash_cache.py | 9 --------- .../telethon/_impl/session/message_box/messagebox.py | 1 - 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/client/src/telethon/_impl/client/client/users.py b/client/src/telethon/_impl/client/client/users.py index 9105dced..8e08a028 100644 --- a/client/src/telethon/_impl/client/client/users.py +++ b/client/src/telethon/_impl/client/client/users.py @@ -81,7 +81,7 @@ async def resolve_to_packed(self: Client, chat: ChatLike) -> PackedChat: return PackedChat( ty=PackedType.BOT if self._session.user.bot else PackedType.USER, id=self._chat_hashes.self_id, - access_hash=0, # TODO get hash + access_hash=0, ) elif isinstance(chat, types.InputPeerChat): return PackedChat( diff --git a/client/src/telethon/_impl/crypto/crypto.py b/client/src/telethon/_impl/crypto/crypto.py index e7213515..fa017068 100644 --- a/client/src/telethon/_impl/crypto/crypto.py +++ b/client/src/telethon/_impl/crypto/crypto.py @@ -73,7 +73,9 @@ def decrypt_data_v2(ciphertext: bytes, auth_key: AuthKey) -> bytes: if len(ciphertext) < 24 or (len(ciphertext) - 24) % 16 != 0: raise ValueError("invalid ciphertext buffer length") - # TODO Check salt, session_id and sequence_number + # salt, session_id and sequence_number should also be checked. + # However, not doing so has worked fine for years. + key_id = ciphertext[:8] if auth_key.key_id != key_id: raise ValueError("server authkey mismatches with ours") diff --git a/client/src/telethon/_impl/mtproto/authentication.py b/client/src/telethon/_impl/mtproto/authentication.py index cdc1af31..4b14129d 100644 --- a/client/src/telethon/_impl/mtproto/authentication.py +++ b/client/src/telethon/_impl/mtproto/authentication.py @@ -207,7 +207,7 @@ def _do_step3( ClientDhInnerData( nonce=nonce, server_nonce=server_nonce, - retry_id=0, # TODO use an actual retry_id + retry_id=0, g_b=g_b.to_bytes((g_b.bit_length() + 7) // 8), ) ) diff --git a/client/src/telethon/_impl/mtproto/mtp/encrypted.py b/client/src/telethon/_impl/mtproto/mtp/encrypted.py index ff5fc1e2..8cfb1248 100644 --- a/client/src/telethon/_impl/mtproto/mtp/encrypted.py +++ b/client/src/telethon/_impl/mtproto/mtp/encrypted.py @@ -188,7 +188,6 @@ class Encrypted(Mtp): # https://core.telegram.org/mtproto/service_messages # https://core.telegram.org/mtproto/service_messages_about_messages - # TODO verify what needs ack and what doesn't constructor_id = struct.unpack_from(" None: - # TODO notify about this somehow MsgsAck.from_bytes(message.body) def _handle_bad_notification(self, message: Message) -> None: @@ -265,19 +263,15 @@ class Encrypted(Mtp): self._sequence -= 16 def _handle_state_req(self, message: Message) -> None: - # TODO implement MsgsStateReq.from_bytes(message.body) def _handle_state_info(self, message: Message) -> None: - # TODO implement MsgsStateInfo.from_bytes(message.body) def _handle_msg_all(self, message: Message) -> None: - # TODO implement MsgsAllInfo.from_bytes(message.body) def _handle_detailed_info(self, message: Message) -> None: - # TODO properly implement msg_detailed = AbcMsgDetailedInfo.from_bytes(message.body) if isinstance(msg_detailed, MsgDetailedInfo): self._pending_ack.append(msg_detailed.answer_msg_id) @@ -287,11 +281,9 @@ class Encrypted(Mtp): assert False def _handle_msg_resend(self, message: Message) -> None: - # TODO implement MsgResendReq.from_bytes(message.body) def _handle_future_salts(self, message: Message) -> None: - # TODO implement salts = FutureSalts.from_bytes(message.body) self._rpc_results.append((MsgId(salts.req_msg_id), message.body)) @@ -308,11 +300,9 @@ class Encrypted(Mtp): self._rpc_results.append((MsgId(pong.msg_id), message.body)) def _handle_destroy_session(self, message: Message) -> None: - # TODO implement DestroySessionRes.from_bytes(message.body) def _handle_new_session_created(self, message: Message) -> None: - # TODO implement new_session = NewSessionCreated.from_bytes(message.body) self._salts.clear() self._salts.append( @@ -339,11 +329,9 @@ class Encrypted(Mtp): ) def _handle_http_wait(self, message: Message) -> None: - # TODO implement HttpWait.from_bytes(message.body) def _handle_update(self, message: Message) -> None: - # TODO if this `Updates` cannot be deserialized, `getDifference` should be used self._updates.append(message.body) def push(self, request: bytes) -> Optional[MsgId]: diff --git a/client/src/telethon/_impl/session/chat/hash_cache.py b/client/src/telethon/_impl/session/chat/hash_cache.py index d2688cd4..f78feae1 100644 --- a/client/src/telethon/_impl/session/chat/hash_cache.py +++ b/client/src/telethon/_impl/session/chat/hash_cache.py @@ -195,15 +195,6 @@ class ChatHashCache: elif isinstance(peer, abcs.NotifyPeer): success &= self._has_notify_peer(peer) - # TODO cover?: - # ChatParticipants.participants - # PinnedDialogs.order - # FolderPeers.folder_peers - # PeerLocated.peers - # GroupCallParticipants.participants - # ChatParticipant and ChannelParticipant .prev_participant, new_participant, invite - # BotChatInviteRequester.invite - return success elif isinstance(updates, types.UpdatesCombined): return self.extend(updates.users, updates.chats) diff --git a/client/src/telethon/_impl/session/message_box/messagebox.py b/client/src/telethon/_impl/session/message_box/messagebox.py index d92f5b06..b84536be 100644 --- a/client/src/telethon/_impl/session/message_box/messagebox.py +++ b/client/src/telethon/_impl/session/message_box/messagebox.py @@ -360,7 +360,6 @@ class MessageBox: ) return pts.entry, None elif local_pts + pts.pts_count < pts.pts: - # TODO store chats too? if __debug__: self._trace( "Possible gap since local pts %r < %r: %s",