Skip to content

Commit b61e28a

Browse files
author
Ali
committed
Chat import fixes
1 parent ea4db44 commit b61e28a

File tree

8 files changed

+115
-74
lines changed

8 files changed

+115
-74
lines changed

‎buildbox/verify-telegram.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ fi
2424

2525
OUTPUT_PATH="build/artifacts"
2626

27+
BAZEL_HTTP_CACHE_URL="$BAZEL_HTTP_CACHE_URL" sh buildbox/build-telegram.sh verify
28+
2729
if [ "$CONFIGURATION" == "appstore" ]; then
2830
if [ -z "$IPA_PATH" ]; then
2931
IPA_PATH="$OUTPUT_PATH/Telegram.ipa"
@@ -43,8 +45,6 @@ VERIFY_PATH="TelegramVerifyBuild.ipa"
4345
rm -f "$VERIFY_PATH"
4446
cp "$IPA_PATH" "$VERIFY_PATH"
4547

46-
BAZEL_HTTP_CACHE_URL="$BAZEL_HTTP_CACHE_URL" sh buildbox/build-telegram.sh verify
47-
4848
python3 tools/ipadiff.py "$IPA_PATH" "$VERIFY_PATH"
4949
retVal=$?
5050
if [ $retVal -ne 0 ]; then

‎submodules/ChatImportUI/Sources/ChatImportActivityScreen.swift

+36-14
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,18 @@ public final class ChatImportActivityScreen: ViewController {
301301
self.doneButton.isHidden = true
302302
self.progressText.isHidden = true
303303
} else {
304+
self.statusText.frame = CGRect(origin: CGPoint(x: floor((layout.size.width - statusTextSize.width) / 2.0), y: self.progressText.frame.minY), size: statusTextSize)
305+
self.statusButtonText.isHidden = false
306+
self.statusButton.isHidden = false
307+
self.doneButton.isHidden = true
308+
self.progressText.isHidden = true
309+
}/* else {
304310
self.statusText.frame = CGRect(origin: CGPoint(x: floor((layout.size.width - statusTextSize.width) / 2.0), y: self.progressText.frame.minY), size: statusTextSize)
305311
self.statusButtonText.isHidden = true
306312
self.statusButton.isHidden = true
307313
self.doneButton.isHidden = false
308314
self.progressText.isHidden = true
309-
}
315+
}*/
310316

