Поддержка синхронизации исходящих сообщений

This commit is contained in:
RoyceDa
2026-01-31 22:12:55 +02:00
parent 5072a71c05
commit 7ca7057805

View File

@@ -62,6 +62,8 @@ export function useDialogFiber() {
/** /**
* Нам приходят сообщения от себя самих же при синхронизации * Нам приходят сообщения от себя самих же при синхронизации
* нужно обрабатывать их особым образом соотвественно * нужно обрабатывать их особым образом соотвественно
*
* Метод нужен для синхронизации своих сообщений
*/ */
usePacket(0x06, async (packet: PacketMessage) => { usePacket(0x06, async (packet: PacketMessage) => {
const fromPublicKey = packet.getFromPublicKey(); const fromPublicKey = packet.getFromPublicKey();
@@ -78,7 +80,6 @@ export function useDialogFiber() {
*/ */
return; return;
} }
const chachaDecryptedKey = Buffer.from(await decodeWithPassword(privatePlain, aesChachaKey), "binary"); const chachaDecryptedKey = Buffer.from(await decodeWithPassword(privatePlain, aesChachaKey), "binary");
const key = chachaDecryptedKey.slice(0, 32); const key = chachaDecryptedKey.slice(0, 32);
const nonce = chachaDecryptedKey.slice(32); const nonce = chachaDecryptedKey.slice(32);
@@ -118,9 +119,9 @@ export function useDialogFiber() {
to_public_key: toPublicKey, to_public_key: toPublicKey,
content: content, content: content,
timestamp: timestamp, timestamp: timestamp,
readed: idle ? 0 : 1, readed: 1, //сообщение прочитано
chacha_key: chachaDecryptedKey.toString('utf-8'), chacha_key: chachaDecryptedKey.toString('utf-8'),
from_me: fromPublicKey == publicKey ? 1 : 0, from_me: 1, //сообщение от нас
plain_message: (decryptedContent as string), plain_message: (decryptedContent as string),
delivered: DeliveredMessageState.DELIVERED, delivered: DeliveredMessageState.DELIVERED,
message_id: messageId, message_id: messageId,
@@ -134,16 +135,16 @@ export function useDialogFiber() {
toPublicKey, toPublicKey,
content, content,
timestamp, timestamp,
(currentDialogPublicKeyView == fromPublicKey && !idle && viewState != ViewPanelsState.DIALOGS_PANEL_ONLY) ? 1 : 0, 0, //по умолчанию не прочитаны
'', '',
0, 1, //Свои же сообщения всегда от нас
await encodeWithPassword(privatePlain, decryptedContent), await encodeWithPassword(privatePlain, decryptedContent),
publicKey, publicKey,
messageId, messageId,
DeliveredMessageState.DELIVERED, DeliveredMessageState.DELIVERED,
JSON.stringify(attachmentsMeta)]); JSON.stringify(attachmentsMeta)]);
updateDialog(fromPublicKey); updateDialog(toPublicKey);
let dialogCache = getDialogCache(toPublicKey); let dialogCache = getDialogCache(toPublicKey);
if (currentDialogPublicKeyView !== toPublicKey && dialogCache.length > 0) { if (currentDialogPublicKeyView !== toPublicKey && dialogCache.length > 0) {