mirror of
https://github.com/openmax-server/server.git
synced 2026-05-22 19:41:41 +03:00
maybe fixes
This commit is contained in:
@@ -49,6 +49,9 @@ class SQLiteConnectionCompat:
|
||||
async def __aexit__(self, exc_type, exc, tb):
|
||||
return False
|
||||
|
||||
async def commit(self):
|
||||
await self.connection.commit()
|
||||
|
||||
def cursor(self):
|
||||
return SQLiteCursorCompat(self.connection)
|
||||
|
||||
|
||||
@@ -39,17 +39,17 @@ class Tools:
|
||||
|
||||
def generate_profile(
|
||||
self,
|
||||
id=1,
|
||||
phone=70000000000,
|
||||
id=None,
|
||||
phone=None,
|
||||
avatarUrl=None,
|
||||
photoId=None,
|
||||
updateTime=0,
|
||||
firstName="Test",
|
||||
lastName="Account",
|
||||
options=[],
|
||||
updateTime=None,
|
||||
firstName=None,
|
||||
lastName=None,
|
||||
options=None,
|
||||
description=None,
|
||||
accountStatus=0,
|
||||
profileOptions=[],
|
||||
accountStatus=None,
|
||||
profileOptions=None,
|
||||
includeProfileOptions=True,
|
||||
username=None,
|
||||
|
||||
@@ -108,31 +108,32 @@ class Tools:
|
||||
|
||||
def generate_profile_tt(
|
||||
self,
|
||||
id=1,
|
||||
phone=70000000000,
|
||||
id=None,
|
||||
phone=None,
|
||||
avatarUrl=None,
|
||||
photoId=None,
|
||||
updateTime=0,
|
||||
firstName="Test",
|
||||
lastName="Account",
|
||||
options=[],
|
||||
updateTime=None,
|
||||
firstName=None,
|
||||
lastName=None,
|
||||
options=None,
|
||||
description=None,
|
||||
username=None,
|
||||
custom_firstname=None,
|
||||
custom_lastname=None
|
||||
custom_lastname=None,
|
||||
blocked=None
|
||||
):
|
||||
# Так как TT не поддерживает фамилию, и если нам ее не передали в функцию
|
||||
# то используем только имя, чтобы избежать None в фамилии
|
||||
if firstName and lastName:
|
||||
name = f"{firstName} {lastName}",
|
||||
name = f"{firstName} {lastName}"
|
||||
else:
|
||||
name = firstName
|
||||
|
||||
# Используем такой же костыль, как и выше
|
||||
if custom_firstname:
|
||||
custom_name = custom_firstname
|
||||
elif custom_firstname and custom_lastname:
|
||||
if custom_firstname and custom_lastname:
|
||||
custom_name = f"{custom_firstname} {custom_lastname}"
|
||||
elif custom_firstname:
|
||||
custom_name = custom_firstname
|
||||
else:
|
||||
custom_name = None
|
||||
|
||||
@@ -163,6 +164,9 @@ class Tools:
|
||||
{"name": custom_name, "type": "CUSTOM"}
|
||||
)
|
||||
|
||||
if blocked:
|
||||
contact["status"] = "BLOCKED"
|
||||
|
||||
return contact
|
||||
|
||||
def generate_chat(
|
||||
|
||||
@@ -22,6 +22,7 @@ class OnemeController(ControllerBase):
|
||||
|
||||
# Выбираем протокол в зависимости от типа подключения
|
||||
proto = self.proto_web if is_web else self.proto_tcp
|
||||
packet = None
|
||||
|
||||
# Не отправляем событие самому себе
|
||||
if writer == eventData.get("writer"):
|
||||
@@ -94,7 +95,9 @@ class OnemeController(ControllerBase):
|
||||
cmd=0, seq=1, opcode=self.opcodes.NOTIF_PRESENCE, payload=payload
|
||||
)
|
||||
|
||||
# Отправляем пакет
|
||||
if not packet:
|
||||
return
|
||||
|
||||
if is_web:
|
||||
await writer.send(packet)
|
||||
else:
|
||||
|
||||
@@ -297,7 +297,7 @@ class AuthProcessors(BaseProcessor):
|
||||
photoId = (
|
||||
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 = (
|
||||
None if not account.get("description") else account.get("description")
|
||||
)
|
||||
@@ -521,7 +521,7 @@ class AuthProcessors(BaseProcessor):
|
||||
await self._send_error(
|
||||
seq, self.opcodes.LOGIN, self.error_types.INVALID_PAYLOAD, writer
|
||||
)
|
||||
return
|
||||
return None, None, None
|
||||
|
||||
# Чаты, где состоит пользователь
|
||||
chats = []
|
||||
@@ -545,7 +545,7 @@ class AuthProcessors(BaseProcessor):
|
||||
await self._send_error(
|
||||
seq, self.opcodes.LOGIN, self.error_types.INVALID_TOKEN, writer
|
||||
)
|
||||
return
|
||||
return None, None, None
|
||||
|
||||
# Ищем аккаунт пользователя в бд
|
||||
await cursor.execute(
|
||||
@@ -563,7 +563,7 @@ class AuthProcessors(BaseProcessor):
|
||||
# Ищем все чаты, где состоит пользователь
|
||||
await cursor.execute(
|
||||
"SELECT * FROM chat_participants WHERE user_id = %s",
|
||||
(user.get("id")),
|
||||
(user.get("id"),),
|
||||
)
|
||||
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"))
|
||||
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")
|
||||
|
||||
if self._check_legacy_version(appVersion):
|
||||
|
||||
@@ -153,7 +153,7 @@ class MainProcessors(BaseProcessor):
|
||||
|
||||
# Аватарка с биографией
|
||||
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")
|
||||
|
||||
# Генерируем профиль
|
||||
|
||||
@@ -36,7 +36,7 @@ class SearchProcessors(BaseProcessor):
|
||||
if user:
|
||||
# Аватарка с биографией
|
||||
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")
|
||||
|
||||
# Получаем данные контакта
|
||||
@@ -129,7 +129,7 @@ class SearchProcessors(BaseProcessor):
|
||||
|
||||
# Аватарка с биографией
|
||||
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")
|
||||
|
||||
# Получаем данные контакта
|
||||
|
||||
@@ -22,6 +22,7 @@ class TTController(ControllerBase):
|
||||
|
||||
# Выбираем протокол в зависимости от типа подключения
|
||||
proto = self.proto_web if is_web else self.proto_tcp
|
||||
packet = None
|
||||
|
||||
# Не отправляем событие самому себе
|
||||
if writer == eventData.get("writer"):
|
||||
@@ -94,7 +95,9 @@ class TTController(ControllerBase):
|
||||
cmd=0, seq=1, opcode=self.opcodes.NOTIF_PRESENCE, payload=payload
|
||||
)
|
||||
|
||||
# Отправляем пакет
|
||||
if not packet:
|
||||
return
|
||||
|
||||
if is_web:
|
||||
await writer.send(packet)
|
||||
else:
|
||||
|
||||
@@ -443,7 +443,7 @@ class AuthProcessors(BaseProcessor):
|
||||
self.logger.error(f"Возникли ошибки при валидации пакета: {e}")
|
||||
await self._send_error(seq, self.opcodes.LOGIN,
|
||||
self.error_types.INVALID_PAYLOAD, writer)
|
||||
return
|
||||
return None, None, None
|
||||
|
||||
# Чаты, где состоит пользователь
|
||||
chats = []
|
||||
@@ -464,7 +464,7 @@ class AuthProcessors(BaseProcessor):
|
||||
if token_data is None:
|
||||
await self._send_error(seq, self.opcodes.LOGIN,
|
||||
self.error_types.INVALID_TOKEN, writer)
|
||||
return
|
||||
return None, None, None
|
||||
|
||||
# Ищем аккаунт пользователя в бд
|
||||
await cursor.execute("SELECT * FROM users WHERE phone = %s", (token_data.get("phone"),))
|
||||
@@ -476,8 +476,8 @@ class AuthProcessors(BaseProcessor):
|
||||
|
||||
# Ищем все чаты, где состоит пользователь
|
||||
await cursor.execute(
|
||||
"SELECT * FROM chat_participants WHERE user_id = %s",
|
||||
(user.get('id'))
|
||||
"SELECT * FROM chat_participants WHERE user_id = %s",
|
||||
(user.get('id'),)
|
||||
)
|
||||
user_chats = await cursor.fetchall()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user