311317
let buttonSideInset: CGFloat = 75.0
312318
let buttonWidth = max(240.0, min(layout.size.width - buttonSideInset * 2.0, horizontalContainerFillingSizeForLayout(layout: layout, sideInset: buttonSideInset)))
@@ -395,7 +401,7 @@ public final class ChatImportActivityScreen: ViewController {
395401
private let archive: Archive
396402
private let mainEntry: TempBoxFile
397403
private let mainEntrySize: Int
398-
private let otherEntries: [(Entry, String, ChatHistoryImport.MediaType)]
404+
private let otherEntries: [(Entry, String, ChatHistoryImport.MediaType, Promise<TempBoxFile?>)]
399405
private let totalBytes: Int
400406

401407
private var pendingEntries: [String: (Int, Float)] = [:]
@@ -415,7 +421,25 @@ public final class ChatImportActivityScreen: ViewController {
415421
self.peerId = peerId
416422
self.archive = archive
417423
self.mainEntry = mainEntry
418-
self.otherEntries = otherEntries
424+
425+
self.otherEntries = otherEntries.map { entry -> (Entry, String, ChatHistoryImport.MediaType, Promise<TempBoxFile?>) in
426+
let signal = Signal<TempBoxFile?, NoError> { subscriber in
427+
let tempFile = TempBox.shared.tempFile(fileName: entry.1)
428+
do {
429+
let _ = try archive.extract(entry.0, to: URL(fileURLWithPath: tempFile.path))
430+
subscriber.putNext(tempFile)
431+
subscriber.putCompletion()
432+
} catch {
433+
subscriber.putNext(nil)
434+
subscriber.putCompletion()
435+
}
436+
437+
return EmptyDisposable
438+
}
439+
let promise = Promise<TempBoxFile?>()
440+
promise.set(signal)
441+
return (entry.0, entry.1, entry.2, promise)
442+
}
419443

420444
if let size = fileSize(self.mainEntry.path) {
421445
self.mainEntrySize = size
@@ -523,18 +547,16 @@ public final class ChatImportActivityScreen: ViewController {
523547
|> mapToSignal { session -> Signal<(String, Float), ImportError> in
524548
var importSignal: Signal<(String, Float), ImportError> = .single(("", 0.0))
525549

526-
for (entry, fileName, mediaType) in otherEntries {
527-
let unpackedFile = Signal<TempBoxFile, ImportError> { subscriber in
528-
let tempFile = TempBox.shared.tempFile(fileName: fileName)
529-
do {
530-
let _ = try archive.extract(entry, to: URL(fileURLWithPath: tempFile.path))
531-
subscriber.putNext(tempFile)
532-
subscriber.putCompletion()
533-
} catch {
534-
subscriber.putError(.generic)
550+
for (_, fileName, mediaType, fileData) in otherEntries {
551+
let unpackedFile: Signal<TempBoxFile, ImportError> = fileData.get()
552+
|> take(1)
553+
|> castError(ImportError.self)
554+
|> mapToSignal { file -> Signal<TempBoxFile, ImportError> in
555+
if let file = file {
556+
return .single(file)
557+
} else {
558+
return .fail(.generic)
535559
}
536-
537-
return EmptyDisposable
538560
}
539561
let uploadedMedia = unpackedFile
540562
|> mapToSignal { tempFile -> Signal<(String, Float), ImportError> in

‎submodules/TelegramApi/Sources/Api0.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
1111
dict[-457104426] = { return Api.InputGeoPoint.parse_inputGeoPointEmpty($0) }
1212
dict[1210199983] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) }
1313
dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) }
14-
dict[-281384243] = { return Api.ChatFull.parse_channelFull($0) }
15-
dict[231260545] = { return Api.ChatFull.parse_chatFull($0) }
14+
dict[2055070967] = { return Api.ChatFull.parse_channelFull($0) }
15+
dict[-213431562] = { return Api.ChatFull.parse_chatFull($0) }
1616
dict[-1159937629] = { return Api.PollResults.parse_pollResults($0) }
1717
dict[-925415106] = { return Api.ChatParticipant.parse_chatParticipant($0) }
1818
dict[-636267638] = { return Api.ChatParticipant.parse_chatParticipantCreator($0) }
@@ -736,8 +736,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
736736
dict[-1673717362] = { return Api.InputPeerNotifySettings.parse_inputPeerNotifySettings($0) }
737737
dict[-1634752813] = { return Api.messages.FavedStickers.parse_favedStickersNotModified($0) }
738738
dict[-209768682] = { return Api.messages.FavedStickers.parse_favedStickers($0) }
739-
dict[1776236393] = { return Api.ExportedChatInvite.parse_chatInviteEmpty($0) }
740-
dict[-64092740] = { return Api.ExportedChatInvite.parse_chatInviteExported($0) }
739+
dict[1847917725] = { return Api.ExportedChatInvite.parse_chatInviteExported($0) }
741740
dict[-1389486888] = { return Api.account.AuthorizationForm.parse_authorizationForm($0) }
742741
dict[-1392388579] = { return Api.Authorization.parse_authorization($0) }
743742
dict[-1361650766] = { return Api.MaskCoords.parse_maskCoords($0) }

‎submodules/TelegramApi/Sources/Api1.swift

+51-35
Original file line numberDiff line numberDiff line change
@@ -2124,14 +2124,14 @@ public extension Api {
21242124

21252125
}
21262126
public enum ChatFull: TypeConstructorDescription {
2127-
case channelFull(flags: Int32, id: Int32, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo], migratedFromChatId: Int32?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int32?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?)
2128-
case chatFull(flags: Int32, id: Int32, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?)
2127+
case channelFull(flags: Int32, id: Int32, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo], migratedFromChatId: Int32?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int32?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?)
2128+
case chatFull(flags: Int32, id: Int32, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?)
21292129

21302130
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
21312131
switch self {
21322132
case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call):
21332133
if boxed {
2134-
buffer.appendInt32(-281384243)
2134+
buffer.appendInt32(2055070967)
21352135
}
21362136
serializeInt32(flags, buffer: buffer, boxed: false)
21372137
serializeInt32(id, buffer: buffer, boxed: false)
@@ -2146,7 +2146,7 @@ public extension Api {
21462146
serializeInt32(unreadCount, buffer: buffer, boxed: false)
21472147
chatPhoto.serialize(buffer, true)
21482148
notifySettings.serialize(buffer, true)
2149-
exportedInvite.serialize(buffer, true)
2149+
if Int(flags) & Int(1 << 23) != 0 {exportedInvite!.serialize(buffer, true)}
21502150
buffer.appendInt32(481674261)
21512151
buffer.appendInt32(Int32(botInfo.count))
21522152
for item in botInfo {
@@ -2168,15 +2168,15 @@ public extension Api {
21682168
break
21692169
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let folderId, let call):
21702170
if boxed {
2171-
buffer.appendInt32(231260545)
2171+
buffer.appendInt32(-213431562)
21722172
}
21732173
serializeInt32(flags, buffer: buffer, boxed: false)
21742174
serializeInt32(id, buffer: buffer, boxed: false)
21752175
serializeString(about, buffer: buffer, boxed: false)
21762176
participants.serialize(buffer, true)
21772177
if Int(flags) & Int(1 << 2) != 0 {chatPhoto!.serialize(buffer, true)}
21782178
notifySettings.serialize(buffer, true)
2179-
exportedInvite.serialize(buffer, true)
2179+
if Int(flags) & Int(1 << 13) != 0 {exportedInvite!.serialize(buffer, true)}
21802180
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261)
21812181
buffer.appendInt32(Int32(botInfo!.count))
21822182
for item in botInfo! {
@@ -2230,9 +2230,9 @@ public extension Api {
22302230
_13 = Api.parse(reader, signature: signature) as? Api.PeerNotifySettings
22312231
}
22322232
var _14: Api.ExportedChatInvite?
2233-
if let signature = reader.readInt32() {
2233+
if Int(_1!) & Int(1 << 23) != 0 {if let signature = reader.readInt32() {
22342234
_14 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
2235-
}
2235+
} }
22362236
var _15: [Api.BotInfo]?
22372237
if let _ = reader.readInt32() {
22382238
_15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotInfo.self)
@@ -2282,7 +2282,7 @@ public extension Api {
22822282
let _c11 = _11 != nil
22832283
let _c12 = _12 != nil
22842284
let _c13 = _13 != nil
2285-
let _c14 = _14 != nil
2285+
let _c14 = (Int(_1!) & Int(1 << 23) == 0) || _14 != nil
22862286
let _c15 = _15 != nil
22872287
let _c16 = (Int(_1!) & Int(1 << 4) == 0) || _16 != nil
22882288
let _c17 = (Int(_1!) & Int(1 << 4) == 0) || _17 != nil
@@ -2298,7 +2298,7 @@ public extension Api {
22982298
let _c27 = _27 != nil
22992299
let _c28 = (Int(_1!) & Int(1 << 21) == 0) || _28 != nil
23002300
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 && _c22 && _c23 && _c24 && _c25 && _c26 && _c27 && _c28 {
2301-
return Api.ChatFull.channelFull(flags: _1!, id: _2!, about: _3!, participantsCount: _4, adminsCount: _5, kickedCount: _6, bannedCount: _7, onlineCount: _8, readInboxMaxId: _9!, readOutboxMaxId: _10!, unreadCount: _11!, chatPhoto: _12!, notifySettings: _13!, exportedInvite: _14!, botInfo: _15!, migratedFromChatId: _16, migratedFromMaxId: _17, pinnedMsgId: _18, stickerset: _19, availableMinId: _20, folderId: _21, linkedChatId: _22, location: _23, slowmodeSeconds: _24, slowmodeNextSendDate: _25, statsDc: _26, pts: _27!, call: _28)
2301+
return Api.ChatFull.channelFull(flags: _1!, id: _2!, about: _3!, participantsCount: _4, adminsCount: _5, kickedCount: _6, bannedCount: _7, onlineCount: _8, readInboxMaxId: _9!, readOutboxMaxId: _10!, unreadCount: _11!, chatPhoto: _12!, notifySettings: _13!, exportedInvite: _14, botInfo: _15!, migratedFromChatId: _16, migratedFromMaxId: _17, pinnedMsgId: _18, stickerset: _19, availableMinId: _20, folderId: _21, linkedChatId: _22, location: _23, slowmodeSeconds: _24, slowmodeNextSendDate: _25, statsDc: _26, pts: _27!, call: _28)
23022302
}
23032303
else {
23042304
return nil
@@ -2324,9 +2324,9 @@ public extension Api {
23242324
_6 = Api.parse(reader, signature: signature) as? Api.PeerNotifySettings
23252325
}
23262326
var _7: Api.ExportedChatInvite?
2327-
if let signature = reader.readInt32() {
2327+
if Int(_1!) & Int(1 << 13) != 0 {if let signature = reader.readInt32() {
23282328
_7 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
2329-
}
2329+
} }
23302330
var _8: [Api.BotInfo]?
23312331
if Int(_1!) & Int(1 << 3) != 0 {if let _ = reader.readInt32() {
23322332
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotInfo.self)
@@ -2345,13 +2345,13 @@ public extension Api {
23452345
let _c4 = _4 != nil
23462346
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
23472347
let _c6 = _6 != nil
2348-
let _c7 = _7 != nil
2348+
let _c7 = (Int(_1!) & Int(1 << 13) == 0) || _7 != nil
23492349
let _c8 = (Int(_1!) & Int(1 << 3) == 0) || _8 != nil
23502350
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
23512351
let _c10 = (Int(_1!) & Int(1 << 11) == 0) || _10 != nil
23522352
let _c11 = (Int(_1!) & Int(1 << 12) == 0) || _11 != nil
23532353
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 {
2354-
return Api.ChatFull.chatFull(flags: _1!, id: _2!, about: _3!, participants: _4!, chatPhoto: _5, notifySettings: _6!, exportedInvite: _7!, botInfo: _8, pinnedMsgId: _9, folderId: _10, call: _11)
2354+
return Api.ChatFull.chatFull(flags: _1!, id: _2!, about: _3!, participants: _4!, chatPhoto: _5, notifySettings: _6!, exportedInvite: _7, botInfo: _8, pinnedMsgId: _9, folderId: _10, call: _11)
23552355
}
23562356
else {
23572357
return nil
@@ -20882,44 +20882,60 @@ public extension Api {
2088220882

2088320883
}
2088420884
public enum ExportedChatInvite: TypeConstructorDescription {
20885-
case chatInviteEmpty
20886-
case chatInviteExported(link: String)
20885+
case chatInviteExported(flags: Int32, link: String, adminId: Int32, date: Int32, startDate: Int32?, expireDate: Int32?, usageLimit: Int32?, usage: Int32?)
2088720886

2088820887
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
2088920888
switch self {
20890-
case .chatInviteEmpty:
20889+
case .chatInviteExported(let flags, let link, let adminId, let date, let startDate, let expireDate, let usageLimit, let usage):
2089120890
if boxed {
20892-
buffer.appendInt32(1776236393)
20893-
}
20894-
20895-
break
20896-
case .chatInviteExported(let link):
20897-
if boxed {
20898-
buffer.appendInt32(-64092740)
20891+
buffer.appendInt32(1847917725)
2089920892
}
20893+
serializeInt32(flags, buffer: buffer, boxed: false)
2090020894
serializeString(link, buffer: buffer, boxed: false)
20895+
serializeInt32(adminId, buffer: buffer, boxed: false)
20896+
serializeInt32(date, buffer: buffer, boxed: false)
20897+
if Int(flags) & Int(1 << 4) != 0 {serializeInt32(startDate!, buffer: buffer, boxed: false)}
20898+
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(expireDate!, buffer: buffer, boxed: false)}
20899+
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(usageLimit!, buffer: buffer, boxed: false)}
20900+
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(usage!, buffer: buffer, boxed: false)}
2090120901
break
2090220902
}
2090320903
}
2090420904

2090520905
public func descriptionFields() -> (String, [(String, Any)]) {
2090620906
switch self {
20907-
case .chatInviteEmpty:
20908-
return ("chatInviteEmpty", [])
20909-
case .chatInviteExported(let link):
20910-
return ("chatInviteExported", [("link", link)])
20907+
case .chatInviteExported(let flags, let link, let adminId, let date, let startDate, let expireDate, let usageLimit, let usage):
20908+
return ("chatInviteExported", [("flags", flags), ("link", link), ("adminId", adminId), ("date", date), ("startDate", startDate), ("expireDate", expireDate), ("usageLimit", usageLimit), ("usage", usage)])
2091120909
}
2091220910
}
2091320911

20914-
public static func parse_chatInviteEmpty(_ reader: BufferReader) -> ExportedChatInvite? {
20915-
return Api.ExportedChatInvite.chatInviteEmpty
20916-
}
2091720912
public static func parse_chatInviteExported(_ reader: BufferReader) -> ExportedChatInvite? {
20918-
var _1: String?
20919-
_1 = parseString(reader)
20913+
var _1: Int32?
20914+
_1 = reader.readInt32()
20915+
var _2: String?
20916+
_2 = parseString(reader)
20917+
var _3: Int32?
20918+
_3 = reader.readInt32()
20919+
var _4: Int32?
20920+
_4 = reader.readInt32()
20921+
var _5: Int32?
20922+
if Int(_1!) & Int(1 << 4) != 0 {_5 = reader.readInt32() }
20923+
var _6: Int32?
20924+
if Int(_1!) & Int(1 << 1) != 0 {_6 = reader.readInt32() }
20925+
var _7: Int32?
20926+
if Int(_1!) & Int(1 << 2) != 0 {_7 = reader.readInt32() }
20927+
var _8: Int32?
20928+
if Int(_1!) & Int(1 << 3) != 0 {_8 = reader.readInt32() }
2092020929
let _c1 = _1 != nil
20921-
if _c1 {
20922-
return Api.ExportedChatInvite.chatInviteExported(link: _1!)
20930+
let _c2 = _2 != nil
20931+
let _c3 = _3 != nil
20932+
let _c4 = _4 != nil
20933+
let _c5 = (Int(_1!) & Int(1 << 4) == 0) || _5 != nil
20934+
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
20935+
let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil
20936+
let _c8 = (Int(_1!) & Int(1 << 3) == 0) || _8 != nil
20937+
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
20938+
return Api.ExportedChatInvite.chatInviteExported(flags: _1!, link: _2!, adminId: _3!, date: _4!, startDate: _5, expireDate: _6, usageLimit: _7, usage: _8)
2092320939
}
2092420940
else {
2092520941
return nil

0 commit comments

Comments
 (0)