ТамТам: починил 32 опкод и добавил серверный конфиг. Избранное больше не добавляется в список чатов

MAX: починил 32 опкод
This commit is contained in:
Alexey Polyakov 2026-03-22 18:26:04 +03:00
parent aa6411b75d
commit a8732b5d7f
5 changed files with 630 additions and 35 deletions

View File

@ -108,15 +108,17 @@ class Tools:
"lastDelayedUpdateTime": 0,
"lastFireDelayedErrorTime": 0,
"created": 1,
"cid": id,
"prevMessageId": prevMessageId,
"joinTime": 1,
"modified": lastEventTime
"modified": lastEventTime,
}
# Возвращаем
return result
async def generate_chats(self, chatIds, db_pool, senderId):
async def generate_chats(self, chatIds, db_pool, senderId, include_favourites=True):
"""Генерирует чаты для отдачи клиенту"""
# Готовый список с чатами
chats = []
@ -156,34 +158,35 @@ class Tools:
)
)
# Получаем последнее сообщение из избранного
message, messageTime = await self.get_last_message(
senderId, db_pool
)
# ID избранного
chatId = senderId ^ senderId
# Получаем последнюю активность участника (отправителя) в избранном
participants = await self.get_participant_last_activity(
senderId, [senderId], db_pool
)
# Получаем ID предыдущего сообщения для избранного (чат ID = senderId)
prevMessageId = await self.get_previous_message_id(senderId, db_pool)
# Хардкодим в лист чатов избранное
chats.append(
self.generate_chat(
chatId,
senderId,
"DIALOG",
participants,
message,
messageTime,
prevMessageId
if include_favourites == True:
# Получаем последнее сообщение из избранного
message, messageTime = await self.get_last_message(
senderId, db_pool
)
# ID избранного
chatId = senderId ^ senderId
# Получаем последнюю активность участника (отправителя) в избранном
participants = await self.get_participant_last_activity(
senderId, [senderId], db_pool
)
# Получаем ID предыдущего сообщения для избранного (чат ID = senderId)
prevMessageId = await self.get_previous_message_id(senderId, db_pool)
# Хардкодим в лист чатов избранное
chats.append(
self.generate_chat(
chatId,
senderId,
"DIALOG",
participants,
message,
messageTime,
prevMessageId
)
)
)
return chats

View File

@ -834,7 +834,7 @@ class Processors:
# Создаем пакет
response = self.proto.pack_packet(
seq=seq, opcode=self.opcodes.CONTACT_INFO, payload=payload
cmd=self.proto.CMD_OK, seq=seq, opcode=self.opcodes.CONTACT_INFO, payload=payload
)
# Отправляем

572
src/tamtam/config.py Normal file
View File

@ -0,0 +1,572 @@
class TTConfig:
def __init__(self):
pass
SERVER_CONFIG = {
"a-2g": 8,
"a-3g": 24,
"a-constraints": {
"googNoiseSuppression": "true",
"googHighpassFilter": "false",
"googTypingNoiseDetection": "false",
"googAudioNetworkAdaptorConfig": "ChyyARkNCtcjPBUK1yM8GKjDASCw6gEomHUwoJwBCgfKAQQIABAACgvCAQgIqMMBELiRAgosqgEpChEIuBcVzcxMPhjogQIlCtejOxIRCOgHFc3MTD4YsOoBJQrXozsYyAEKC7oBCAiw6gEQoJwB"
},
"a-lte": 24,
"a-wifi": 34,
"account-removal-enabled": False,
"animated-emojis": {
"❤️": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/03.json"
},
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/04.json"
}
},
"👍": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-29lottie/e/16.json"
},
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/01_m.json"
}
},
"👎": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/17.json"
},
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/02.json"
}
},
"🙏": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/04.json"
},
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-29lottie/e/30_ng.json"
}
},
"😘": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/05.json"
},
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/03.json"
}
},
"🔥": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/06.json"
},
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/10.json"
}
},
"😂": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/07.json"
}
},
"👏": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/56.json"
}
},
"😮": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/09.json"
}
},
"💋": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/13_v02.json"
},
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2023-01-18lottie/r/kissing2.json"
}
},
"🥂": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/20.json"
},
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/20.json"
}
},
"😳": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/09.json"
},
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/02.json"
}
},
"😔": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/r/11.json"
},
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/05.json"
}
},
"😍": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/07.json"
}
},
"😯": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/08.json"
}
},
"😉": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/09.json"
}
},
"🌺": {
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2023-03-06lottie/flower.json"
},
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/11.json"
}
},
"🎂": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/14.json"
}
},
"💩": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/15.json"
},
"reactionAction": {
"url": "https://st.okcdn.ru/static/messages/2023-01-18lottie/r/shit_1.json"
}
},
"🐰": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/19.json"
}
},
"🎅": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/21.json"
}
},
"🎄": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/23.json"
}
},
"🎆": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/22.json"
}
},
"❄️": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/25.json"
}
},
"🎉": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-28lottie/e/12.json"
}
},
"🥗": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2022-12-29lottie/e/28.json"
}
},
"🧡": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/31.json"
}
},
"💔": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/32.json"
}
},
"🎁": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/34.json"
}
},
"🌹": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/35.json"
}
},
"🌸": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/36.json"
}
},
"🍒": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/37.json"
}
},
"🥕": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/39.json"
}
},
"🍑": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/40.json"
}
},
"🍋": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/41.json"
}
},
"🍃": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/42.json"
}
},
"😺": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/43.json"
}
},
"🐶": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/44.json"
}
},
"🐽": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-07-20animojie/45.json"
}
},
"💐": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/46.json"
}
},
"🎈": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/47.json"
}
},
"🍾": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/48.json"
}
},
"": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/49.json"
}
},
"": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/50.json"
}
},
"": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/51.json"
}
},
"💃": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/52.json"
}
},
"☀️": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/53.json"
}
},
"👋": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/54.json"
}
},
"": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/57.json"
}
},
"🙂": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/58.json"
}
},
"🤩": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-15animoji/59.json"
}
},
"😇": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/60.json"
}
},
"😎": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/61.json"
}
},
"🍎": {
"emoji": {
"url": "https://st.okcdn.ru/static/messages/2023-08-14animoji/62.json"
}
}
},
"animated-emojis-limits": {
"low": 5,
"average": 10,
"high": 15
},
"animated-emojis-places": [
"MESSAGE_NORMAL_TEXT",
"MESSAGE_BIG_EMOJI_TEXT",
"MESSAGE_INPUT",
"STICKERS_KEYBOARD",
"CHATS_LIST"
],
"attachment-popup-click": False,
"audio-transcription-enabled": True,
"audio-transcription-locales": [
"ru"
],
"change-self-readmark-on-msg-send": False,
"chat-bg": False,
"chat-cancel-top-menu-enabled": False,
"chat-filter": False,
"chat-info-full-list-enabled": False,
"chat-preview-enabled": False,
"chats-edit-enabled": False,
"chats-folder-enabled": True,
"chats-list-promo-link-enabled": False,
"chats-page-size": 50,
"chats-preload-period": 15,
"close-keyboard-on-scroll": True,
"common-chats-enabled": True,
"compact-mode-enabled": False,
"congrats-banner-enabled-mob": False,
"congrats-banner-enabled-web": True,
"contact-verify-enabled": False,
"contacts-send": False,
"contacts-sort-refresh": 259200,
"copy-id-btn": False,
"debug-mode": 1,
"delayed-messages": False,
"delayed-messages-enabled": False,
"detect-share-when-send-message": True,
"dialog-priority": False,
"disconnect-timeout": 300,
"drafts-sync-enabled": True,
"edit-timeout": 86400,
"expandable-appbar-enabled": True,
"experimental": False,
"fast-chat-actions-enabled": False,
"file-upload-enabled": True,
"file-upload-max-size": 2147483648,
"file-upload-unsupported-types": [
"exe"
],
"gce": True,
"hashtags-enabled": True,
"html-paste": False,
"http-logs-enabled": False,
"image-height": 1680,
"image-quality": 0.800000011920929,
"image-size": 40000000,
"image-width": 1680,
"invite-header": "Приглашение в ТамТам",
"invite-link": "https://tt.me/starwear",
"invite-long": "Я общаюсь в ТамТам, присоединяйся https://tt.me/starwear",
"invite-short": "Привет! Ставь ТамТам! Жду ответа! https://tt.me/starwear",
"keep-connection": 2,
"l10n": False,
"live-location-enabled": True,
"location-enabled": True,
"logs-enabled": True,
"markdown-enabled": True,
"markdown-menu": 0,
"markdown-miui-enabled": True,
"max-audio-length": 3600,
"max-cname-length": 200,
"max-description-length": 400,
"max-favorite-chats": 5,
"max-favorite-sticker-sets": 100,
"max-favorite-stickers": 100,
"max-msg-length": 4000,
"max-participants": 20000,
"max-readmarks": 300,
"max-theme-length": 200,
"max-video-duration-download": 1200,
"mediabar-scroll-layout": True,
"mentions-enabled": True,
"mentions_entity_names_limit": 3,
"min-image-side-size": 64,
"moderated-groups": False,
"moderated-groups-filter": False,
"multiselect": True,
"music-files-enabled": False,
"muted-chat-call-enabled": False,
"nearby-timeouts": {
"enabled": "True",
"LaunchBroadcastTime": "0",
"LaunchBroadcastTimeLimit": "300",
"ContactsScreenBroadcastTime": "10",
"ChatSearchScreenBroadcastTime": "10",
"RecentContactTime": "300"
},
"new-chats-searching": True,
"new-chats-ui": True,
"new-fcm-push": True,
"notif-images": True,
"offline-icon": False,
"often-chats": False,
"ok-avatar-icon": False,
"ok-profile-unbind-enabled": True,
"ok-tt-chat-separation": True,
"one-chat-enabled": False,
"one-chat-new-panel-sticker": False,
"peer-connection-params": {
"ebv": [
"xiaomi",
"huawei"
],
"ebm": [
"oneplus a5010"
]
},
"phone-bind-enabled": True,
"phone-layer-enabled": True,
"play-background-listen-to-end": False,
"play-next-audio": False,
"plus-menu-enabled": False,
"prefs": 1,
"profile-autodelete-enabled": True,
"profiling-enabled": False,
"progress-diff-for-notify": 1,
"promo-contact-id": 0,
"promo-recent-contacts": True,
"promo_contact_label": "Белый Маг",
"proxy": "msgproxy.okcdn.ru",
"proxy-domains": [
"okcdn.ru",
"mycdn.me",
"ok.ru",
"odnoklassniki.ru",
"odkl.ru",
"vk.com",
"userapi.com",
"vkuser.net",
"vkusercdn.ru"
],
"proxy-exclude": [
"r.mradx.net",
"ad.mail.ru"
],
"proxy-rotation": True,
"push-alert-timeout": 604800,
"push-tracking-enabled": True,
"quick-forward-cases": [],
"react-permission": 2,
"reactions-enabled": True,
"reactions-max": 3,
"reactions-menu": [
"👍",
"❤️",
"💩",
"😂",
"🔥",
"🙏",
"👎",
"😮"
],
"readmark-enabled-delay-ms": 400,
"remove-profile-enable": True,
"remove-user-msg-del": True,
"retry-sig-count": 5,
"retry-sig-delay": 4,
"screen-share-enabled": False,
"screen-sharing-enabled": True,
"send-media-from-system-keyboard": False,
"send-side-bwe": True,
"send-system-keyboard-png-as-stickers": True,
"set-unread-timeout": 31536000,
"settings-use": False,
"show-invited-by": True,
"show-rm-limits": [
15,
100
],
"show-snow": True,
"sticker-gif-enabled": True,
"sticker-sections": [
"TOP",
"NEW"
],
"sticker-sets-links-enabled": True,
"sticker-suggest-disabled": False,
"stickers-suggestion": [
"RECENT",
"NEW",
"TOP"
],
"stickers-suggestion-keywords-inline": False,
"support-account": "tt.me/support",
"support-button-enable": False,
"t-ice-reconnect": 15,
"t-incoming-call": 40,
"t-start-connect": 20,
"tam-emoji-font-url": "https://st.okcdn.ru/static/messages/2022-08-25noto/TamNotoColorEmojiCompat.ttf",
"tcp-candidates": False,
"tracer-crash-report-enabled": True,
"tracer-crash-report-host": "https://api-hprof.odkl.ru",
"tracer-crash-send-asap-enabled": True,
"tracer-crash-send-logs-enabled": True,
"tracer-crash-send-threads-dump-enabled": True,
"tracer-disk-overflow-report-threshold": 3000000000,
"tracer-disk-usage-probability": 500,
"tracer-enabled": True,
"tracer-host": "https://api-hprof.odkl.ru",
"tracer-hprof-probability": -1,
"tracer-sampled-conditions": "tag=app_start_ui_freeze_2k;probability=100000;startEvent=app_first_activity_created;interestingEvent=app_freeze;interestingDuration=2000",
"tracer-sampled-duration": 20000,
"tracer-systrace-duration": 20000,
"tracer-systrace-interesting-duration": 10000,
"tracer-systrace-probability": 10000,
"unknown-person-attention": True,
"unread-filter-enabled": False,
"update-non-contacts": 10,
"use-congrats-list-in-mass-sending": False,
"use-new-message-rendering": True,
"v-2g": 128,
"v-3g": 1024,
"v-fps": 24,
"v-fps-v8": 20,
"v-height": 720,
"v-height-vp8": 480,
"v-lte": 1024,
"v-vp8": 512,
"v-width": 1280,
"v-width-vp8": 640,
"v-wifi": 2048,
"vce": True,
"video-attach-download-enabled": False,
"video-auto-compress-enabled": True,
"video-messages": False,
"video-params": True,
"video-preview": "480x270",
"wakelock-on-push": False,
"wm-analytics-enabled": True,
"wm-workers-limit": 80,
"iceServers": [],
"has-phone": True,
"promo-constructors": []
}

