maybe fixes

This commit is contained in:
Alexey Polyakov
2026-05-14 17:30:57 +03:00
parent c5721f3f9e
commit c0e23840b5
8 changed files with 46 additions and 33 deletions

View File

@@ -49,6 +49,9 @@ class SQLiteConnectionCompat:
async def __aexit__(self, exc_type, exc, tb): async def __aexit__(self, exc_type, exc, tb):
return False return False
async def commit(self):
await self.connection.commit()
def cursor(self): def cursor(self):
return SQLiteCursorCompat(self.connection) return SQLiteCursorCompat(self.connection)

View File

@@ -39,17 +39,17 @@ class Tools:
def generate_profile( def generate_profile(
self, self,
id=1, id=None,
phone=70000000000, phone=None,
avatarUrl=None, avatarUrl=None,
photoId=None, photoId=None,
updateTime=0, updateTime=None,
firstName="Test", firstName=None,
lastName="Account", lastName=None,
options=[], options=None,
description=None, description=None,
accountStatus=0, accountStatus=None,
profileOptions=[], profileOptions=None,
includeProfileOptions=True, includeProfileOptions=True,
username=None, username=None,
@@ -108,31 +108,32 @@ class Tools:
def generate_profile_tt( def generate_profile_tt(
self, self,
id=1, id=None,
phone=70000000000, phone=None,
avatarUrl=None, avatarUrl=None,
photoId=None, photoId=None,
updateTime=0, updateTime=None,
firstName="Test", firstName=None,
lastName="Account", lastName=None,
options=[], options=None,
description=None, description=None,
username=None, username=None,
custom_firstname=None, custom_firstname=None,
custom_lastname=None custom_lastname=None,
blocked=None
): ):
# Так как TT не поддерживает фамилию, и если нам ее не передали в функцию # Так как TT не поддерживает фамилию, и если нам ее не передали в функцию
# то используем только имя, чтобы избежать None в фамилии # то используем только имя, чтобы избежать None в фамилии
if firstName and lastName: if firstName and lastName:
name = f"{firstName} {lastName}", name = f"{firstName} {lastName}"
else: else:
name = firstName name = firstName
# Используем такой же костыль, как и выше # Используем такой же костыль, как и выше
if custom_firstname: if custom_firstname and custom_lastname:
custom_name = custom_firstname
elif custom_firstname and custom_lastname:
custom_name = f"{custom_firstname} {custom_lastname}" custom_name = f"{custom_firstname} {custom_lastname}"
elif custom_firstname:
custom_name = custom_firstname
else: else:
custom_name = None custom_name = None
@@ -163,6 +164,9 @@ class Tools:
{"name": custom_name, "type": "CUSTOM"} {"name": custom_name, "type": "CUSTOM"}
) )
if blocked:
contact["status"] = "BLOCKED"
return contact return contact
def generate_chat( def generate_chat(

View File

@@ -22,6 +22,7 @@ class OnemeController(ControllerBase):
# Выбираем протокол в зависимости от типа подключения # Выбираем протокол в зависимости от типа подключения
proto = self.proto_web if is_web else self.proto_tcp proto = self.proto_web if is_web else self.proto_tcp
packet = None
# Не отправляем событие самому себе # Не отправляем событие самому себе
if writer == eventData.get("writer"): if writer == eventData.get("writer"):
@@ -94,7 +95,9 @@ class OnemeController(ControllerBase):
cmd=0, seq=1, opcode=self.opcodes.NOTIF_PRESENCE, payload=payload cmd=0, seq=1, opcode=self.opcodes.NOTIF_PRESENCE, payload=payload
) )
# Отправляем пакет if not packet:
return
if is_web: if is_web:
await writer.send(packet) await writer.send(packet)
else: else:

View File

