mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
Merge branch 'master' of https://github.com/peter-iakovlev/TelegramCore
This commit is contained in:
commit
6dd610e518
@ -274,6 +274,12 @@ public final class PendingMessageManager {
|
|||||||
} else {
|
} else {
|
||||||
messageContext.state = .waitingForUploadToStart(groupId: message.groupingKey, upload: contentUploadSignal)
|
messageContext.state = .waitingForUploadToStart(groupId: message.groupingKey, upload: contentUploadSignal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let _ = currentGroupId, message.groupingKey != currentGroupId {
|
||||||
|
currentGroupId = nil
|
||||||
|
} else {
|
||||||
|
currentGroupId = message.groupingKey
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let currentGroupId = currentGroupId {
|
if let currentGroupId = currentGroupId {
|
||||||
@ -442,9 +448,9 @@ public final class PendingMessageManager {
|
|||||||
if let current = strongSelf.messageContexts[id] {
|
if let current = strongSelf.messageContexts[id] {
|
||||||
strongSelf.beginSendingMessage(messageContext: current, messageId: id, groupId: groupId, content: content)
|
strongSelf.beginSendingMessage(messageContext: current, messageId: id, groupId: groupId, content: content)
|
||||||
strongSelf.updateWaitingUploads(peerId: id.peerId)
|
strongSelf.updateWaitingUploads(peerId: id.peerId)
|
||||||
if let groupId = groupId {
|
//if let groupId = groupId {
|
||||||
strongSelf.beginSendingGroupIfPossible(groupId: groupId)
|
// strongSelf.beginSendingGroupIfPossible(groupId: groupId)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -806,14 +806,15 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32
|
|||||||
if let file = file {
|
if let file = file {
|
||||||
let fileMedia = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.CloudSecretFile, id: file.id), partialReference: nil, resource: file.resource(key: SecretFileEncryptionKey(aesKey: key.makeData(), aesIv: iv.makeData()), decryptedSize: size), previewRepresentations: [], mimeType: mimeType, size: Int(size), attributes: [TelegramMediaFileAttribute.Audio(isVoice: true, duration: Int(duration), title: nil, performer: nil, waveform: nil)])
|
let fileMedia = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.CloudSecretFile, id: file.id), partialReference: nil, resource: file.resource(key: SecretFileEncryptionKey(aesKey: key.makeData(), aesIv: iv.makeData()), decryptedSize: size), previewRepresentations: [], mimeType: mimeType, size: Int(size), attributes: [TelegramMediaFileAttribute.Audio(isVoice: true, duration: Int(duration), title: nil, performer: nil, waveform: nil)])
|
||||||
parsedMedia.append(fileMedia)
|
parsedMedia.append(fileMedia)
|
||||||
|
attributes.append(ConsumableContentMessageAttribute(consumed: false))
|
||||||
}
|
}
|
||||||
case let .decryptedMessageMediaDocument(thumb, thumbW, thumbH, mimeType, size, key, iv, attributes, caption):
|
case let .decryptedMessageMediaDocument(thumb, thumbW, thumbH, mimeType, size, key, iv, decryptedAttributes, caption):
|
||||||
if !caption.isEmpty {
|
if !caption.isEmpty {
|
||||||
text = caption
|
text = caption
|
||||||
}
|
}
|
||||||
if let file = file {
|
if let file = file {
|
||||||
var parsedAttributes: [TelegramMediaFileAttribute] = []
|
var parsedAttributes: [TelegramMediaFileAttribute] = []
|
||||||
for attribute in attributes {
|
for attribute in decryptedAttributes {
|
||||||
if let parsedAttribute = TelegramMediaFileAttribute(attribute) {
|
if let parsedAttribute = TelegramMediaFileAttribute(attribute) {
|
||||||
parsedAttributes.append(parsedAttribute)
|
parsedAttributes.append(parsedAttribute)
|
||||||
}
|
}
|
||||||
@ -826,6 +827,22 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32
|
|||||||
}
|
}
|
||||||
let fileMedia = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.CloudSecretFile, id: file.id), partialReference: nil, resource: file.resource(key: SecretFileEncryptionKey(aesKey: key.makeData(), aesIv: iv.makeData()), decryptedSize: size), previewRepresentations: previewRepresentations, mimeType: mimeType, size: Int(size), attributes: parsedAttributes)
|
let fileMedia = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.CloudSecretFile, id: file.id), partialReference: nil, resource: file.resource(key: SecretFileEncryptionKey(aesKey: key.makeData(), aesIv: iv.makeData()), decryptedSize: size), previewRepresentations: previewRepresentations, mimeType: mimeType, size: Int(size), attributes: parsedAttributes)
|
||||||
parsedMedia.append(fileMedia)
|
parsedMedia.append(fileMedia)
|
||||||
|
|
||||||
|
loop: for attr in parsedAttributes {
|
||||||
|
switch attr {
|
||||||
|
case let .Video(_, _, flags):
|
||||||
|
if flags.contains(.instantRoundVideo) {
|
||||||
|
attributes.append(ConsumableContentMessageAttribute(consumed: false))
|
||||||
|
}
|
||||||
|
break loop
|
||||||
|
case let .Audio(isVoice, _, _, _, _):
|
||||||
|
if isVoice {
|
||||||
|
attributes.append(ConsumableContentMessageAttribute(consumed: false))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case let .decryptedMessageMediaVideo(thumb, thumbW, thumbH, duration, mimeType, w, h, size, key, iv, caption):
|
case let .decryptedMessageMediaVideo(thumb, thumbW, thumbH, duration, mimeType, w, h, size, key, iv, caption):
|
||||||
if !caption.isEmpty {
|
if !caption.isEmpty {
|
||||||
|
|||||||
@ -261,7 +261,7 @@ public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: Peer
|
|||||||
|> mapToSignal { result -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> in
|
|> mapToSignal { result -> Signal<EncryptedSecureIdForm, RequestSecureIdFormError> in
|
||||||
return postbox.transaction { transaction -> EncryptedSecureIdForm in
|
return postbox.transaction { transaction -> EncryptedSecureIdForm in
|
||||||
switch result {
|
switch result {
|
||||||
case let .authorizationForm(flags, requiredTypes, values, errors, users, termsUrl):
|
case let .authorizationForm(_, requiredTypes, values, errors, users, termsUrl):
|
||||||
var peers: [Peer] = []
|
var peers: [Peer] = []
|
||||||
for user in users {
|
for user in users {
|
||||||
let parsed = TelegramUser(user: user)
|
let parsed = TelegramUser(user: user)
|
||||||
|
|||||||
@ -182,7 +182,7 @@ private func makeInputSecureValue(context: SecureIdAccessContext, value: SecureI
|
|||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
|
|
||||||
let files = inputData.fileReferences.map(apiInputSecretFile)
|
let files = inputData.fileReferences.map(apiInputSecretFile)
|
||||||
let translations = inputData.translationReferences.flatMap(apiInputSecretFile)
|
let translations = inputData.translationReferences.map(apiInputSecretFile)
|
||||||
|
|
||||||
if secureData != nil {
|
if secureData != nil {
|
||||||
flags |= 1 << 0
|
flags |= 1 << 0
|
||||||
|
|||||||
@ -38,53 +38,57 @@ public enum SecureIdValue: Equatable {
|
|||||||
if let selfie = passport.selfieDocument {
|
if let selfie = passport.selfieDocument {
|
||||||
result.append(selfie)
|
result.append(selfie)
|
||||||
}
|
}
|
||||||
if let fontSide = passport.frontSideDocument {
|
if let frontSide = passport.frontSideDocument {
|
||||||
result.append(fontSide)
|
result.append(frontSide)
|
||||||
}
|
}
|
||||||
|
result.append(contentsOf: passport.translations)
|
||||||
return result
|
return result
|
||||||
case let .internalPassport(passport):
|
case let .internalPassport(passport):
|
||||||
var result = passport.verificationDocuments
|
var result = passport.verificationDocuments
|
||||||
if let selfie = passport.selfieDocument {
|
if let selfie = passport.selfieDocument {
|
||||||
result.append(selfie)
|
result.append(selfie)
|
||||||
}
|
}
|
||||||
if let fontSide = passport.frontSideDocument {
|
if let frontSide = passport.frontSideDocument {
|
||||||
result.append(fontSide)
|
result.append(frontSide)
|
||||||
}
|
}
|
||||||
|
result.append(contentsOf: passport.translations)
|
||||||
return result
|
return result
|
||||||
case let .driversLicense(driversLicense):
|
case let .driversLicense(driversLicense):
|
||||||
var result = driversLicense.verificationDocuments
|
var result = driversLicense.verificationDocuments
|
||||||
if let selfie = driversLicense.selfieDocument {
|
if let selfie = driversLicense.selfieDocument {
|
||||||
result.append(selfie)
|
result.append(selfie)
|
||||||
}
|
}
|
||||||
if let fontSide = driversLicense.frontSideDocument {
|
if let frontSide = driversLicense.frontSideDocument {
|
||||||
result.append(fontSide)
|
result.append(frontSide)
|
||||||
}
|
}
|
||||||
if let backSide = driversLicense.backSideDocument {
|
if let backSide = driversLicense.backSideDocument {
|
||||||
result.append(backSide)
|
result.append(backSide)
|
||||||
}
|
}
|
||||||
|
result.append(contentsOf: driversLicense.translations)
|
||||||
return result
|
return result
|
||||||
case let .idCard(idCard):
|
case let .idCard(idCard):
|
||||||
var result = idCard.verificationDocuments
|
var result = idCard.verificationDocuments
|
||||||
if let selfie = idCard.selfieDocument {
|
if let selfie = idCard.selfieDocument {
|
||||||
result.append(selfie)
|
result.append(selfie)
|
||||||
}
|
}
|
||||||
if let fontSide = idCard.frontSideDocument {
|
if let frontSide = idCard.frontSideDocument {
|
||||||
result.append(fontSide)
|
result.append(frontSide)
|
||||||
}
|
}
|
||||||
if let backSide = idCard.backSideDocument {
|
if let backSide = idCard.backSideDocument {
|
||||||
result.append(backSide)
|
result.append(backSide)
|
||||||
}
|
}
|
||||||
|
result.append(contentsOf: idCard.translations)
|
||||||
return result
|
return result
|
||||||
case let .passportRegistration(passportRegistration):
|
case let .passportRegistration(passportRegistration):
|
||||||
return passportRegistration.verificationDocuments
|
return passportRegistration.verificationDocuments + passportRegistration.translations
|
||||||
case let .temporaryRegistration(passportRegistration):
|
case let .temporaryRegistration(passportRegistration):
|
||||||
return passportRegistration.verificationDocuments
|
return passportRegistration.verificationDocuments + passportRegistration.translations
|
||||||
case let .bankStatement(bankStatement):
|
case let .bankStatement(bankStatement):
|
||||||
return bankStatement.verificationDocuments
|
return bankStatement.verificationDocuments + bankStatement.translations
|
||||||
case let .utilityBill(utilityBill):
|
case let .utilityBill(utilityBill):
|
||||||
return utilityBill.verificationDocuments
|
return utilityBill.verificationDocuments + utilityBill.translations
|
||||||
case let .rentalAgreement(rentalAgreement):
|
case let .rentalAgreement(rentalAgreement):
|
||||||
return rentalAgreement.verificationDocuments
|
return rentalAgreement.verificationDocuments + rentalAgreement.translations
|
||||||
default:
|
default:
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|||||||
@ -224,7 +224,9 @@ func fetchAndUpdateCachedPeerData(peerId: PeerId, network: Network, postbox: Pos
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch fullChat {
|
switch fullChat {
|
||||||
case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId):
|
// case channelFull(flags: Int32, id: Int32, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: 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?)
|
||||||
|
|
||||||
|
case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, apiReadInboxMaxId, apiReadOutboxMaxId, apiUnreadCount, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId):
|
||||||
var channelFlags = CachedChannelFlags()
|
var channelFlags = CachedChannelFlags()
|
||||||
if (flags & (1 << 3)) != 0 {
|
if (flags & (1 << 3)) != 0 {
|
||||||
channelFlags.insert(.canDisplayParticipants)
|
channelFlags.insert(.canDisplayParticipants)
|
||||||
@ -288,6 +290,22 @@ func fetchAndUpdateCachedPeerData(peerId: PeerId, network: Network, postbox: Pos
|
|||||||
|
|
||||||
transaction.updatePeerPresences(peerPresences)
|
transaction.updatePeerPresences(peerPresences)
|
||||||
|
|
||||||
|
|
||||||
|
// let readState = transaction.getReadState(peerId)
|
||||||
|
//
|
||||||
|
// let hasReadState: Bool = false//readState?.hasNamespace(Namespaces.Message.Cloud) ?? false
|
||||||
|
//
|
||||||
|
// if !hasReadState {
|
||||||
|
// var readStates: [PeerId: [MessageId.Namespace: PeerReadState]] = [:]
|
||||||
|
// if readStates[peerId] == nil {
|
||||||
|
// readStates[peerId] = [:]
|
||||||
|
// }
|
||||||
|
// readStates[peerId]![Namespaces.Message.Cloud] = .idBased(maxIncomingReadId: apiReadInboxMaxId, maxOutgoingReadId: apiReadOutboxMaxId, maxKnownId: readState?.maxKnownId ?? 0, count: apiUnreadCount, markedUnread: readState?.markedUnread ?? false)
|
||||||
|
// transaction.resetIncomingReadStates(readStates)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in
|
let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in
|
||||||
let namespace: ItemCollectionId.Namespace
|
let namespace: ItemCollectionId.Namespace
|
||||||
switch apiSet {
|
switch apiSet {
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import Foundation
|
|||||||
public enum SecureIdPreparePhoneVerificationError {
|
public enum SecureIdPreparePhoneVerificationError {
|
||||||
case generic
|
case generic
|
||||||
case flood
|
case flood
|
||||||
case occupied
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct SecureIdPreparePhoneVerificationPayload {
|
public struct SecureIdPreparePhoneVerificationPayload {
|
||||||
@ -28,8 +27,6 @@ public func secureIdPreparePhoneVerification(network: Network, value: SecureIdPh
|
|||||||
|> mapError { error -> SecureIdPreparePhoneVerificationError in
|
|> mapError { error -> SecureIdPreparePhoneVerificationError in
|
||||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||||
return .flood
|
return .flood
|
||||||
} else if error.errorDescription == "PHONE_NUMBER_OCCUPIED" {
|
|
||||||
return .occupied
|
|
||||||
}
|
}
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user