Skip to content

Commit

Permalink
2.12.2 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludy87 authored Jan 24, 2024
1 parent 75e0d48 commit 3895fe9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/pyxplora_api/const_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = "2.12.1"
VERSION = "2.12.2"
VERSION_APP = "1298"
4 changes: 2 additions & 2 deletions src/pyxplora_api/gql_handler_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .exception_classes import ErrorMSG, HandlerException, LoginError, NoAdminError
from .graphql_client import GraphqlClient
from .handler_gql import HandlerGQL
from .model import Chats
from .model import Chats, ChatsNew
from .status import EmailAndPhoneVerificationTypeV2, NormalStatus, UserContactType

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -205,7 +205,7 @@ async def silentTimes_a(self, wuid: str) -> dict[str, Any]:

async def chats_a(
self, wuid: str, offset: int = 0, limit: int = 0, msgId: str = "", asObject=False
) -> dict[str, Any] | Chats:
) -> dict[str, Any] | Chats | ChatsNew | str | None:
# ownUser id
res: dict = await self.runGqlQuery_a(
gq.WATCH_Q.get("chatsQ", ""), {"uid": wuid, "offset": offset, "limit": limit, "msgId": msgId}, "Chats"
Expand Down
23 changes: 18 additions & 5 deletions src/pyxplora_api/pyxplora_api_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
from datetime import datetime
import json
import logging
from time import time
from typing import Any
Expand Down Expand Up @@ -404,12 +405,26 @@ async def getWatchChatsRaw(
while not chats_new and retry_counter < self.maxRetries + 2:
retry_counter += 1
try:
result = await self._gql_handler.chats_a(wuid, offset, limit, msgId, asObject)
result: dict[str, Any] | Chats | ChatsNew | str | None = await self._gql_handler.chats_a(
wuid, offset, limit, msgId, asObject
)

if not result:
continue

if result == "":
result = ChatsNew()

if isinstance(result, str):
result = json.loads(result)

if isinstance(result, dict):
result = ChatsNew.from_dict(result.get("chatsNew", None))
elif isinstance(result, Chats):
if result.get("chatsNew", None):
result = ChatsNew.from_dict(result.get("chatsNew", None))
else:
result = ChatsNew()

if isinstance(result, Chats):
result = result.chatsNew

if result is None:
Expand All @@ -421,8 +436,6 @@ async def getWatchChatsRaw(
d.data.emoticon_id = Emoji[f"M{d.data.emoticon_id}"].value
await self.set_read_chat_msg(wuid, d.msgId, d.id)

result = ChatsNew.from_dict(result)

filtered_chats = [chat for chat in result.list if show_del_msg or chat.data.delete_flag == 0]
chats_new = ChatsNew(filtered_chats).to_dict()
except Error as error:
Expand Down

0 comments on commit 3895fe9

Please sign in to comment.