@@ -297,7 +297,7 @@ class AuthProcessors(BaseProcessor):
photoId = ( photoId = (
None if not account.get("avatar_id") else int(account.get("avatar_id")) None if not account.get("avatar_id") else int(account.get("avatar_id"))
) )
avatar_url = None if not photoId else self.config.avatar_base_url + photoId avatar_url = None if not photoId else self.config.avatar_base_url + str(photoId)
description = ( description = (
None if not account.get("description") else account.get("description") None if not account.get("description") else account.get("description")
) )
@@ -521,7 +521,7 @@ class AuthProcessors(BaseProcessor):
await self._send_error( await self._send_error(
seq, self.opcodes.LOGIN, self.error_types.INVALID_PAYLOAD, writer seq, self.opcodes.LOGIN, self.error_types.INVALID_PAYLOAD, writer
) )
return return None, None, None
# Чаты, где состоит пользователь # Чаты, где состоит пользователь
chats = [] chats = []
@@ -545,7 +545,7 @@ class AuthProcessors(BaseProcessor):
await self._send_error( await self._send_error(
seq, self.opcodes.LOGIN, self.error_types.INVALID_TOKEN, writer seq, self.opcodes.LOGIN, self.error_types.INVALID_TOKEN, writer
) )
return return None, None, None
# Ищем аккаунт пользователя в бд # Ищем аккаунт пользователя в бд
await cursor.execute( await cursor.execute(
@@ -563,7 +563,7 @@ class AuthProcessors(BaseProcessor):
# Ищем все чаты, где состоит пользователь # Ищем все чаты, где состоит пользователь
await cursor.execute( await cursor.execute(
"SELECT * FROM chat_participants WHERE user_id = %s", "SELECT * FROM chat_participants WHERE user_id = %s",
(user.get("id")), (user.get("id"),),
) )
user_chats = await cursor.fetchall() user_chats = await cursor.fetchall()
@@ -578,7 +578,7 @@ class AuthProcessors(BaseProcessor):
# Аватарка с биографией # Аватарка с биографией
photoId = None if not user.get("avatar_id") else int(user.get("avatar_id")) photoId = None if not user.get("avatar_id") else int(user.get("avatar_id"))
avatar_url = None if not photoId else self.config.avatar_base_url + photoId avatar_url = None if not photoId else self.config.avatar_base_url + str(photoId)
description = None if not user.get("description") else user.get("description") description = None if not user.get("description") else user.get("description")
if self._check_legacy_version(appVersion): if self._check_legacy_version(appVersion):

View File

@@ -153,7 +153,7 @@ class MainProcessors(BaseProcessor):
# Аватарка с биографией # Аватарка с биографией
photoId = None if not user.get("avatar_id") else int(user.get("avatar_id")) photoId = None if not user.get("avatar_id") else int(user.get("avatar_id"))
avatar_url = None if not photoId else self.config.avatar_base_url + photoId avatar_url = None if not photoId else self.config.avatar_base_url + str(photoId)
description = None if not user.get("description") else user.get("description") description = None if not user.get("description") else user.get("description")
# Генерируем профиль # Генерируем профиль

View File

@@ -36,7 +36,7 @@ class SearchProcessors(BaseProcessor):
if user: if user:
# Аватарка с биографией # Аватарка с биографией
photoId = None if not user.get("avatar_id") else int(user.get("avatar_id")) photoId = None if not user.get("avatar_id") else int(user.get("avatar_id"))
avatar_url = None if not photoId else self.config.avatar_base_url + photoId avatar_url = None if not photoId else self.config.avatar_base_url + str(photoId)
description = None if not user.get("description") else user.get("description") description = None if not user.get("description") else user.get("description")
# Получаем данные контакта # Получаем данные контакта
@@ -129,7 +129,7 @@ class SearchProcessors(BaseProcessor):
# Аватарка с биографией # Аватарка с биографией
photoId = None if not user.get("avatar_id") else int(user.get("avatar_id")) photoId = None if not user.get("avatar_id") else int(user.get("avatar_id"))
avatar_url = None if not photoId else self.config.avatar_base_url + photoId avatar_url = None if not photoId else self.config.avatar_base_url + str(photoId)
description = None if not user.get("description") else user.get("description") description = None if not user.get("description") else user.get("description")
# Получаем данные контакта # Получаем данные контакта

View File

@@ -22,6 +22,7 @@ class TTController(ControllerBase):
# Выбираем протокол в зависимости от типа подключения # Выбираем протокол в зависимости от типа подключения
proto = self.proto_web if is_web else self.proto_tcp proto = self.proto_web if is_web else self.proto_tcp
packet = None
# Не отправляем событие самому себе # Не отправляем событие самому себе
if writer == eventData.get("writer"): if writer == eventData.get("writer"):
@@ -94,7 +95,9 @@ class TTController(ControllerBase):
cmd=0, seq=1, opcode=self.opcodes.NOTIF_PRESENCE, payload=payload cmd=0, seq=1, opcode=self.opcodes.NOTIF_PRESENCE, payload=payload
) )
# Отправляем пакет if not packet:
return
if is_web: if is_web:
await writer.send(packet) await writer.send(packet)
else: else:

View File

@@ -443,7 +443,7 @@ class AuthProcessors(BaseProcessor):
self.logger.error(f"Возникли ошибки при валидации пакета: {e}") self.logger.error(f"Возникли ошибки при валидации пакета: {e}")
await self._send_error(seq, self.opcodes.LOGIN, await self._send_error(seq, self.opcodes.LOGIN,
self.error_types.INVALID_PAYLOAD, writer) self.error_types.INVALID_PAYLOAD, writer)
return return None, None, None
# Чаты, где состоит пользователь # Чаты, где состоит пользователь
chats = [] chats = []
@@ -464,7 +464,7 @@ class AuthProcessors(BaseProcessor):
if token_data is None: if token_data is None:
await self._send_error(seq, self.opcodes.LOGIN, await self._send_error(seq, self.opcodes.LOGIN,
self.error_types.INVALID_TOKEN, writer) self.error_types.INVALID_TOKEN, writer)
return return None, None, None
# Ищем аккаунт пользователя в бд # Ищем аккаунт пользователя в бд
await cursor.execute("SELECT * FROM users WHERE phone = %s", (token_data.get("phone"),)) await cursor.execute("SELECT * FROM users WHERE phone = %s", (token_data.get("phone"),))
@@ -477,7 +477,7 @@ class AuthProcessors(BaseProcessor):
# Ищем все чаты, где состоит пользователь # Ищем все чаты, где состоит пользователь
await cursor.execute( await cursor.execute(
"SELECT * FROM chat_participants WHERE user_id = %s", "SELECT * FROM chat_participants WHERE user_id = %s",
(user.get('id')) (user.get('id'),)
) )
user_chats = await cursor.fetchall() user_chats = await cursor.fetchall()