View File

@ -10,8 +10,13 @@ from tamtam.models import (
FinalAuthPayloadModel,
LoginPayloadModel,
)
from tamtam.config import TTConfig
class AuthProcessors(BaseProcessor):
def __init__(self, db_pool=None, clients=None, send_event=None, type="socket"):
super().__init__(db_pool, clients, send_event, type)
self.server_config = TTConfig().SERVER_CONFIG
async def auth_request(self, payload, seq, writer):
"""Обработчик запроса кода"""
# Валидируем данные пакета
@ -254,6 +259,9 @@ class AuthProcessors(BaseProcessor):
self.error_types.INVALID_PAYLOAD, writer)
return
# Чаты, где состоит пользователь
chats = []
# Получаем данные из пакета
token = payload.get("token")
@ -280,6 +288,18 @@ class AuthProcessors(BaseProcessor):
await cursor.execute("SELECT * FROM user_data WHERE phone = %s", (token_data.get("phone"),))
user_data = await cursor.fetchone()
# Ищем все чаты, где состоит пользователь
await cursor.execute(
"SELECT * FROM chat_participants WHERE user_id = %s",
(user.get('id'))
)
user_chats = await cursor.fetchall()
for chat in user_chats:
chats.append(
chat.get("chat_id")
)
# Аватарка с биографией
photo_id = None if not user.get("avatar_id") else int(user.get("avatar_id"))
avatar_url = None if not photo_id else self.config.avatar_base_url + str(photo_id)
@ -300,8 +320,8 @@ class AuthProcessors(BaseProcessor):
)
chats = await self.tools.generate_chats(
json.loads(user_data.get("chats")),
self.db_pool, user.get("id")
chats, self.db_pool, user.get("id"),
include_favourites=False
)
# Формируем данные пакета
@ -313,8 +333,8 @@ class AuthProcessors(BaseProcessor):
"contacts": [],
"presence": {},
"config": {
"hash": "0",
"server": {},
"hash": "e5903aa8-0000000000000000-80000106-0000000000000001-00000001-0000000000000000-00000000-2-00000001-0000019c9559d057",
"server": self.server_config,
"user": json.loads(user_data.get("user_config")),
"chatFolders": {
"FOLDERS": [],

View File

@ -56,7 +56,7 @@ class SearchProcessors(BaseProcessor):
# Создаем пакет
response = self.proto.pack_packet(
seq=seq, opcode=self.opcodes.CONTACT_INFO, payload=payload
cmd=self.proto.CMD_OK, seq=seq, opcode=self.opcodes.CONTACT_INFO, payload=payload
)
# Отправляем