@imessaging/telegram-mtproto 0.8.17 → 0.8.19

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @imessaging/telegram-mtproto
2
+
3
+ Telegram user-account transport for [imessaging](https://github.com/iconicompany/imessaging) over MTProto.
4
+
5
+ Needs `teleproto` 1.229.1+ (a GramJS fork) installed under the `telegram` name; upstream GramJS
6
+ (`telegram` 2.x) lacks `telegram/richMessage` and does not load:
7
+
8
+ ```sh
9
+ bun add @imessaging/telegram-mtproto telegram@npm:teleproto@^1.229.1
10
+ npm install @imessaging/telegram-mtproto telegram@npm:teleproto@^1.229.1
11
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imessaging/telegram-mtproto",
3
- "version": "0.8.17",
3
+ "version": "0.8.19",
4
4
  "description": "Telegram MTProto user-account transport for imessaging",
5
5
  "keywords": [
6
6
  "messaging",
@@ -35,6 +35,6 @@
35
35
  "big-integer": "^1.6.52"
36
36
  },
37
37
  "peerDependencies": {
38
- "telegram": ">=1.229.1"
38
+ "telegram": ">=1.229.1 <2"
39
39
  }
40
40
  }
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,
@@ -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: message.sender?.username ?? (await message.getSender?.())?.username,
641
+ ...(username ? { username } : {}),
640
642
  resolvedAt: new Date().toISOString(),
641
643
  },
642
644
  this.options.peerTtlSeconds,