diff --git a/tg/controllers.py b/tg/controllers.py index afaf86b..ef3f6a6 100644 --- a/tg/controllers.py +++ b/tg/controllers.py @@ -873,7 +873,7 @@ class Controller: return # notify - if self.model.is_me(msg["sender"].get("user_id")): + if self.model.is_me(msg["sender_id"].get("user_id")): return user = self.model.users.get_user(msg.sender_id) name = f"{user['first_name']} {user['last_name']}" diff --git a/tg/models.py b/tg/models.py index 15f7ec7..98409bb 100644 --- a/tg/models.py +++ b/tg/models.py @@ -175,7 +175,7 @@ class Model: return False def can_be_deleted(self, chat_id: int, msg: Dict[str, Any]) -> bool: - c_id = msg["sender"].get("chat_id") or msg["sender"].get("user_id") + c_id = msg["sender_id"].get("chat_id") or msg["sender_id"].get("user_id") if chat_id == c_id: return msg["can_be_deleted_only_for_self"] return msg["can_be_deleted_for_all_users"] diff --git a/tg/msg.py b/tg/msg.py index 5c35ef4..c9e56e0 100644 --- a/tg/msg.py +++ b/tg/msg.py @@ -220,7 +220,7 @@ class MsgProxy: @property def sender_id(self) -> int: - return self.msg["sender"].get("user_id") or self.msg["sender"].get( + return self.msg["sender_id"].get("user_id") or self.msg["sender_id"].get( "chat_id" ) diff --git a/tg/views.py b/tg/views.py index 20e6756..3facfc2 100644 --- a/tg/views.py +++ b/tg/views.py @@ -262,7 +262,7 @@ class ChatView: msg = chat.get("last_message") if ( msg - and self.model.is_me(msg["sender"].get("user_id")) + and self.model.is_me(msg["sender_id"].get("user_id")) and msg["id"] > chat["last_read_outbox_message_id"] and not self.model.is_me(chat["id"]) ): @@ -270,7 +270,7 @@ class ChatView: flags.append("unseen") elif ( msg - and self.model.is_me(msg["sender"].get("user_id")) + and self.model.is_me(msg["sender_id"].get("user_id")) and msg["id"] <= chat["last_read_outbox_message_id"] ): flags.append("seen") @@ -610,7 +610,7 @@ def get_last_msg( if not last_msg: return None, "" return ( - last_msg["sender"].get("user_id"), + last_msg["sender_id"].get("user_id"), parse_content(MsgProxy(last_msg), users), )