@imessaging/telegram-mtproto 0.8.16 → 0.8.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/incoming.ts
CHANGED
|
@@ -410,7 +410,7 @@ export function toIncomingMessage(
|
|
|
410
410
|
senderId,
|
|
411
411
|
// Имя отправителя: по нему отвечают, когда номер клиенту неизвестен, и по нему же продукты
|
|
412
412
|
// связывают человека со своей учётной записью.
|
|
413
|
-
senderUsername: message.sender?.username,
|
|
413
|
+
senderUsername: message.sender?.username ?? undefined,
|
|
414
414
|
senderName,
|
|
415
415
|
senderMutualContact:
|
|
416
416
|
typeof message.sender?.mutualContact === "boolean" ? message.sender.mutualContact : undefined,
|
|
@@ -417,7 +417,7 @@ export class TelegramMtprotoTransport
|
|
|
417
417
|
if (threadId !== undefined && (!Number.isSafeInteger(threadId) || threadId <= 0)) {
|
|
418
418
|
throw new Error(`Telegram thread id must be a positive integer: ${threadId}`);
|
|
419
419
|
}
|
|
420
|
-
//
|
|
420
|
+
// Тема: topMsgId всегда, без него черновик ложится в General; без ответа — ответ на корень темы.
|
|
421
421
|
const replyToMsgId = replyTo ?? threadId;
|
|
422
422
|
const ft = draft.format ? formatText(draft.text, draft.format) : undefined;
|
|
423
423
|
const save = async (peer: Api.TypeInputPeer) =>
|
|
@@ -430,7 +430,7 @@ export class TelegramMtprotoTransport
|
|
|
430
430
|
? {
|
|
431
431
|
replyTo: new Api.InputReplyToMessage({
|
|
432
432
|
replyToMsgId,
|
|
433
|
-
...(
|
|
433
|
+
...(threadId ? { topMsgId: threadId } : {}),
|
|
434
434
|
}),
|
|
435
435
|
}
|
|
436
436
|
: {}),
|
|
@@ -629,6 +629,8 @@ export class TelegramMtprotoTransport
|
|
|
629
629
|
// В группе отправитель и чат — разные пиры, и запись сложила бы одно вместо другого.
|
|
630
630
|
if (chatType !== "user") return;
|
|
631
631
|
const recipient = { type: "user", id: chatId } as const;
|
|
632
|
+
// Без ника gramjs отдаёт null; в записи он ронял RedisPeerStore на чтении.
|
|
633
|
+
const username = message.sender?.username || (await message.getSender?.())?.username;
|
|
632
634
|
await this.peerStore.set(
|
|
633
635
|
this.options.accountId,
|
|
634
636
|
recipient,
|
|
@@ -636,7 +638,7 @@ export class TelegramMtprotoTransport
|
|
|
636
638
|
type: "user",
|
|
637
639
|
id: chatId,
|
|
638
640
|
accessHash: String(hash),
|
|
639
|
-
username
|
|
641
|
+
...(username ? { username } : {}),
|
|
640
642
|
resolvedAt: new Date().toISOString(),
|
|
641
643
|
},
|
|
642
644
|
this.options.peerTtlSeconds,
|