@imessaging/telegram-mtproto 0.8.5 → 0.8.6
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imessaging/telegram-mtproto",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Telegram MTProto user-account transport for imessaging",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"messaging",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "bun test"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@imessaging/core": "^0.8.
|
|
34
|
+
"@imessaging/core": "^0.8.6",
|
|
35
35
|
"big-integer": "^1.6.52"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
PhoneLookupOptions,
|
|
2
3
|
PhoneLookupTransport,
|
|
3
4
|
PhoneMatch,
|
|
4
5
|
DraftTransport,
|
|
@@ -228,10 +229,10 @@ export class TelegramMtprotoTransport
|
|
|
228
229
|
|
|
229
230
|
/**
|
|
230
231
|
* Учётка по номеру телефона: сначала contacts.ResolvePhone (номер, открытый настройками приватности),
|
|
231
|
-
* затем contacts.ImportContacts (номер виден только контакту)
|
|
232
|
-
*
|
|
232
|
+
* затем contacts.ImportContacts (номер виден только контакту) — он и заводит контакт. С `keepContact: false`
|
|
233
|
+
* заведённый контакт удаляется сразу; бывший контактом до поиска не удаляется никогда.
|
|
233
234
|
*/
|
|
234
|
-
async findByPhone(phone: string): Promise<PhoneMatch | null> {
|
|
235
|
+
async findByPhone(phone: string, options: PhoneLookupOptions = {}): Promise<PhoneMatch | null> {
|
|
235
236
|
this.assertConnected();
|
|
236
237
|
const digits = phone.replace(/[\s()-]/g, "").replace(/^\+/, "");
|
|
237
238
|
if (!/^\d{7,15}$/.test(digits))
|
|
@@ -263,8 +264,8 @@ export class TelegramMtprotoTransport
|
|
|
263
264
|
new Api.InputPhoneContact({
|
|
264
265
|
clientId: bigInt(Date.now()),
|
|
265
266
|
phone: `+${digits}`,
|
|
266
|
-
firstName: `+${digits}`,
|
|
267
|
-
lastName: "",
|
|
267
|
+
firstName: options.firstName?.trim() || `+${digits}`,
|
|
268
|
+
lastName: options.lastName?.trim() ?? "",
|
|
268
269
|
}),
|
|
269
270
|
],
|
|
270
271
|
}),
|
|
@@ -274,7 +275,7 @@ export class TelegramMtprotoTransport
|
|
|
274
275
|
try {
|
|
275
276
|
return await this.rememberPhoneMatch(user);
|
|
276
277
|
} finally {
|
|
277
|
-
if (!known.has(user.id.toString()) && user.accessHash) {
|
|
278
|
+
if (options.keepContact === false && !known.has(user.id.toString()) && user.accessHash) {
|
|
278
279
|
await this.client.invoke(
|
|
279
280
|
new Api.contacts.DeleteContacts({
|
|
280
281
|
id: [new Api.InputUser({ userId: user.id, accessHash: user.accessHash })],
|