|
@@ -22,6 +22,12 @@ const DEFAULT_IPV6_IP = '[2001:67c:4e8:f002::a]'
|
|
// Chunk sizes for upload.getFile must be multiples of the smallest size
|
|
// Chunk sizes for upload.getFile must be multiples of the smallest size
|
|
const MIN_CHUNK_SIZE = 4096
|
|
const MIN_CHUNK_SIZE = 4096
|
|
const MAX_CHUNK_SIZE = 512 * 1024
|
|
const MAX_CHUNK_SIZE = 512 * 1024
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
+=======
|
|
|
|
+const DEFAULT_CHUNK_SIZE = 64 // kb
|
|
|
|
+// All types
|
|
|
|
+const sizeTypes = ['w', 'y', 'x', 'm', 's']
|
|
|
|
+>>>>>>> ddb2a0ed... GramJS: Fix downloading images of uncommon (small) size
|
|
|
|
|
|
|
|
|
|
class TelegramClient {
|
|
class TelegramClient {
|
|
@@ -148,7 +154,7 @@ class TelegramClient {
|
|
this._sender = new MTProtoSender(this.session.getAuthKey(), {
|
|
this._sender = new MTProtoSender(this.session.getAuthKey(), {
|
|
>>>>>>> 42589b8b... GramJS: Add `LocalStorageSession` with keys and hashes for all DCs
|
|
>>>>>>> 42589b8b... GramJS: Add `LocalStorageSession` with keys and hashes for all DCs
|
|
logger: this._log,
|
|
logger: this._log,
|
|
- dcId:this.session.dcId,
|
|
|
|
|
|
+ dcId: this.session.dcId,
|
|
retries: this._connectionRetries,
|
|
retries: this._connectionRetries,
|
|
delay: this._retryDelay,
|
|
delay: this._retryDelay,
|
|
autoReconnect: this._autoReconnect,
|
|
autoReconnect: this._autoReconnect,
|
|
@@ -221,8 +227,8 @@ class TelegramClient {
|
|
return await this.connect()
|
|
return await this.connect()
|
|
}
|
|
}
|
|
|
|
|
|
- async _authKeyCallback(authKey,dcId) {
|
|
|
|
- this.session.setAuthKey(authKey,dcId)
|
|
|
|
|
|
+ async _authKeyCallback(authKey, dcId) {
|
|
|
|
+ this.session.setAuthKey(authKey, dcId)
|
|
}
|
|
}
|
|
|
|
|
|
// endregion
|
|
// endregion
|
|
@@ -252,8 +258,9 @@ class TelegramClient {
|
|
async _createExportedSender(dcId, retries) {
|
|
async _createExportedSender(dcId, retries) {
|
|
const dc = utils.getDC(dcId)
|
|
const dc = utils.getDC(dcId)
|
|
const sender = new MTProtoSender(this.session.getAuthKey(dcId),
|
|
const sender = new MTProtoSender(this.session.getAuthKey(dcId),
|
|
- { logger: this._log,
|
|
|
|
- dcId:dcId,
|
|
|
|
|
|
+ {
|
|
|
|
+ logger: this._log,
|
|
|
|
+ dcId: dcId,
|
|
retries: this._connectionRetries,
|
|
retries: this._connectionRetries,
|
|
delay: this._retryDelay,
|
|
delay: this._retryDelay,
|
|
autoReconnect: this._autoReconnect,
|
|
autoReconnect: this._autoReconnect,
|
|
@@ -526,8 +533,15 @@ class TelegramClient {
|
|
if (!sizeType || !sizes || !sizes.length) {
|
|
if (!sizeType || !sizes || !sizes.length) {
|
|
return null
|
|
return null
|
|
}
|
|
}
|
|
-
|
|
|
|
- return sizes.find((s) => s.type === sizeType)
|
|
|
|
|
|
+ const indexOfSize = sizeTypes.indexOf(sizeType)
|
|
|
|
+ let size
|
|
|
|
+ for (let i = indexOfSize; i < sizeTypes.length; i++) {
|
|
|
|
+ size = sizes.find((s) => s.type === sizeTypes[i])
|
|
|
|
+ if (size) {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return size
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -549,7 +563,8 @@ class TelegramClient {
|
|
if (!(photo instanceof constructors.Photo)) {
|
|
if (!(photo instanceof constructors.Photo)) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- const size = this._pickFileSize(photo.sizes, args.sizeType)
|
|
|
|
|
|
+ let size
|
|
|
|
+ size = this._pickFileSize(photo.sizes, args.sizeType)
|
|
if (!size || (size instanceof constructors.PhotoSizeEmpty)) {
|
|
if (!size || (size instanceof constructors.PhotoSizeEmpty)) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -566,7 +581,6 @@ class TelegramClient {
|
|
if (size instanceof constructors.PhotoCachedSize || size instanceof constructors.PhotoStrippedSize) {
|
|
if (size instanceof constructors.PhotoCachedSize || size instanceof constructors.PhotoStrippedSize) {
|
|
return this._downloadCachedPhotoSize(size)
|
|
return this._downloadCachedPhotoSize(size)
|
|
}
|
|
}
|
|
-
|
|
|
|
return this.downloadFile(
|
|
return this.downloadFile(
|
|
new constructors.InputPhotoFileLocation({
|
|
new constructors.InputPhotoFileLocation({
|
|
>>>>>>> f70d85dd... Gram JS: Replace generated `tl/*` contents with runtime logic; TypeScript typings
|
|
>>>>>>> f70d85dd... Gram JS: Replace generated `tl/*` contents with runtime logic; TypeScript typings
|