mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Initial peer id refactoring
This commit is contained in:
parent
86e3e2bc35
commit
4dae31e340
@ -35,7 +35,7 @@ private func parseAppSpecificContactReference(_ value: String) -> PeerId? {
|
||||
}
|
||||
let idString = String(value[value.index(value.startIndex, offsetBy: phonebookUsernamePrefix.count)...])
|
||||
if let id = Int32(idString) {
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ private func callWithTelegramMessage(_ telegramMessage: Message, account: Accoun
|
||||
|
||||
@available(iOSApplicationExtension 10.0, iOS 10.0, *)
|
||||
private func messageWithTelegramMessage(_ telegramMessage: Message) -> INMessage? {
|
||||
guard let author = telegramMessage.author, let user = telegramMessage.peers[author.id] as? TelegramUser, user.id.id != 777000 else {
|
||||
guard let author = telegramMessage.author, let user = telegramMessage.peers[author.id] as? TelegramUser, user.id.id._internalGetInt32Value() != 777000 else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ public enum ChatListSearchFilter: Equatable {
|
||||
case .voice:
|
||||
return 5
|
||||
case let .peer(peerId, _, _, _):
|
||||
return peerId.id
|
||||
return peerId.id._internalGetInt32Value()
|
||||
case let .date(_, date, _):
|
||||
return date
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ public func parseAppSpecificContactReference(_ value: String) -> PeerId? {
|
||||
}
|
||||
let idString = String(value[value.index(value.startIndex, offsetBy: phonebookUsernamePrefix.count)...])
|
||||
if let id = Int32(idString) {
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public func freeMediaFileInteractiveFetched(account: Account, fileReference: Fil
|
||||
public func freeMediaFileInteractiveFetched(fetchManager: FetchManager, fileReference: FileMediaReference, priority: FetchManagerPriority) -> Signal<Void, NoError> {
|
||||
let file = fileReference.media
|
||||
let mediaReference = AnyMediaReference.standalone(media: fileReference.media)
|
||||
return fetchManager.interactivelyFetched(category: fetchCategoryForFile(file), location: .chat(PeerId(namespace: 0, id: 0)), locationKey: .free, mediaReference: mediaReference, resourceReference: mediaReference.resourceReference(file.resource), ranges: IndexSet(integersIn: 0 ..< Int(Int32.max) as Range<Int>), statsCategory: statsCategoryForFileWithAttributes(file.attributes), elevatedPriority: false, userInitiated: false, priority: priority, storeToDownloadsPeerType: nil)
|
||||
return fetchManager.interactivelyFetched(category: fetchCategoryForFile(file), location: .chat(PeerId(0)), locationKey: .free, mediaReference: mediaReference, resourceReference: mediaReference.resourceReference(file.resource), ranges: IndexSet(integersIn: 0 ..< Int(Int32.max) as Range<Int>), statsCategory: statsCategoryForFileWithAttributes(file.attributes), elevatedPriority: false, userInitiated: false, priority: priority, storeToDownloadsPeerType: nil)
|
||||
}
|
||||
|
||||
public func freeMediaFileResourceInteractiveFetched(account: Account, fileReference: FileMediaReference, resource: MediaResource) -> Signal<FetchResourceSourceType, FetchResourceError> {
|
||||
|
@ -337,7 +337,7 @@ public final class AvatarNode: ASDisplayNode {
|
||||
} else if peer?.restrictionText(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) == nil {
|
||||
representation = peer?.smallProfileImage
|
||||
}
|
||||
let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? PeerId(namespace: 0, id: 0), peer?.displayLetters ?? [], representation)
|
||||
let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? PeerId(0), peer?.displayLetters ?? [], representation)
|
||||
if updatedState != self.state || overrideImage != self.overrideImage || theme !== self.theme {
|
||||
self.state = updatedState
|
||||
self.overrideImage = overrideImage
|
||||
@ -381,7 +381,7 @@ public final class AvatarNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
self.editOverlayNode?.isHidden = true
|
||||
parameters = AvatarNodeParameters(theme: theme, accountPeerId: context.account.peerId, peerId: peer?.id ?? PeerId(namespace: 0, id: 0), letters: peer?.displayLetters ?? [], font: self.font, icon: icon, explicitColorIndex: nil, hasImage: false, clipStyle: clipStyle)
|
||||
parameters = AvatarNodeParameters(theme: theme, accountPeerId: context.account.peerId, peerId: peer?.id ?? PeerId(0), letters: peer?.displayLetters ?? [], font: self.font, icon: icon, explicitColorIndex: nil, hasImage: false, clipStyle: clipStyle)
|
||||
}
|
||||
if self.parameters == nil || self.parameters != parameters {
|
||||
self.parameters = parameters
|
||||
@ -453,10 +453,10 @@ public final class AvatarNode: ASDisplayNode {
|
||||
colorIndex = explicitColorIndex
|
||||
} else {
|
||||
if let peerId = parameters.peerId {
|
||||
if peerId.namespace == -1 {
|
||||
if peerId.namespace == .max {
|
||||
colorIndex = -1
|
||||
} else {
|
||||
colorIndex = abs(Int(clamping: peerId.id))
|
||||
colorIndex = abs(Int(clamping: peerId.id._internalGetInt32Value()))
|
||||
}
|
||||
} else {
|
||||
colorIndex = -1
|
||||
@ -630,10 +630,10 @@ public func drawPeerAvatarLetters(context: CGContext, size: CGSize, font: UIFont
|
||||
context.clip()
|
||||
|
||||
let colorIndex: Int
|
||||
if peerId.namespace == -1 {
|
||||
if peerId.namespace == .max {
|
||||
colorIndex = -1
|
||||
} else {
|
||||
colorIndex = Int(abs(peerId.id))
|
||||
colorIndex = Int(abs(peerId.id._internalGetInt32Value()))
|
||||
}
|
||||
|
||||
let colorsArray: NSArray
|
||||
|
@ -260,7 +260,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
||||
|
||||
let groupAndIndex = transaction.getPeerChatListIndex(peerId)
|
||||
|
||||
let archiveEnabled = !isSavedMessages && peerId != PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000) && peerId == context.account.peerId
|
||||
let archiveEnabled = !isSavedMessages && peerId != PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) && peerId == context.account.peerId
|
||||
if let (group, index) = groupAndIndex {
|
||||
if archiveEnabled {
|
||||
let isArchived = group == Namespaces.PeerGroup.archive
|
||||
|
@ -938,7 +938,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
if archiveEnabled {
|
||||
for peerId in peerIds {
|
||||
if peerId == PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000) {
|
||||
if peerId == PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) {
|
||||
archiveEnabled = false
|
||||
break
|
||||
} else if peerId == strongSelf.context.account.peerId {
|
||||
|
@ -179,7 +179,7 @@ private final class ChatListShimmerNode: ASDisplayNode {
|
||||
|
||||
let chatListPresentationData = ChatListPresentationData(theme: presentationData.theme, fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true)
|
||||
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 1), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let timestamp1: Int32 = 100000
|
||||
let peers = SimpleDictionary<PeerId, Peer>()
|
||||
let interaction = ChatListNodeInteraction(activateSearch: {}, peerSelected: { _, _ in }, disabledPeerSelected: { _ in }, togglePeerSelected: { _ in }, additionalCategorySelected: { _ in
|
||||
|
@ -2327,7 +2327,7 @@ private final class ChatListSearchShimmerNode: ASDisplayNode {
|
||||
|
||||
let chatListPresentationData = ChatListPresentationData(theme: presentationData.theme, fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true)
|
||||
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 1), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let timestamp1: Int32 = 100000
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
peers[peer1.id] = peer1
|
||||
|
@ -196,7 +196,7 @@ private enum RevealOptionKey: Int32 {
|
||||
}
|
||||
|
||||
private func canArchivePeer(id: PeerId, accountPeerId: PeerId) -> Bool {
|
||||
if id.namespace == Namespaces.Peer.CloudUser && id.id == 777000 {
|
||||
if id.namespace == Namespaces.Peer.CloudUser && id.id._internalGetInt32Value() == 777000 {
|
||||
return false
|
||||
}
|
||||
if id == accountPeerId {
|
||||
|
@ -360,7 +360,7 @@ func chatListNodeEntriesForView(_ view: ChatListView, state: ChatListNodeState,
|
||||
|
||||
if view.laterIndex == nil, case .chatList = mode {
|
||||
for groupReference in view.groupEntries {
|
||||
let messageIndex = MessageIndex(id: MessageId(peerId: PeerId(namespace: 0, id: 0), namespace: 0, id: 0), timestamp: 1)
|
||||
let messageIndex = MessageIndex(id: MessageId(peerId: PeerId(0), namespace: 0, id: 0), timestamp: 1)
|
||||
result.append(.GroupReferenceEntry(index: ChatListIndex(pinningIndex: pinningIndex, messageIndex: messageIndex), presentationData: state.presentationData, groupId: groupReference.groupId, peers: groupReference.renderedPeers, message: groupReference.message, editing: state.editing, unreadState: groupReference.unreadState, revealed: state.archiveShouldBeTemporaryRevealed, hiddenByDefault: hideArchivedFolderByDefault))
|
||||
if pinningIndex != 0 {
|
||||
pinningIndex -= 1
|
||||
|
@ -58,7 +58,7 @@ private enum InviteContactsEntry: Comparable, Identifiable {
|
||||
} else {
|
||||
status = .none
|
||||
}
|
||||
let peer = TelegramUser(id: PeerId(namespace: -1, id: 0), accessHash: nil, firstName: contact.firstName, lastName: contact.lastName, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: contact.firstName, lastName: contact.lastName, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: peer, chatPeer: peer), status: status, enabled: true, selection: selection, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .contacts, theme: theme, strings: strings, actionTitle: nil, action: nil), action: { _ in
|
||||
interaction.toggleContact(id)
|
||||
})
|
||||
|
@ -1250,7 +1250,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
}, openUrl: { _ in }, openPeer: { _ in
|
||||
}, showAll: false)
|
||||
|
||||
let peer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 1), accessHash: nil, firstName: "", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let message = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peer, text: "", attributes: [], media: [map], peers: SimpleDictionary(), associatedMessages: SimpleDictionary(), associatedMessageIds: [])
|
||||
|
||||
let controller = LocationViewController(context: self.context, subject: message, params: controllerParams)
|
||||
|
@ -598,7 +598,7 @@ public final class InviteLinkViewController: ViewController {
|
||||
if state.importers.isEmpty && state.isLoadingMore {
|
||||
count = min(4, state.count)
|
||||
loading = true
|
||||
let fakeUser = TelegramUser(id: PeerId(namespace: -1, id: 0), accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let fakeUser = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
for i in 0 ..< count {
|
||||
entries.append(.importer(Int32(i), presentationData.theme, presentationData.dateTimeFormat, fakeUser, 0, true))
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
||||
}
|
||||
|
||||
var updateAvatarOverlayImage: UIImage?
|
||||
if item.updatingImage != nil && item.peer?.id.namespace != -1 && currentOverlayImage == nil {
|
||||
if item.updatingImage != nil && item.peer?.id.namespace != .max && currentOverlayImage == nil {
|
||||
updateAvatarOverlayImage = updatingAvatarOverlayImage
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ final class JoinLinkPreviewPeerContentNode: ASDisplayNode, ShareContentContainer
|
||||
|
||||
super.init()
|
||||
|
||||
let peer = TelegramGroup(id: PeerId(namespace: 0, id: 0), title: title, photo: image.flatMap { [$0] } ?? [], participantCount: Int(memberCount), role: .member, membership: .Left, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
let peer = TelegramGroup(id: PeerId(0), title: title, photo: image.flatMap { [$0] } ?? [], participantCount: Int(memberCount), role: .member, membership: .Left, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
|
||||
self.addSubnode(self.avatarNode)
|
||||
self.avatarNode.setPeer(context: context, theme: theme, peer: peer, emptyColor: theme.list.mediaPlaceholderColor)
|
||||
|
@ -67,7 +67,7 @@ public func configureLegacyAssetPicker(_ controller: TGMediaAssetsController, co
|
||||
}
|
||||
|
||||
public func legacyAssetPicker(context: AccountContext, presentationData: PresentationData, editingMedia: Bool, fileMode: Bool, peer: Peer?, saveEditedPhotos: Bool, allowGrouping: Bool, selectionLimit: Int) -> Signal<(LegacyComponentsContext) -> TGMediaAssetsController, Void> {
|
||||
let isSecretChat = (peer?.id.namespace ?? 0) == Namespaces.Peer.SecretChat
|
||||
let isSecretChat = (peer?.id.namespace._internalGetInt32Value() ?? 0) == Namespaces.Peer.SecretChat._internalGetInt32Value()
|
||||
|
||||
return Signal { subscriber in
|
||||
let intent = fileMode ? TGMediaAssetsControllerSendFileIntent : TGMediaAssetsControllerSendMediaIntent
|
||||
|
@ -19,7 +19,7 @@ public func legacySuggestionContext(context: AccountContext, peerId: PeerId, cha
|
||||
for peer in peers {
|
||||
if let peer = peer as? TelegramUser {
|
||||
let user = TGUser()
|
||||
user.uid = peer.id.id
|
||||
user.uid = peer.id.id._internalGetInt32Value()
|
||||
user.firstName = peer.firstName
|
||||
user.lastName = peer.lastName
|
||||
user.userName = peer.addressName
|
||||
|
@ -61,12 +61,12 @@ final class LegacyPeerAvatarPlaceholderDataSource: TGImageDataSource {
|
||||
return EmptyDisposable
|
||||
}
|
||||
|
||||
var peerId = PeerId(namespace: 0, id: 0)
|
||||
var peerId = PeerId(0)
|
||||
|
||||
if let uid = args["uid"] as? String, let nUid = Int32(uid) {
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: nUid)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(nUid))
|
||||
} else if let cid = args["cid"] as? String, let nCid = Int32(cid) {
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: nCid)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(nCid))
|
||||
}
|
||||
|
||||
let image = generateImage(CGSize(width: CGFloat(width), height: CGFloat(height)), rotatedContext: { size, context in
|
||||
@ -77,10 +77,10 @@ final class LegacyPeerAvatarPlaceholderDataSource: TGImageDataSource {
|
||||
context.clip()
|
||||
|
||||
let colorIndex: Int
|
||||
if peerId.id == 0 {
|
||||
if peerId.id._internalGetInt32Value() == 0 {
|
||||
colorIndex = -1
|
||||
} else {
|
||||
colorIndex = abs(Int(account.peerId.id + peerId.id))
|
||||
colorIndex = abs(Int(account.peerId.id._internalGetInt32Value() &+ peerId.id._internalGetInt32Value()))
|
||||
}
|
||||
|
||||
let colorsArray: NSArray
|
||||
|
@ -257,7 +257,7 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
id = image.0.id
|
||||
category = image.9
|
||||
} else {
|
||||
id = Int64(entry.peer?.id.id ?? 0)
|
||||
id = Int64(entry.peer?.id.id._internalGetInt32Value() ?? 0)
|
||||
if let resource = entry.videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource {
|
||||
id = id &+ resource.photoId
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ public final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
||||
representations = topRepresentations
|
||||
videoRepresentations = videoRepresentationsValue
|
||||
immediateThumbnailData = immediateThumbnail
|
||||
id = Int64(self.peer.id.id)
|
||||
id = Int64(self.peer.id.id._internalGetInt32Value())
|
||||
if let resource = videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource {
|
||||
id = id &+ resource.photoId
|
||||
}
|
||||
@ -333,7 +333,7 @@ public final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
||||
if case let .cloud(imageId, _, _) = reference {
|
||||
id = imageId
|
||||
} else {
|
||||
id = Int64(self.peer.id.id)
|
||||
id = Int64(self.peer.id.id._internalGetInt32Value())
|
||||
}
|
||||
}
|
||||
self.imageNode.setSignal(chatAvatarGalleryPhoto(account: self.context.account, representations: representations, immediateThumbnailData: immediateThumbnailData, autoFetchFullSize: true, attemptSynchronously: synchronous), attemptSynchronously: synchronous, dispatchOnDisplayLink: false)
|
||||
|
@ -648,7 +648,7 @@ private func deviceContactInfoEntries(account: Account, presentationData: Presen
|
||||
|
||||
let isOrganization = personName.0.isEmpty && personName.1.isEmpty && !contactData.organization.isEmpty
|
||||
|
||||
entries.append(.info(entries.count, presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, peer: peer ?? TelegramUser(id: PeerId(namespace: -1, id: 0), accessHash: nil, firstName: isOrganization ? contactData.organization : personName.0, lastName: isOrganization ? nil : personName.1, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []), state: ItemListAvatarAndNameInfoItemState(editingName: editingName, updatingName: nil), job: isOrganization ? nil : jobSummary, isPlain: !isShare))
|
||||
entries.append(.info(entries.count, presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, peer: peer ?? TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: isOrganization ? contactData.organization : personName.0, lastName: isOrganization ? nil : personName.1, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []), state: ItemListAvatarAndNameInfoItemState(editingName: editingName, updatingName: nil), job: isOrganization ? nil : jobSummary, isPlain: !isShare))
|
||||
|
||||
if !selecting {
|
||||
if let _ = peer {
|
||||
|
@ -62,8 +62,7 @@ final class ChatListIndexTable: Table {
|
||||
}
|
||||
|
||||
private func key(_ peerId: PeerId) -> ValueBoxKey {
|
||||
self.sharedKey.setInt32(0, value: peerId.namespace)
|
||||
self.sharedKey.setInt32(4, value: peerId.id)
|
||||
self.sharedKey.setInt64(0, value: peerId.toInt64())
|
||||
assert(self.sharedKey.getInt64(0) == peerId.toInt64())
|
||||
return self.sharedKey
|
||||
}
|
||||
@ -648,7 +647,7 @@ final class ChatListIndexTable: Table {
|
||||
var summary = PeerGroupUnreadCountersCombinedSummary(namespaces: [:])
|
||||
|
||||
postbox.chatListTable.forEachPeer(groupId: groupId, { peerId in
|
||||
if peerId.namespace == Int32.max {
|
||||
if peerId.namespace == .max {
|
||||
return
|
||||
}
|
||||
guard let combinedState = postbox.readStateTable.getCombinedState(peerId) else {
|
||||
|
@ -22,11 +22,11 @@ final class ContactTable: Table {
|
||||
}
|
||||
|
||||
private func lowerBound() -> ValueBoxKey {
|
||||
return self.key(PeerId(namespace: 0, id: 0))
|
||||
return self.key(PeerId(0))
|
||||
}
|
||||
|
||||
private func upperBound() -> ValueBoxKey {
|
||||
return self.key(PeerId(namespace: Int32.max, id: Int32.max))
|
||||
return self.key(PeerId.max)
|
||||
}
|
||||
|
||||
func isContact(peerId: PeerId) -> Bool {
|
||||
@ -81,7 +81,7 @@ final class ContactTable: Table {
|
||||
let removedPeerIds = peerIdsBeforeModification.subtracting(peerIds)
|
||||
let addedPeerIds = peerIds.subtracting(peerIdsBeforeModification)
|
||||
|
||||
let sharedKey = self.key(PeerId(namespace: 0, id: 0))
|
||||
let sharedKey = self.key(PeerId(0))
|
||||
|
||||
for peerId in removedPeerIds {
|
||||
self.valueBox.remove(self.table, key: self.key(peerId, sharedKey: sharedKey), secure: false)
|
||||
|
@ -23,7 +23,7 @@ final class GlobalMessageIdsTable: Table {
|
||||
|
||||
func set(_ globalId: Int32, id: MessageId) {
|
||||
assert(id.namespace == 0)
|
||||
assert(id.peerId.namespace == 0 || id.peerId.namespace == 1)
|
||||
assert(id.peerId.namespace._internalGetInt32Value() == 0 || id.peerId.namespace._internalGetInt32Value() == 1)
|
||||
assert(self.seedConfiguration.globalMessageIdsPeerIdNamespaces.contains(GlobalMessageIdsNamespace(peerIdNamespace: id.peerId.namespace, messageIdNamespace: id.namespace)))
|
||||
|
||||
self.sharedBuffer.reset()
|
||||
|
@ -21,11 +21,10 @@ public struct MessageId: Hashable, Comparable, CustomStringConvertible, PostboxC
|
||||
}
|
||||
|
||||
public init(_ buffer: ReadBuffer) {
|
||||
var peerIdNamespaceValue: Int32 = 0
|
||||
memcpy(&peerIdNamespaceValue, buffer.memory + buffer.offset, 4)
|
||||
var peerIdIdValue: Int32 = 0
|
||||
memcpy(&peerIdIdValue, buffer.memory + (buffer.offset + 4), 4)
|
||||
self.peerId = PeerId(namespace: peerIdNamespaceValue, id: peerIdIdValue)
|
||||
var peerIdInt64Value: Int64 = 0
|
||||
memcpy(&peerIdInt64Value, buffer.memory + buffer.offset, 8)
|
||||
|
||||
self.peerId = PeerId(peerIdInt64Value)
|
||||
|
||||
var namespaceValue: Int32 = 0
|
||||
memcpy(&namespaceValue, buffer.memory + (buffer.offset + 8), 4)
|
||||
@ -120,11 +119,11 @@ public struct MessageIndex: Comparable, Hashable {
|
||||
}
|
||||
|
||||
public static func absoluteUpperBound() -> MessageIndex {
|
||||
return MessageIndex(id: MessageId(peerId: PeerId(namespace: Int32(Int8.max), id: Int32.max), namespace: Int32(Int8.max), id: Int32.max), timestamp: Int32.max)
|
||||
return MessageIndex(id: MessageId(peerId: PeerId.max, namespace: Int32(Int8.max), id: Int32.max), timestamp: Int32.max)
|
||||
}
|
||||
|
||||
public static func absoluteLowerBound() -> MessageIndex {
|
||||
return MessageIndex(id: MessageId(peerId: PeerId(namespace: 0, id: 0), namespace: 0, id: 0), timestamp: 0)
|
||||
return MessageIndex(id: MessageId(peerId: PeerId(0), namespace: 0, id: 0), timestamp: 0)
|
||||
}
|
||||
|
||||
public static func lowerBound(peerId: PeerId) -> MessageIndex {
|
||||
|
@ -223,7 +223,7 @@ final class MessageHistoryTable: Table {
|
||||
}
|
||||
|
||||
private func processIndexOperations(_ peerId: PeerId, operations: [MessageHistoryIndexOperation], processedOperationsByPeerId: inout [PeerId: [MessageHistoryOperation]], updatedMedia: inout [MediaId: Media?], unsentMessageOperations: inout [IntermediateMessageHistoryUnsentOperation], updatedPeerReadStateOperations: inout [PeerId: PeerReadStateSynchronizationOperation?], globalTagsOperations: inout [GlobalMessageHistoryTagsOperation], pendingActionsOperations: inout [PendingMessageActionsOperation], updatedMessageActionsSummaries: inout [PendingMessageActionsSummaryKey: Int32], updatedMessageTagSummaries: inout [MessageHistoryTagsSummaryKey: MessageHistoryTagNamespaceSummary], invalidateMessageTagSummaries: inout [InvalidatedMessageHistoryTagsSummaryEntryOperation], localTagsOperations: inout [IntermediateMessageHistoryLocalTagsOperation], timestampBasedMessageAttributesOperations: inout [TimestampBasedMessageAttributesOperation]) {
|
||||
let sharedKey = self.key(MessageIndex(id: MessageId(peerId: PeerId(namespace: 0, id: 0), namespace: 0, id: 0), timestamp: 0))
|
||||
let sharedKey = self.key(MessageIndex(id: MessageId(peerId: PeerId(0), namespace: 0, id: 0), timestamp: 0))
|
||||
let sharedBuffer = WriteBuffer()
|
||||
let sharedEncoder = PostboxEncoder()
|
||||
|
||||
|
@ -1,8 +1,57 @@
|
||||
import Foundation
|
||||
|
||||
public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable {
|
||||
public typealias Namespace = Int32
|
||||
public typealias Id = Int32
|
||||
public struct Namespace: Comparable, Hashable, Codable {
|
||||
public static var max: Namespace {
|
||||
return Namespace(rawValue: 0x7)
|
||||
}
|
||||
|
||||
fileprivate var rawValue: UInt32
|
||||
|
||||
public init(rawValue: UInt32) {
|
||||
precondition((rawValue | 0x7) == 0x7)
|
||||
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static func _internalFromInt32Value(_ value: Int32) -> Namespace {
|
||||
return Namespace(rawValue: UInt32(bitPattern: value))
|
||||
}
|
||||
|
||||
public func _internalGetInt32Value() -> Int32 {
|
||||
return Int32(bitPattern: self.rawValue)
|
||||
}
|
||||
|
||||
public static func <(lhs: Namespace, rhs: Namespace) -> Bool {
|
||||
return lhs.rawValue < rhs.rawValue
|
||||
}
|
||||
}
|
||||
|
||||
public struct Id: Comparable, Hashable, Codable {
|
||||
fileprivate var rawValue: UInt64
|
||||
|
||||
public init(rawValue: UInt64) {
|
||||
precondition((rawValue | 0xFFFFFFFFFFFFF) == 0xFFFFFFFFFFFFF)
|
||||
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static func _internalFromInt32Value(_ value: Int32) -> Id {
|
||||
return Id(rawValue: UInt64(UInt32(bitPattern: value)))
|
||||
}
|
||||
|
||||
public func _internalGetInt32Value() -> Int32 {
|
||||
return Int32(clamping: self.rawValue)
|
||||
}
|
||||
|
||||
public static func <(lhs: Id, rhs: Id) -> Bool {
|
||||
return lhs.rawValue < rhs.rawValue
|
||||
}
|
||||
}
|
||||
|
||||
public static var max: PeerId {
|
||||
return PeerId(Int64(bitPattern: UInt64.max))
|
||||
}
|
||||
|
||||
public let namespace: Namespace
|
||||
public let id: Id
|
||||
@ -13,12 +62,29 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable {
|
||||
}
|
||||
|
||||
public init(_ n: Int64) {
|
||||
self.namespace = Int32((n >> 32) & 0x7fffffff)
|
||||
self.id = Int32(bitPattern: UInt32(n & 0xffffffff))
|
||||
let data = UInt64(bitPattern: n)
|
||||
|
||||
let namespaceBits = ((data >> 32) & 0x7)
|
||||
self.namespace = Namespace(rawValue: UInt32(namespaceBits))
|
||||
|
||||
let idLowBits = data & 0xffffffff
|
||||
let idHighBits = (data >> (32 + 3)) & 0xffffffff
|
||||
assert(idHighBits == 0)
|
||||
|
||||
self.id = Id(rawValue: idLowBits)
|
||||
}
|
||||
|
||||
public func toInt64() -> Int64 {
|
||||
return (Int64(self.namespace) << 32) | Int64(bitPattern: UInt64(UInt32(bitPattern: self.id)))
|
||||
var data: UInt64 = 0
|
||||
data |= UInt64(self.namespace.rawValue) << 32
|
||||
|
||||
let idLowBits = self.id.rawValue & 0xffffffff
|
||||
let idHighBits = (self.id.rawValue >> 32) & 0x3FFFFFFF
|
||||
assert(idHighBits == 0)
|
||||
|
||||
data |= idLowBits
|
||||
|
||||
return Int64(bitPattern: data)
|
||||
}
|
||||
|
||||
public static func encodeArrayToBuffer(_ array: [PeerId], buffer: WriteBuffer) {
|
||||
@ -46,32 +112,23 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable {
|
||||
return array
|
||||
}
|
||||
|
||||
public var hashValue: Int {
|
||||
get {
|
||||
return Int(self.id)
|
||||
}
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
get {
|
||||
return "\(namespace):\(id)"
|
||||
}
|
||||
}
|
||||
|
||||
public init(_ buffer: ReadBuffer) {
|
||||
var namespace: Int32 = 0
|
||||
var id: Int32 = 0
|
||||
memcpy(&namespace, buffer.memory, 4)
|
||||
self.namespace = namespace
|
||||
memcpy(&id, buffer.memory + 4, 4)
|
||||
self.id = id
|
||||
}
|
||||
/*public init(_ buffer: ReadBuffer) {
|
||||
var value: Int64 = 0
|
||||
memcpy(&value, buffer.memory, 8)
|
||||
buffer.offset += 8
|
||||
|
||||
self.init(value)
|
||||
}*/
|
||||
|
||||
public func encodeToBuffer(_ buffer: WriteBuffer) {
|
||||
var namespace = self.namespace
|
||||
var id = self.id
|
||||
buffer.write(&namespace, offset: 0, length: 4);
|
||||
buffer.write(&id, offset: 0, length: 4);
|
||||
var value = self.toInt64()
|
||||
buffer.write(&value, offset: 0, length: 8);
|
||||
}
|
||||
|
||||
public static func <(lhs: PeerId, rhs: PeerId) -> Bool {
|
||||
|
@ -211,10 +211,8 @@ func postboxUpgrade_15to16(metadataTable: MetadataTable, valueBox: ValueBox, pro
|
||||
|
||||
valueBox.scanInt64(chatListIndexTable, values: { key, value in
|
||||
let peerId = PeerId(key)
|
||||
if peerId.namespace != Int32.max {
|
||||
if parseInclusionIndex(peerId: peerId, value: value) {
|
||||
includedPeerIds.append(peerId)
|
||||
}
|
||||
if parseInclusionIndex(peerId: peerId, value: value) {
|
||||
includedPeerIds.append(peerId)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
@ -215,10 +215,8 @@ func postboxUpgrade_16to17(metadataTable: MetadataTable, valueBox: ValueBox, pro
|
||||
|
||||
valueBox.scanInt64(chatListIndexTable, values: { key, value in
|
||||
let peerId = PeerId(key)
|
||||
if peerId.namespace != Int32.max {
|
||||
if parseInclusionIndex(peerId: peerId, value: value) {
|
||||
includedPeerIds.append(peerId)
|
||||
}
|
||||
if parseInclusionIndex(peerId: peerId, value: value) {
|
||||
includedPeerIds.append(peerId)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
@ -424,7 +424,7 @@ func postboxUpgrade_19to20(metadataTable: MetadataTable, valueBox: ValueBox, pro
|
||||
var removeChatListKeys: [ValueBoxKey] = []
|
||||
valueBox.scan(chatListTable, keys: { key in
|
||||
let (_, _, index, type) = extractChatListKey(key)
|
||||
if index.id.peerId.namespace != 3 { // Secret Chat
|
||||
if index.id.peerId.namespace._internalGetInt32Value() != 3 { // Secret Chat
|
||||
sharedChatListIndexKey.setInt64(0, value: index.id.peerId.toInt64())
|
||||
valueBox.remove(chatListIndexTable, key: sharedChatListIndexKey, secure: false)
|
||||
|
||||
|
@ -426,7 +426,7 @@ func postboxUpgrade_20to21(metadataTable: MetadataTable, valueBox: ValueBox, pro
|
||||
var removeChatListKeys: [ValueBoxKey] = []
|
||||
valueBox.scan(chatListTable, keys: { key in
|
||||
let (_, _, index, type) = extractChatListKey(key)
|
||||
if index.id.peerId.namespace != 3 { // Secret Chat
|
||||
if index.id.peerId.namespace._internalGetInt32Value() != 3 { // Secret Chat
|
||||
sharedChatListIndexKey.setInt64(0, value: index.id.peerId.toInt64())
|
||||
valueBox.remove(chatListIndexTable, key: sharedChatListIndexKey, secure: false)
|
||||
|
||||
|
@ -162,7 +162,7 @@ private final class BubbleSettingsControllerNode: ASDisplayNode, UIScrollViewDel
|
||||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
|
@ -150,7 +150,7 @@ class ForwardPrivacyChatPreviewItemNode: ListViewItemNode {
|
||||
let insets: UIEdgeInsets
|
||||
let separatorHeight = UIScreenPixel
|
||||
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1))
|
||||
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
|
@ -223,14 +223,14 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, UIScrollView
|
||||
let peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
let selfPeer = TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 1), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 2), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: 3), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 4), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 4), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: 5), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: 5), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer7 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 6), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer7 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(6)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
|
||||
let timestamp = self.referenceTimestamp
|
||||
|
||||
@ -308,7 +308,7 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, UIScrollView
|
||||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
|
@ -777,11 +777,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
let peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
let selfPeer = TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 1), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 2), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: 3), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 4), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: 4), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
|
||||
let timestamp = self.referenceTimestamp
|
||||
|
||||
@ -843,7 +843,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.theme, strings: self.presentationData.strings, wallpaper: self.wallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
|
@ -361,14 +361,14 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
let peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
let selfPeer = TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 1), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 2), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: 3), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 4), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 4), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: 5), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: 5), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer7 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 6), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil)
|
||||
let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer7 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(6)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
|
||||
let timestamp = self.referenceTimestamp
|
||||
|
||||
@ -448,7 +448,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.previewTheme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
|
@ -151,8 +151,8 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode {
|
||||
let insets: UIEdgeInsets
|
||||
let separatorHeight = UIScreenPixel
|
||||
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||
let otherPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 2)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1))
|
||||
let otherPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2))
|
||||
var items: [ListViewItem] = []
|
||||
for messageItem in item.messageItems.reversed() {
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
|
@ -800,7 +800,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
}
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
|
@ -31,11 +31,11 @@ public struct Namespaces {
|
||||
}
|
||||
|
||||
public struct Peer {
|
||||
public static let CloudUser: Int32 = 0
|
||||
public static let CloudGroup: Int32 = 1
|
||||
public static let CloudChannel: Int32 = 2
|
||||
public static let SecretChat: Int32 = 3
|
||||
public static let Empty: Int32 = Int32.max
|
||||
public static let CloudUser = PeerId.Namespace._internalFromInt32Value(0)
|
||||
public static let CloudGroup = PeerId.Namespace._internalFromInt32Value(1)
|
||||
public static let CloudChannel = PeerId.Namespace._internalFromInt32Value(2)
|
||||
public static let SecretChat = PeerId.Namespace._internalFromInt32Value(3)
|
||||
public static let Empty = PeerId.Namespace.max
|
||||
}
|
||||
|
||||
public struct ItemCollection {
|
||||
|
@ -39,15 +39,15 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable {
|
||||
switch peer {
|
||||
case let user as TelegramUser:
|
||||
if let accessHash = user.accessHash {
|
||||
self = .user(id: user.id.id, accessHash: accessHash.value)
|
||||
self = .user(id: user.id.id._internalGetInt32Value(), accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let group as TelegramGroup:
|
||||
self = .group(id: group.id.id)
|
||||
self = .group(id: group.id.id._internalGetInt32Value())
|
||||
case let channel as TelegramChannel:
|
||||
if let accessHash = channel.accessHash {
|
||||
self = .channel(id: channel.id.id, accessHash: accessHash.value)
|
||||
self = .channel(id: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public let telegramPostboxSeedConfiguration: SeedConfiguration = {
|
||||
globalMessageIdsPeerIdNamespaces.insert(GlobalMessageIdsNamespace(peerIdNamespace: peerIdNamespace, messageIdNamespace: Namespaces.Message.Cloud))
|
||||
}
|
||||
|
||||
return SeedConfiguration(globalMessageIdsPeerIdNamespaces: globalMessageIdsPeerIdNamespaces, initializeChatListWithHole: (topLevel: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: 0), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1)), groups: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: 0), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1))), messageHoles: messageHoles, upgradedMessageHoles: upgradedMessageHoles, messageThreadHoles: messageThreadHoles, existingMessageTags: MessageTags.all, messageTagsWithSummary: [.unseenPersonalMessage, .pinned], existingGlobalMessageTags: GlobalMessageTags.all, peerNamespacesRequiringMessageTextIndex: [Namespaces.Peer.SecretChat], peerSummaryCounterTags: { peer, isContact in
|
||||
return SeedConfiguration(globalMessageIdsPeerIdNamespaces: globalMessageIdsPeerIdNamespaces, initializeChatListWithHole: (topLevel: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt32Value(0)), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1)), groups: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt32Value(0)), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1))), messageHoles: messageHoles, upgradedMessageHoles: upgradedMessageHoles, messageThreadHoles: messageThreadHoles, existingMessageTags: MessageTags.all, messageTagsWithSummary: [.unseenPersonalMessage, .pinned], existingGlobalMessageTags: GlobalMessageTags.all, peerNamespacesRequiringMessageTextIndex: [Namespaces.Peer.SecretChat], peerSummaryCounterTags: { peer, isContact in
|
||||
if let peer = peer as? TelegramUser {
|
||||
if peer.botInfo != nil {
|
||||
return .bot
|
||||
|
@ -48,7 +48,7 @@ public func addSynchronizePinnedChatsOperation(transaction: Transaction, groupId
|
||||
var previousItemIds = transaction.getPinnedItemIds(groupId: groupId)
|
||||
var updateLocalIndex: Int32?
|
||||
|
||||
transaction.operationLogEnumerateEntries(peerId: PeerId(namespace: 0, id: rawId), tag: OperationLogTags.SynchronizePinnedChats, { entry in
|
||||
transaction.operationLogEnumerateEntries(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt32Value(rawId)), tag: OperationLogTags.SynchronizePinnedChats, { entry in
|
||||
updateLocalIndex = entry.tagLocalIndex
|
||||
if let contents = entry.contents as? SynchronizePinnedChatsOperation {
|
||||
previousItemIds = contents.previousItemIds
|
||||
@ -57,7 +57,7 @@ public func addSynchronizePinnedChatsOperation(transaction: Transaction, groupId
|
||||
})
|
||||
let operationContents = SynchronizePinnedChatsOperation(previousItemIds: previousItemIds)
|
||||
if let updateLocalIndex = updateLocalIndex {
|
||||
let _ = transaction.operationLogRemoveEntry(peerId: PeerId(namespace: 0, id: rawId), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: updateLocalIndex)
|
||||
let _ = transaction.operationLogRemoveEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt32Value(rawId)), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: updateLocalIndex)
|
||||
}
|
||||
transaction.operationLogAddEntry(peerId: PeerId(namespace: 0, id: rawId), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents)
|
||||
transaction.operationLogAddEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt32Value(rawId)), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents)
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ private final class CallRatingAlertContentNode: AlertContentNode {
|
||||
}
|
||||
|
||||
func rateCallAndSendLogs(account: Account, callId: CallId, starsCount: Int, comment: String, userInitiated: Bool, includeLogs: Bool) -> Signal<Void, NoError> {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 4244000)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4244000))
|
||||
|
||||
let rate = rateCall(account: account, callId: callId, starsCount: Int32(starsCount), comment: comment, userInitiated: userInitiated)
|
||||
if includeLogs {
|
||||
|
@ -206,7 +206,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
||||
|
||||
startCallImpl = { [weak self] account, uuid, handle, isVideo in
|
||||
if let strongSelf = self, let userId = Int32(handle) {
|
||||
return strongSelf.startCall(account: account, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), isVideo: isVideo, internalId: uuid)
|
||||
return strongSelf.startCall(account: account, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), isVideo: isVideo, internalId: uuid)
|
||||
|> take(1)
|
||||
|> map { result -> Bool in
|
||||
return result
|
||||
|
@ -417,7 +417,7 @@ struct AccountMutableState {
|
||||
switch user {
|
||||
case let .user(_, id, _, _, _, _, _, _, status, _, _, _, _):
|
||||
if let status = status {
|
||||
presences[PeerId(namespace: Namespaces.Peer.CloudUser, id: id)] = status
|
||||
presences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))] = status
|
||||
}
|
||||
break
|
||||
case .userEmpty:
|
||||
|
@ -717,7 +717,7 @@ public final class AccountViewTracker {
|
||||
switch replies {
|
||||
case let .messageReplies(_, repliesCountValue, _, recentRepliers, channelId, maxId, readMaxId):
|
||||
if let channelId = channelId {
|
||||
commentsChannelId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
commentsChannelId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
}
|
||||
repliesCount = repliesCountValue
|
||||
if let recentRepliers = recentRepliers {
|
||||
|
@ -18,7 +18,7 @@ public func addGroupMember(account: Account, peerId: PeerId, memberId: PeerId) -
|
||||
return account.postbox.transaction { transaction -> Signal<Void, AddGroupMemberError> in
|
||||
if let peer = transaction.getPeer(peerId), let memberPeer = transaction.getPeer(memberId), let inputUser = apiInputUser(memberPeer) {
|
||||
if let group = peer as? TelegramGroup {
|
||||
return account.network.request(Api.functions.messages.addChatUser(chatId: group.id.id, userId: inputUser, fwdLimit: 100))
|
||||
return account.network.request(Api.functions.messages.addChatUser(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, fwdLimit: 100))
|
||||
|> mapError { error -> AddGroupMemberError in
|
||||
switch error.errorDescription {
|
||||
case "USERS_TOO_MUCH":
|
||||
|
@ -34,7 +34,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
if let migratedTo = migratedTo {
|
||||
switch migratedTo {
|
||||
case let .inputChannel(channelId, accessHash):
|
||||
migrationReference = TelegramGroupToChannelMigrationReference(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), accessHash: accessHash)
|
||||
migrationReference = TelegramGroupToChannelMigrationReference(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), accessHash: accessHash)
|
||||
case .inputChannelEmpty:
|
||||
break
|
||||
case .inputChannelFromMessage:
|
||||
@ -57,11 +57,11 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
if (flags & Int32(1 << 24)) != 0 {
|
||||
groupFlags.insert(.hasActiveVoiceChat)
|
||||
}
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:)), migrationReference: migrationReference, creationDate: date, version: Int(version))
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:)), migrationReference: migrationReference, creationDate: date, version: Int(version))
|
||||
case let .chatEmpty(id):
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
case let .chatForbidden(id, title):
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), title: title, photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0)
|
||||
case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, defaultBannedRights, _):
|
||||
let isMin = (flags & (1 << 12)) != 0
|
||||
|
||||
@ -133,7 +133,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
}
|
||||
}
|
||||
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHashValue, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: date, version: version, participationStatus: participationStatus, info: info, flags: channelFlags, restrictionInfo: restrictionInfo, adminRights: adminRights.flatMap(TelegramChatAdminRights.init), bannedRights: bannedRights.flatMap(TelegramChatBannedRights.init), defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init))
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id)), accessHash: accessHashValue, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: date, version: version, participationStatus: participationStatus, info: info, flags: channelFlags, restrictionInfo: restrictionInfo, adminRights: adminRights.flatMap(TelegramChatAdminRights.init), bannedRights: bannedRights.flatMap(TelegramChatBannedRights.init), defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init))
|
||||
case let .channelForbidden(flags, id, accessHash, title, untilDate):
|
||||
let info: TelegramChannelInfo
|
||||
if (flags & Int32(1 << 8)) != 0 {
|
||||
@ -142,7 +142,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
info = .broadcast(TelegramChannelBroadcastInfo(flags: []))
|
||||
}
|
||||
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: .personal(accessHash), title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: untilDate ?? Int32.max), defaultBannedRights: nil)
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id)), accessHash: .personal(accessHash), title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: untilDate ?? Int32.max), defaultBannedRights: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,11 @@ public extension PeerReference {
|
||||
var id: PeerId {
|
||||
switch self {
|
||||
case let .user(id, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .group(id):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .channel(id, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,12 +49,12 @@ extension PeerReference {
|
||||
func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
||||
switch peer {
|
||||
case let user as TelegramUser:
|
||||
return Api.InputPeer.inputPeerUser(userId: user.id.id, accessHash: user.accessHash?.value ?? 0)
|
||||
return Api.InputPeer.inputPeerUser(userId: user.id.id._internalGetInt32Value(), accessHash: user.accessHash?.value ?? 0)
|
||||
case let group as TelegramGroup:
|
||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt32Value())
|
||||
case let channel as TelegramChannel:
|
||||
if let accessHash = channel.accessHash {
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id, accessHash: accessHash.value)
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -66,12 +66,12 @@ func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
||||
func apiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
||||
switch peer {
|
||||
case let user as TelegramUser where user.accessHash != nil:
|
||||
return Api.InputPeer.inputPeerUser(userId: user.id.id, accessHash: user.accessHash!.value)
|
||||
return Api.InputPeer.inputPeerUser(userId: user.id.id._internalGetInt32Value(), accessHash: user.accessHash!.value)
|
||||
case let group as TelegramGroup:
|
||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt32Value())
|
||||
case let channel as TelegramChannel:
|
||||
if let accessHash = channel.accessHash {
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id, accessHash: accessHash.value)
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -82,7 +82,7 @@ func apiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
||||
|
||||
func apiInputChannel(_ peer: Peer) -> Api.InputChannel? {
|
||||
if let channel = peer as? TelegramChannel, let accessHash = channel.accessHash {
|
||||
return Api.InputChannel.inputChannel(channelId: channel.id.id, accessHash: accessHash.value)
|
||||
return Api.InputChannel.inputChannel(channelId: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -90,7 +90,7 @@ func apiInputChannel(_ peer: Peer) -> Api.InputChannel? {
|
||||
|
||||
func apiInputUser(_ peer: Peer) -> Api.InputUser? {
|
||||
if let user = peer as? TelegramUser, let accessHash = user.accessHash {
|
||||
return Api.InputUser.inputUser(userId: user.id.id, accessHash: accessHash.value)
|
||||
return Api.InputUser.inputUser(userId: user.id.id._internalGetInt32Value(), accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -98,7 +98,7 @@ func apiInputUser(_ peer: Peer) -> Api.InputUser? {
|
||||
|
||||
func apiInputSecretChat(_ peer: Peer) -> Api.InputEncryptedChat? {
|
||||
if let chat = peer as? TelegramSecretChat {
|
||||
return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id, accessHash: chat.accessHash)
|
||||
return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: chat.accessHash)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
@ -9,23 +9,23 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
||||
case let .messageActionChannelCreate(title):
|
||||
return TelegramMediaAction(action: .groupCreated(title: title))
|
||||
case let .messageActionChannelMigrateFrom(title, chatId):
|
||||
return TelegramMediaAction(action: .channelMigratedFromGroup(title: title, groupId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)))
|
||||
return TelegramMediaAction(action: .channelMigratedFromGroup(title: title, groupId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))))
|
||||
case let .messageActionChatAddUser(users):
|
||||
return TelegramMediaAction(action: .addedMembers(peerIds: users.map({ PeerId(namespace: Namespaces.Peer.CloudUser, id: $0) })))
|
||||
return TelegramMediaAction(action: .addedMembers(peerIds: users.map({ PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value($0)) })))
|
||||
case let .messageActionChatCreate(title, _):
|
||||
return TelegramMediaAction(action: .groupCreated(title: title))
|
||||
case .messageActionChatDeletePhoto:
|
||||
return TelegramMediaAction(action: .photoUpdated(image: nil))
|
||||
case let .messageActionChatDeleteUser(userId):
|
||||
return TelegramMediaAction(action: .removedMembers(peerIds: [PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)]))
|
||||
return TelegramMediaAction(action: .removedMembers(peerIds: [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))]))
|
||||
case let .messageActionChatEditPhoto(photo):
|
||||
return TelegramMediaAction(action: .photoUpdated(image: telegramMediaImageFromApiPhoto(photo)))
|
||||
case let .messageActionChatEditTitle(title):
|
||||
return TelegramMediaAction(action: .titleUpdated(title: title))
|
||||
case let .messageActionChatJoinedByLink(inviterId):
|
||||
return TelegramMediaAction(action: .joinedByLink(inviter: PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId)))
|
||||
return TelegramMediaAction(action: .joinedByLink(inviter: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId))))
|
||||
case let .messageActionChatMigrateTo(channelId):
|
||||
return TelegramMediaAction(action: .groupMigratedToChannel(channelId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)))
|
||||
return TelegramMediaAction(action: .groupMigratedToChannel(channelId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))))
|
||||
case .messageActionHistoryClear:
|
||||
return TelegramMediaAction(action: .historyCleared)
|
||||
case .messageActionPinMessage:
|
||||
@ -68,7 +68,7 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
||||
switch call {
|
||||
case let .inputGroupCall(id, accessHash):
|
||||
return TelegramMediaAction(action: .inviteToGroupPhoneCall(callId: id, accessHash: accessHash, peerIds: userIds.map { userId in
|
||||
PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
}))
|
||||
}
|
||||
case let .messageActionSetMessagesTTL(period):
|
||||
|
@ -36,7 +36,7 @@ extension TelegramMediaPollResults {
|
||||
}
|
||||
|
||||
self.init(voters: results.flatMap({ $0.map(TelegramMediaPollOptionVoters.init(apiVoters:)) }), totalVoters: totalVoters, recentVoters: recentVoters.flatMap { recentVoters in
|
||||
return recentVoters.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: $0) }
|
||||
return recentVoters.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value($0)) }
|
||||
} ?? [], solution: parsedSolution)
|
||||
}
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ extension TelegramUser {
|
||||
|
||||
let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init(apiReasons:))
|
||||
|
||||
self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: accessHashValue, firstName: firstName, lastName: lastName, username: username, phone: phone, photo: representations, botInfo: botInfo, restrictionInfo: restrictionInfo, flags: userFlags)
|
||||
self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)), accessHash: accessHashValue, firstName: firstName, lastName: lastName, username: username, phone: phone, photo: representations, botInfo: botInfo, restrictionInfo: restrictionInfo, flags: userFlags)
|
||||
case let .userEmpty(id):
|
||||
self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)), accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ public enum ExportAuthTransferTokenResult {
|
||||
case passwordRequested(UnauthorizedAccount)
|
||||
}
|
||||
|
||||
public func exportAuthTransferToken(accountManager: AccountManager, account: UnauthorizedAccount, otherAccountUserIds: [Int32], syncContacts: Bool) -> Signal<ExportAuthTransferTokenResult, ExportAuthTransferTokenError> {
|
||||
return account.network.request(Api.functions.auth.exportLoginToken(apiId: account.networkArguments.apiId, apiHash: account.networkArguments.apiHash, exceptIds: otherAccountUserIds))
|
||||
public func exportAuthTransferToken(accountManager: AccountManager, account: UnauthorizedAccount, otherAccountUserIds: [PeerId.Id], syncContacts: Bool) -> Signal<ExportAuthTransferTokenResult, ExportAuthTransferTokenError> {
|
||||
return account.network.request(Api.functions.auth.exportLoginToken(apiId: account.networkArguments.apiId, apiHash: account.networkArguments.apiHash, exceptIds: otherAccountUserIds.map({ $0._internalGetInt32Value() })))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<Api.auth.LoginToken?, ExportAuthTransferTokenError> in
|
||||
if error.errorDescription == "SESSION_PASSWORD_NEEDED" {
|
||||
|
@ -188,9 +188,9 @@ public func fetchBotPaymentForm(postbox: Postbox, network: Network, messageId: M
|
||||
parsedSavedCredentials = .card(id: id, title: title)
|
||||
}
|
||||
}
|
||||
return BotPaymentForm(canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: providerId), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials)
|
||||
return BotPaymentForm(canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(providerId)), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials)
|
||||
}
|
||||
} |> mapError { _ -> BotPaymentFormRequestError in return .generic }
|
||||
} |> mapError { _ -> BotPaymentFormRequestError in }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,17 +199,17 @@ extension ChannelParticipant {
|
||||
init(apiParticipant: Api.ChannelParticipant) {
|
||||
switch apiParticipant {
|
||||
case let .channelParticipant(userId, date):
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil)
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil)
|
||||
case let .channelParticipantCreator(_, userId, adminRights, rank):
|
||||
self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), canBeEditedByAccountPeer: true), rank: rank)
|
||||
self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), canBeEditedByAccountPeer: true), rank: rank)
|
||||
case let .channelParticipantBanned(flags, userId, restrictedBy, date, bannedRights):
|
||||
let hasLeft = (flags & (1 << 0)) != 0
|
||||
let banInfo = ChannelParticipantBannedInfo(rights: TelegramChatBannedRights(apiBannedRights: bannedRights), restrictedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: restrictedBy), timestamp: date, isMember: !hasLeft)
|
||||
let banInfo = ChannelParticipantBannedInfo(rights: TelegramChatBannedRights(apiBannedRights: bannedRights), restrictedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(restrictedBy)), timestamp: date, isMember: !hasLeft)
|
||||
self = .member(id: userId.peerId, invitedAt: date, adminInfo: nil, banInfo: banInfo, rank: nil)
|
||||
case let .channelParticipantAdmin(flags, userId, _, promotedBy, date, adminRights, rank: rank):
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: promotedBy), canBeEditedByAccountPeer: (flags & (1 << 0)) != 0), banInfo: nil, rank: rank)
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedAt: date, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(promotedBy)), canBeEditedByAccountPeer: (flags & (1 << 0)) != 0), banInfo: nil, rank: rank)
|
||||
case let .channelParticipantSelf(userId, _, date):
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil)
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil)
|
||||
case let .channelParticipantLeft(userId):
|
||||
self = .member(id: userId.peerId, invitedAt: 0, adminInfo: nil, banInfo: nil, rank: nil)
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ extension GroupParticipant {
|
||||
init(apiParticipant: Api.ChatParticipant) {
|
||||
switch apiParticipant {
|
||||
case let .chatParticipantCreator(userId):
|
||||
self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId))
|
||||
self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)))
|
||||
case let .chatParticipantAdmin(userId, inviterId, date):
|
||||
self = .admin(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId), invitedAt: date)
|
||||
self = .admin(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)), invitedAt: date)
|
||||
case let .chatParticipant(userId, inviterId, date):
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId), invitedAt: date)
|
||||
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)), invitedAt: date)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ private final class CallSessionManagerContext {
|
||||
versions = libraryVersions
|
||||
}
|
||||
if self.contextIdByStableId[id] == nil {
|
||||
let internalId = self.addIncoming(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: adminId), stableId: id, accessHash: accessHash, timestamp: date, gAHash: gAHash.makeData(), versions: versions, isVideo: isVideo)
|
||||
let internalId = self.addIncoming(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId)), stableId: id, accessHash: accessHash, timestamp: date, gAHash: gAHash.makeData(), versions: versions, isVideo: isVideo)
|
||||
if let internalId = internalId {
|
||||
var resultRingingStateValue: CallSessionRingingState?
|
||||
for ringingState in self.ringingStatesValue() {
|
||||
|
@ -220,7 +220,7 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
|
||||
action = .pollStopped(rendered)
|
||||
}
|
||||
case let .channelAdminLogEventActionChangeLinkedChat(prevValue, newValue):
|
||||
action = .linkedPeerUpdated(previous: prevValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: prevValue)], updated: newValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: newValue)])
|
||||
action = .linkedPeerUpdated(previous: prevValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(prevValue))], updated: newValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(newValue))])
|
||||
case let .channelAdminLogEventActionChangeLocation(prevValue, newValue):
|
||||
action = .changeGeoLocation(previous: PeerGeoLocation(apiLocation: prevValue), updated: PeerGeoLocation(apiLocation: newValue))
|
||||
case let .channelAdminLogEventActionToggleSlowMode(prevValue, newValue):
|
||||
@ -251,7 +251,7 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
|
||||
case let .channelAdminLogEventActionChangeHistoryTTL(prevValue, newValue):
|
||||
action = .changeHistoryTTL(previousValue: prevValue, updatedValue: newValue)
|
||||
}
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
if let action = action {
|
||||
events.append(AdminLogEvent(id: id, peerId: peerId, date: date, action: action))
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ public func channelAdminIds(postbox: Postbox, network: Network, peerId: PeerId,
|
||||
return participants.contains(where: { participant in
|
||||
switch participant {
|
||||
case let .channelParticipantAdmin(_, userId, _, _, _, _, _):
|
||||
return user.peerId.id == userId
|
||||
return user.peerId.id._internalGetInt32Value() == userId
|
||||
case let .channelParticipantCreator(_, userId, _, _):
|
||||
return user.peerId.id == userId
|
||||
return user.peerId.id._internalGetInt32Value() == userId
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
@ -298,22 +298,22 @@ extension ChatListFilter {
|
||||
includePeers: ChatListFilterIncludePeers(rawPeers: includePeers.compactMap { peer -> PeerId? in
|
||||
switch peer {
|
||||
case let .inputPeerUser(userId, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .inputPeerChat(chatId):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .inputPeerChannel(channelId, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}, rawPinnedPeers: pinnedPeers.compactMap { peer -> PeerId? in
|
||||
switch peer {
|
||||
case let .inputPeerUser(userId, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .inputPeerChat(chatId):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .inputPeerChannel(channelId, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@ -321,11 +321,11 @@ extension ChatListFilter {
|
||||
excludePeers: excludePeers.compactMap { peer -> PeerId? in
|
||||
switch peer {
|
||||
case let .inputPeerUser(userId, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .inputPeerChat(chatId):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .inputPeerChannel(channelId, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@ -426,11 +426,11 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
|
||||
var peerId: PeerId?
|
||||
switch peer {
|
||||
case let .inputPeerUser(userId, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .inputPeerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .inputPeerChannel(channelId, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -446,11 +446,11 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
|
||||
var peerId: PeerId?
|
||||
switch peer {
|
||||
case let .inputPeerUser(userId, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .inputPeerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .inputPeerChannel(channelId, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ private func withTakenOperation(postbox: Postbox, peerId: PeerId, tag: PeerOpera
|
||||
|
||||
func requestChatListFiltersSync(transaction: Transaction) {
|
||||
let tag: PeerOperationLogTag = OperationLogTags.SynchronizeChatListFilters
|
||||
let peerId = PeerId(namespace: 0, id: 0)
|
||||
let peerId = PeerId(0)
|
||||
|
||||
var topOperation: (SynchronizeChatListFiltersOperation, Int32)?
|
||||
transaction.operationLogEnumerateEntries(peerId: peerId, tag: tag, { entry in
|
||||
|
@ -56,7 +56,7 @@ func syncContactsOnce(network: Network, postbox: Postbox, accountPeerId: PeerId)
|
||||
let contactPeerIds = transaction.getContactPeerIds()
|
||||
let totalCount = transaction.getRemoteContactCount()
|
||||
let peerIds = Set(contactPeerIds.filter({ $0.namespace == Namespaces.Peer.CloudUser }))
|
||||
return hashForCountAndIds(count: totalCount, ids: peerIds.map({ $0.id }).sorted())
|
||||
return hashForCountAndIds(count: totalCount, ids: peerIds.map({ $0.id._internalGetInt32Value() }).sorted())
|
||||
}
|
||||
|
||||
let updatedPeers = initialContactPeerIdsHash
|
||||
|
@ -345,7 +345,7 @@ private func pushDeviceContactData(postbox: Postbox, network: Network, contacts:
|
||||
for item in imported {
|
||||
switch item {
|
||||
case let .importedContact(userId, _):
|
||||
addedContactPeerIds.insert(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId))
|
||||
addedContactPeerIds.insert(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)))
|
||||
}
|
||||
}
|
||||
for item in retryContacts {
|
||||
@ -399,7 +399,7 @@ private func updateContactPresences(postbox: Postbox, network: Network, accountP
|
||||
for status in statuses {
|
||||
switch status {
|
||||
case let .contactStatus(userId, status):
|
||||
peerPresences[PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)] = TelegramUserPresence(apiStatus: status)
|
||||
peerPresences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))] = TelegramUserPresence(apiStatus: status)
|
||||
}
|
||||
}
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
@ -10,7 +10,7 @@ public enum ConvertGroupToSupergroupError {
|
||||
}
|
||||
|
||||
public func convertGroupToSupergroup(account: Account, peerId: PeerId) -> Signal<PeerId, ConvertGroupToSupergroupError> {
|
||||
return account.network.request(Api.functions.messages.migrateChat(chatId: peerId.id))
|
||||
return account.network.request(Api.functions.messages.migrateChat(chatId: peerId.id._internalGetInt32Value()))
|
||||
|> mapError { error -> ConvertGroupToSupergroupError in
|
||||
if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
||||
return .tooManyChannels
|
||||
|
@ -8,7 +8,7 @@ extension ExportedInvitation {
|
||||
init(apiExportedInvite: Api.ExportedChatInvite) {
|
||||
switch apiExportedInvite {
|
||||
case let .chatInviteExported(flags, link, adminId, date, startDate, expireDate, usageLimit, usage):
|
||||
self = ExportedInvitation(link: link, isPermanent: (flags & (1 << 5)) != 0, isRevoked: (flags & (1 << 0)) != 0, adminId: PeerId(namespace: Namespaces.Peer.CloudUser, id: adminId), date: date, startDate: startDate, expireDate: expireDate, usageLimit: usageLimit, count: usage)
|
||||
self = ExportedInvitation(link: link, isPermanent: (flags & (1 << 5)) != 0, isRevoked: (flags & (1 << 0)) != 0, adminId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId)), date: date, startDate: startDate, expireDate: expireDate, usageLimit: usageLimit, count: usage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +113,11 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message],
|
||||
let peerId: PeerId
|
||||
switch apiPeer {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
}
|
||||
|
||||
if readStates[peerId] == nil {
|
||||
|
@ -333,7 +333,7 @@ public func grantSecureIdAccess(network: Network, peerId: PeerId, publicKey: Str
|
||||
valueHashes.append(.secureValueHash(type: apiSecureValueType(value: value.value), hash: Buffer(data: value.opaqueHash)))
|
||||
}
|
||||
|
||||
return network.request(Api.functions.account.acceptAuthorization(botId: peerId.id, scope: scope, publicKey: publicKey, valueHashes: valueHashes, credentials: .secureCredentialsEncrypted(data: Buffer(data: encryptedCredentialsData), hash: Buffer(data: decryptedCredentialsHash), secret: Buffer(data: encryptedSecretData))))
|
||||
return network.request(Api.functions.account.acceptAuthorization(botId: peerId.id._internalGetInt32Value(), scope: scope, publicKey: publicKey, valueHashes: valueHashes, credentials: .secureCredentialsEncrypted(data: Buffer(data: encryptedCredentialsData), hash: Buffer(data: decryptedCredentialsHash), secret: Buffer(data: encryptedSecretData))))
|
||||
|> mapError { error -> GrantSecureIdAccessError in
|
||||
return .generic
|
||||
}
|
||||
|
@ -111,15 +111,7 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
|
||||
loop: for participant in participants {
|
||||
switch participant {
|
||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, params):
|
||||
let peerId: PeerId
|
||||
switch apiPeerId {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = apiPeerId.peerId
|
||||
|
||||
let ssrc = UInt32(bitPattern: source)
|
||||
guard let peer = transaction.getPeer(peerId) else {
|
||||
@ -298,15 +290,7 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
|
||||
loop: for participant in participants {
|
||||
switch participant {
|
||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, params):
|
||||
let peerId: PeerId
|
||||
switch apiPeerId {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = apiPeerId.peerId
|
||||
let ssrc = UInt32(bitPattern: source)
|
||||
guard let peer = transaction.getPeer(peerId) else {
|
||||
continue loop
|
||||
@ -526,15 +510,7 @@ public func joinGroupCall(account: Account, peerId: PeerId, joinAs: PeerId?, cal
|
||||
loop: for participant in participants {
|
||||
switch participant {
|
||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, params):
|
||||
let peerId: PeerId
|
||||
switch apiPeerId {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = apiPeerId.peerId
|
||||
let ssrc = UInt32(bitPattern: source)
|
||||
guard let peer = transaction.getPeer(peerId) else {
|
||||
continue loop
|
||||
@ -1732,15 +1708,7 @@ extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate {
|
||||
init(_ apiParticipant: Api.GroupCallParticipant) {
|
||||
switch apiParticipant {
|
||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, params):
|
||||
let peerId: PeerId
|
||||
switch apiPeerId {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = apiPeerId.peerId
|
||||
let ssrc = UInt32(bitPattern: source)
|
||||
let muted = (flags & (1 << 0)) != 0
|
||||
let mutedByYou = (flags & (1 << 9)) != 0
|
||||
@ -1795,15 +1763,7 @@ extension GroupCallParticipantsContext.Update.StateUpdate {
|
||||
for participant in participants {
|
||||
switch participant {
|
||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, params):
|
||||
let peerId: PeerId
|
||||
switch apiPeerId {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = apiPeerId.peerId
|
||||
let ssrc = UInt32(bitPattern: source)
|
||||
let muted = (flags & (1 << 0)) != 0
|
||||
let mutedByYou = (flags & (1 << 9)) != 0
|
||||
|
@ -9,7 +9,7 @@ public func returnGroup(account: Account, peerId: PeerId) -> Signal<Void, NoErro
|
||||
|> take(1)
|
||||
|> mapToSignal { peer -> Signal<Void, NoError> in
|
||||
if let inputUser = apiInputUser(peer) {
|
||||
return account.network.request(Api.functions.messages.addChatUser(chatId: peerId.id, userId: inputUser, fwdLimit: 50))
|
||||
return account.network.request(Api.functions.messages.addChatUser(chatId: peerId.id._internalGetInt32Value(), userId: inputUser, fwdLimit: 50))
|
||||
|> retryRequest
|
||||
|> mapToSignal { updates -> Signal<Void, NoError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
@ -26,7 +26,7 @@ public func leftGroup(account: Account, peerId: PeerId) -> Signal<Void, NoError>
|
||||
|> take(1)
|
||||
|> mapToSignal { peer -> Signal<Void, NoError> in
|
||||
if let inputUser = apiInputUser(peer) {
|
||||
return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peerId.id, userId: inputUser))
|
||||
return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peerId.id._internalGetInt32Value(), userId: inputUser))
|
||||
|> retryRequest
|
||||
|> mapToSignal { updates -> Signal<Void, NoError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
|
@ -58,7 +58,7 @@ private final class GroupsInCommonContextImpl {
|
||||
guard let inputUser = inputUser else {
|
||||
return .single(([], 0))
|
||||
}
|
||||
return network.request(Api.functions.messages.getCommonChats(userId: inputUser, maxId: maxId ?? 0, limit: limit))
|
||||
return network.request(Api.functions.messages.getCommonChats(userId: inputUser, maxId: maxId?._internalGetInt32Value() ?? 0, limit: limit))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.Chats?, NoError> in
|
||||
return .single(nil)
|
||||
|
@ -410,7 +410,7 @@ private func hashForMessages(_ messages: [Message], withChannelIds: Bool) -> Int
|
||||
|
||||
for message in sorted {
|
||||
if withChannelIds {
|
||||
acc = (acc &* 20261) &+ UInt32(message.id.peerId.id)
|
||||
acc = (acc &* 20261) &+ UInt32(message.id.peerId.id._internalGetInt32Value())
|
||||
}
|
||||
|
||||
acc = (acc &* 20261) &+ UInt32(message.id.id)
|
||||
@ -435,7 +435,7 @@ private func hashForMessages(_ messages: [StoreMessage], withChannelIds: Bool) -
|
||||
for message in messages {
|
||||
if case let .Id(id) = message.id {
|
||||
if withChannelIds {
|
||||
acc = (acc &* 20261) &+ UInt32(id.peerId.id)
|
||||
acc = (acc &* 20261) &+ UInt32(id.peerId.id._internalGetInt32Value())
|
||||
}
|
||||
acc = (acc &* 20261) &+ UInt32(id.id)
|
||||
var timestamp = message.timestamp
|
||||
|
@ -573,13 +573,13 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
|
||||
func groupBoundaryPeer(_ peerId: PeerId, accountPeerId: PeerId) -> Api.Peer {
|
||||
switch peerId.namespace {
|
||||
case Namespaces.Peer.CloudUser:
|
||||
return Api.Peer.peerUser(userId: peerId.id)
|
||||
return Api.Peer.peerUser(userId: peerId.id._internalGetInt32Value())
|
||||
case Namespaces.Peer.CloudGroup:
|
||||
return Api.Peer.peerChat(chatId: peerId.id)
|
||||
return Api.Peer.peerChat(chatId: peerId.id._internalGetInt32Value())
|
||||
case Namespaces.Peer.CloudChannel:
|
||||
return Api.Peer.peerChannel(channelId: peerId.id)
|
||||
return Api.Peer.peerChannel(channelId: peerId.id._internalGetInt32Value())
|
||||
default:
|
||||
return Api.Peer.peerUser(userId: accountPeerId.id)
|
||||
return Api.Peer.peerUser(userId: accountPeerId.id._internalGetInt32Value())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ final class CachedPeerInvitationImporters: PostboxCoding {
|
||||
for index in stride(from: 0, to: datesArray.endIndex, by: 2) {
|
||||
let userId = datesArray[index]
|
||||
let date = datesArray[index + 1]
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
dates[peerId] = date
|
||||
}
|
||||
self.dates = dates
|
||||
@ -671,7 +671,7 @@ final class CachedPeerInvitationImporters: PostboxCoding {
|
||||
|
||||
var dates: [Int32] = []
|
||||
for (peerId, date) in self.dates {
|
||||
dates.append(peerId.id)
|
||||
dates.append(peerId.id._internalGetInt32Value())
|
||||
dates.append(date)
|
||||
}
|
||||
encoder.encodeInt32Array(dates, forKey: "dates")
|
||||
@ -791,7 +791,7 @@ private final class PeerInvitationImportersContextImpl {
|
||||
let date: Int32
|
||||
switch importer {
|
||||
case let .chatInviteImporter(userId, dateValue):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
date = dateValue
|
||||
}
|
||||
if let peer = transaction.getPeer(peerId) {
|
||||
@ -911,7 +911,7 @@ public func peerExportedInvitationsCreators(account: Account, peerId: PeerId) ->
|
||||
for admin in admins {
|
||||
switch admin {
|
||||
case let .chatAdminWithInvites(adminId, invitesCount, revokedInvitesCount):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: adminId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId))
|
||||
if let peer = peersMap[peerId], peerId != account.peerId {
|
||||
creators.append(ExportedInvitationCreator(peer: RenderedPeer(peer: peer), count: invitesCount, revokedCount: revokedInvitesCount))
|
||||
}
|
||||
|
@ -184,10 +184,12 @@ func locallyRenderedMessage(message: StoreMessage, peers: [PeerId: Peer]) -> Mes
|
||||
messagePeers[source.id] = source
|
||||
}
|
||||
}
|
||||
|
||||
var hash: Int32 = id.id
|
||||
hash = hash &* 31 &+ id.peerId.id
|
||||
let stableId = UInt32(clamping: hash)
|
||||
|
||||
var hasher = Hasher()
|
||||
hasher.combine(id.id)
|
||||
hasher.combine(id.peerId)
|
||||
|
||||
let stableId = UInt32(clamping: hasher.finalize())
|
||||
|
||||
return Message(stableId: stableId, stableVersion: 0, id: id, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: message.threadId, timestamp: message.timestamp, flags: MessageFlags(message.flags), tags: message.tags, globalTags: message.globalTags, localTags: message.localTags, forwardInfo: forwardInfo, author: author, text: message.text, attributes: message.attributes, media: message.media, peers: messagePeers, associatedMessages: SimpleDictionary(), associatedMessageIds: [])
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ public func notificationExceptionsList(postbox: Postbox, network: Network) -> Si
|
||||
let peerId: PeerId
|
||||
switch notifyPeer {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
}
|
||||
settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings)
|
||||
default:
|
||||
|
@ -14,7 +14,7 @@ public func removeGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId)
|
||||
return account.postbox.transaction { transaction -> Signal<Void, RemoveGroupAdminError> in
|
||||
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) {
|
||||
if let group = peer as? TelegramGroup {
|
||||
return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id, userId: inputUser, isAdmin: .boolFalse))
|
||||
return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, isAdmin: .boolFalse))
|
||||
|> mapError { _ -> RemoveGroupAdminError in return .generic }
|
||||
|> mapToSignal { result -> Signal<Void, RemoveGroupAdminError> in
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
@ -62,7 +62,7 @@ public func addGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) ->
|
||||
return account.postbox.transaction { transaction -> Signal<Void, AddGroupAdminError> in
|
||||
if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) {
|
||||
if let group = peer as? TelegramGroup {
|
||||
return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id, userId: inputUser, isAdmin: .boolTrue))
|
||||
return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, isAdmin: .boolTrue))
|
||||
|> `catch` { error -> Signal<Api.Bool, AddGroupAdminError> in
|
||||
if error.errorDescription == "USER_NOT_PARTICIPANT" {
|
||||
return addGroupMember(account: account, peerId: peerId, memberId: adminId)
|
||||
@ -73,7 +73,7 @@ public func addGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) ->
|
||||
return .complete()
|
||||
}
|
||||
|> then(
|
||||
account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id, userId: inputUser, isAdmin: .boolTrue))
|
||||
account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, isAdmin: .boolTrue))
|
||||
|> mapError { error -> AddGroupAdminError in
|
||||
return .generic
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public func updatePeerPhotoInternal(postbox: Postbox, network: Network, stateMan
|
||||
|
||||
let request: Signal<Api.Updates, MTRpcError>
|
||||
if let peer = peer as? TelegramGroup {
|
||||
request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id, photo: .inputChatUploadedPhoto(flags: flags, file: file, video: videoFile, videoStartTs: videoStartTimestamp)))
|
||||
request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id._internalGetInt32Value(), photo: .inputChatUploadedPhoto(flags: flags, file: file, video: videoFile, videoStartTs: videoStartTimestamp)))
|
||||
} else if let peer = peer as? TelegramChannel, let inputChannel = apiInputChannel(peer) {
|
||||
request = network.request(Api.functions.channels.editPhoto(channel: inputChannel, photo: .inputChatUploadedPhoto(flags: flags, file: file, video: videoFile, videoStartTs: videoStartTimestamp)))
|
||||
} else {
|
||||
@ -311,7 +311,7 @@ public func updatePeerPhotoInternal(postbox: Postbox, network: Network, stateMan
|
||||
} else {
|
||||
let request: Signal<Api.Updates, MTRpcError>
|
||||
if let peer = peer as? TelegramGroup {
|
||||
request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id, photo: .inputChatPhotoEmpty))
|
||||
request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id._internalGetInt32Value(), photo: .inputChatPhotoEmpty))
|
||||
} else if let peer = peer as? TelegramChannel, let inputChannel = apiInputChannel(peer) {
|
||||
request = network.request(Api.functions.channels.editPhoto(channel: inputChannel, photo: .inputChatPhotoEmpty))
|
||||
} else {
|
||||
|
@ -1065,7 +1065,7 @@ extension GroupStatsTopPoster {
|
||||
init(apiStatsGroupTopPoster: Api.StatsGroupTopPoster) {
|
||||
switch apiStatsGroupTopPoster {
|
||||
case let .statsGroupTopPoster(userId, messages, avgChars):
|
||||
self = GroupStatsTopPoster(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), messageCount: messages, averageChars: avgChars)
|
||||
self = GroupStatsTopPoster(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), messageCount: messages, averageChars: avgChars)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1074,7 +1074,7 @@ extension GroupStatsTopAdmin {
|
||||
init(apiStatsGroupTopAdmin: Api.StatsGroupTopAdmin) {
|
||||
switch apiStatsGroupTopAdmin {
|
||||
case let .statsGroupTopAdmin(userId, deleted, kicked, banned):
|
||||
self = GroupStatsTopAdmin(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), deletedCount: deleted, kickedCount: kicked, bannedCount: banned)
|
||||
self = GroupStatsTopAdmin(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), deletedCount: deleted, kickedCount: kicked, bannedCount: banned)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1083,7 +1083,7 @@ extension GroupStatsTopInviter {
|
||||
init(apiStatsGroupTopInviter: Api.StatsGroupTopInviter) {
|
||||
switch apiStatsGroupTopInviter {
|
||||
case let .statsGroupTopInviter(userId, invitations):
|
||||
self = GroupStatsTopInviter(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), inviteCount: invitations)
|
||||
self = GroupStatsTopInviter(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), inviteCount: invitations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public func isServicePeer(_ peer: Peer) -> Bool {
|
||||
if peer.id.isReplies {
|
||||
return true
|
||||
}
|
||||
return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id == 777000 || peer.id.id == 333000))
|
||||
return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt32Value() == 777000 || peer.id.id._internalGetInt32Value() == 333000))
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -249,7 +249,7 @@ public func isServicePeer(_ peer: Peer) -> Bool {
|
||||
public extension PeerId {
|
||||
var isReplies: Bool {
|
||||
if self.namespace == Namespaces.Peer.CloudUser {
|
||||
if self.id == 708513 || self.id == 1271266957 {
|
||||
if self.id._internalGetInt32Value() == 708513 || self.id._internalGetInt32Value() == 1271266957 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -268,7 +268,7 @@ public extension PeerId {
|
||||
|
||||
var isImport: Bool {
|
||||
if self.namespace == Namespaces.Peer.CloudUser {
|
||||
if self.id == 225079 {
|
||||
if self.id._internalGetInt32Value() == 225079 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -286,11 +286,11 @@ private final class PollResultsOptionContext {
|
||||
let peerId: PeerId
|
||||
switch vote {
|
||||
case let .messageUserVote(userId, _, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .messageUserVoteInputOption(userId, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
case let .messageUserVoteMultiple(userId, _, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
}
|
||||
if let peer = transaction.getPeer(peerId) {
|
||||
resultPeers.append(RenderedPeer(peer: peer))
|
||||
|
@ -162,7 +162,7 @@ extension SelectivePrivacySettings {
|
||||
current = .enableContacts(enableFor: [:], disableFor: [:])
|
||||
case let .privacyValueAllowUsers(users):
|
||||
for id in users {
|
||||
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: id)] {
|
||||
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))] {
|
||||
enableFor[peer.peer.id] = peer
|
||||
}
|
||||
}
|
||||
@ -172,13 +172,13 @@ extension SelectivePrivacySettings {
|
||||
break
|
||||
case let .privacyValueDisallowUsers(users):
|
||||
for id in users {
|
||||
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: id)] {
|
||||
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))] {
|
||||
disableFor[peer.peer.id] = peer
|
||||
}
|
||||
}
|
||||
case let .privacyValueAllowChatParticipants(chats):
|
||||
for id in chats {
|
||||
for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), PeerId(namespace: Namespaces.Peer.CloudChannel, id: id)] {
|
||||
for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id))] {
|
||||
if let peer = peers[possibleId] {
|
||||
enableFor[peer.peer.id] = peer
|
||||
}
|
||||
@ -186,7 +186,7 @@ extension SelectivePrivacySettings {
|
||||
}
|
||||
case let .privacyValueDisallowChatParticipants(chats):
|
||||
for id in chats {
|
||||
for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), PeerId(namespace: Namespaces.Peer.CloudChannel, id: id)] {
|
||||
for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id))] {
|
||||
if let peer = peers[possibleId] {
|
||||
disableFor[peer.peer.id] = peer
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32
|
||||
case let .decryptedMessageMediaGeoPoint(lat, long):
|
||||
parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))
|
||||
case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId):
|
||||
parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil))
|
||||
parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), vCardData: nil))
|
||||
case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId):
|
||||
parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))
|
||||
case .decryptedMessageMediaEmpty:
|
||||
@ -1015,7 +1015,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32
|
||||
case let .decryptedMessageMediaGeoPoint(lat, long):
|
||||
parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))
|
||||
case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId):
|
||||
parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil))
|
||||
parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), vCardData: nil))
|
||||
case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId):
|
||||
parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))
|
||||
case .decryptedMessageMediaEmpty:
|
||||
@ -1253,7 +1253,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32
|
||||
case let .decryptedMessageMediaGeoPoint(lat, long):
|
||||
parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))
|
||||
case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId):
|
||||
parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil))
|
||||
parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), vCardData: nil))
|
||||
case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId):
|
||||
parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil))
|
||||
case .decryptedMessageMediaEmpty:
|
||||
|
@ -32,7 +32,7 @@ public func webSessions(network: Network) -> Signal<([WebAuthorization], [PeerId
|
||||
for authorization in authorizations {
|
||||
switch authorization {
|
||||
case let .webAuthorization(hash, botId, domain, browser, platform, dateCreated, dateActive, ip, region):
|
||||
sessions.append(WebAuthorization(hash: hash, botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: botId), domain: domain, browser: browser, platform: platform, dateCreated: dateCreated, dateActive: dateActive, ip: ip, region: region))
|
||||
sessions.append(WebAuthorization(hash: hash, botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)), domain: domain, browser: browser, platform: platform, dateCreated: dateCreated, dateActive: dateActive, ip: ip, region: region))
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public enum NotificationTokenType {
|
||||
case voip
|
||||
}
|
||||
|
||||
public func unregisterNotificationToken(account: Account, token: Data, type: NotificationTokenType, otherAccountUserIds: [Int32]) -> Signal<Never, NoError> {
|
||||
public func unregisterNotificationToken(account: Account, token: Data, type: NotificationTokenType, otherAccountUserIds: [PeerId.Id]) -> Signal<Never, NoError> {
|
||||
let mappedType: Int32
|
||||
switch type {
|
||||
case .aps:
|
||||
@ -18,12 +18,12 @@ public func unregisterNotificationToken(account: Account, token: Data, type: Not
|
||||
case .voip:
|
||||
mappedType = 9
|
||||
}
|
||||
return account.network.request(Api.functions.account.unregisterDevice(tokenType: mappedType, token: hexString(token), otherUids: otherAccountUserIds))
|
||||
return account.network.request(Api.functions.account.unregisterDevice(tokenType: mappedType, token: hexString(token), otherUids: otherAccountUserIds.map({ $0._internalGetInt32Value() })))
|
||||
|> retryRequest
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public func registerNotificationToken(account: Account, token: Data, type: NotificationTokenType, sandbox: Bool, otherAccountUserIds: [Int32], excludeMutedChats: Bool) -> Signal<Never, NoError> {
|
||||
public func registerNotificationToken(account: Account, token: Data, type: NotificationTokenType, sandbox: Bool, otherAccountUserIds: [PeerId.Id], excludeMutedChats: Bool) -> Signal<Never, NoError> {
|
||||
return masterNotificationsKey(account: account, ignoreDisabled: false)
|
||||
|> mapToSignal { masterKey -> Signal<Never, NoError> in
|
||||
let mappedType: Int32
|
||||
@ -42,7 +42,7 @@ public func registerNotificationToken(account: Account, token: Data, type: Notif
|
||||
if excludeMutedChats {
|
||||
flags |= 1 << 0
|
||||
}
|
||||
return account.network.request(Api.functions.account.registerDevice(flags: flags, tokenType: mappedType, token: hexString(token), appSandbox: sandbox ? .boolTrue : .boolFalse, secret: Buffer(data: keyData), otherUids: otherAccountUserIds))
|
||||
return account.network.request(Api.functions.account.registerDevice(flags: flags, tokenType: mappedType, token: hexString(token), appSandbox: sandbox ? .boolTrue : .boolFalse, secret: Buffer(data: keyData), otherUids: otherAccountUserIds.map({ $0._internalGetInt32Value() })))
|
||||
|> retryRequest
|
||||
|> ignoreValues
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public func removePeerMember(account: Account, peerId: PeerId, memberId: PeerId)
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
if let peer = transaction.getPeer(peerId), let memberPeer = transaction.getPeer(memberId), let inputUser = apiInputUser(memberPeer) {
|
||||
if let group = peer as? TelegramGroup {
|
||||
return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: group.id.id, userId: inputUser))
|
||||
return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: group.id.id._internalGetInt32Value(), userId: inputUser))
|
||||
|> mapError { error -> Void in
|
||||
return Void()
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public func reportPeer(account: Account, peerId: PeerId) -> Signal<Void, NoError
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
if let peer = transaction.getPeer(peerId) {
|
||||
if let peer = peer as? TelegramSecretChat {
|
||||
return account.network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id, accessHash: peer.accessHash)))
|
||||
return account.network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash)))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Bool?, NoError> in
|
||||
return .single(nil)
|
||||
|
@ -251,7 +251,7 @@ public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: Peer
|
||||
if publicKey.isEmpty {
|
||||
return .fail(.serverError("PUBLIC_KEY_REQUIRED"))
|
||||
}
|
||||
return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id, scope: scope, publicKey: publicKey))
|
||||
return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id._internalGetInt32Value(), scope: scope, publicKey: publicKey))
|
||||
|> mapError { error -> RequestSecureIdFormError in
|
||||
switch error.errorDescription {
|
||||
case "APP_VERSION_OUTDATED":
|
||||
|
@ -61,15 +61,7 @@ public func searchPeers(account: Account, query: String) -> Signal<([FoundPeer],
|
||||
|
||||
var renderedMyPeers: [FoundPeer] = []
|
||||
for result in myResults {
|
||||
let peerId: PeerId
|
||||
switch result {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = result.peerId
|
||||
if let peer = peers[peerId] {
|
||||
if let group = peer as? TelegramGroup, group.migrationReference != nil {
|
||||
continue
|
||||
@ -80,15 +72,7 @@ public func searchPeers(account: Account, query: String) -> Signal<([FoundPeer],
|
||||
|
||||
var renderedPeers: [FoundPeer] = []
|
||||
for result in results {
|
||||
let peerId: PeerId
|
||||
switch result {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = result.peerId
|
||||
if let peer = peers[peerId] {
|
||||
if let group = peer as? TelegramGroup, group.migrationReference != nil {
|
||||
continue
|
||||
|
@ -17,9 +17,9 @@ extension SecretChatIncomingEncryptedOperation {
|
||||
convenience init(message: Api.EncryptedMessage) {
|
||||
switch message {
|
||||
case let .encryptedMessage(randomId, chatId, date, bytes, file):
|
||||
self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: chatId), globallyUniqueId: randomId, timestamp: date, type: .message, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: SecretChatFileReference(file))
|
||||
self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), globallyUniqueId: randomId, timestamp: date, type: .message, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: SecretChatFileReference(file))
|
||||
case let .encryptedMessageService(randomId, chatId, date, bytes):
|
||||
self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: chatId), globallyUniqueId: randomId, timestamp: date, type: .service, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: nil)
|
||||
self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), globallyUniqueId: randomId, timestamp: date, type: .service, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
||||
assert((currentPeer == nil) == (currentState == nil))
|
||||
switch chat {
|
||||
case let .encryptedChat(_, _, _, adminId, _, gAOrB, remoteKeyFingerprint):
|
||||
if let currentPeer = currentPeer, let currentState = currentState, adminId == accountPeerId.id {
|
||||
if let currentPeer = currentPeer, let currentState = currentState, adminId == accountPeerId.id._internalGetInt32Value() {
|
||||
if case let .handshake(handshakeState) = currentState.embeddedState, case let .requested(_, p, a) = handshakeState {
|
||||
let pData = p.makeData()
|
||||
let aData = a.makeData()
|
||||
@ -88,7 +88,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
||||
case .encryptedChatEmpty(_):
|
||||
break
|
||||
case let .encryptedChatRequested(_, folderId, _, accessHash, date, adminId, participantId, gA):
|
||||
if currentPeer == nil && participantId == accountPeerId.id {
|
||||
if currentPeer == nil && participantId == accountPeerId.id._internalGetInt32Value() {
|
||||
if settings.acceptOnThisDevice {
|
||||
let state = SecretChatState(role: .participant, embeddedState: .handshake(.accepting), keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil)
|
||||
|
||||
@ -99,7 +99,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
||||
let updatedState = addSecretChatOutgoingOperation(transaction: transaction, peerId: chat.peerId, operation: .initialHandshakeAccept(gA: MemoryBuffer(gA), accessHash: accessHash, b: b), state: state)
|
||||
transaction.setPeerChatState(chat.peerId, state: updatedState)
|
||||
|
||||
let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: adminId), accessHash: accessHash, role: updatedState.role, embeddedState: updatedState.embeddedState.peerState, messageAutoremoveTimeout: nil)
|
||||
let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId)), accessHash: accessHash, role: updatedState.role, embeddedState: updatedState.embeddedState.peerState, messageAutoremoveTimeout: nil)
|
||||
updatePeers(transaction: transaction, peers: [peer], update: { _, updated in return updated })
|
||||
if folderId != nil {
|
||||
transaction.updatePeerChatListInclusion(peer.id, inclusion: .ifHasMessagesOrOneOf(groupId: Namespaces.PeerGroup.archive, pinningIndex: nil, minTimestamp: date))
|
||||
@ -122,9 +122,9 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
||||
Logger.shared.log("State", "got encryptedChatRequested, but peer already exists or this account is creator")
|
||||
}
|
||||
case let .encryptedChatWaiting(_, accessHash, date, adminId, participantId):
|
||||
if let requestData = requestData, currentPeer == nil && adminId == accountPeerId.id {
|
||||
if let requestData = requestData, currentPeer == nil && adminId == accountPeerId.id._internalGetInt32Value() {
|
||||
let state = SecretChatState(role: .creator, embeddedState: .handshake(.requested(g: requestData.g, p: requestData.p, a: requestData.a)), keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil)
|
||||
let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: participantId), accessHash: accessHash, role: state.role, embeddedState: state.embeddedState.peerState, messageAutoremoveTimeout: nil)
|
||||
let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(participantId)), accessHash: accessHash, role: state.role, embeddedState: state.embeddedState.peerState, messageAutoremoveTimeout: nil)
|
||||
updatePeers(transaction: transaction, peers: [peer], update: { _, updated in return updated })
|
||||
transaction.setPeerChatState(peer.id, state: state)
|
||||
transaction.resetIncomingReadStates([peer.id: [
|
||||
|
@ -87,7 +87,7 @@ public func standaloneUploadedImage(account: Account, peerId: PeerId, text: Stri
|
||||
case let .inputSecretFile(file, _, key):
|
||||
return account.postbox.transaction { transaction -> Api.InputEncryptedChat? in
|
||||
if let peer = transaction.getPeer(peerId) as? TelegramSecretChat {
|
||||
return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id, accessHash: peer.accessHash)
|
||||
return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -181,7 +181,7 @@ public func standaloneUploadedFile(account: Account, peerId: PeerId, text: Strin
|
||||
case let .inputSecretFile(file, _, key):
|
||||
return account.postbox.transaction { transaction -> Api.InputEncryptedChat? in
|
||||
if let peer = transaction.getPeer(peerId) as? TelegramSecretChat {
|
||||
return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id, accessHash: peer.accessHash)
|
||||
return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ private func peerIdsFromUpdateGroups(_ groups: [UpdateGroup]) -> Set<PeerId> {
|
||||
}
|
||||
switch group {
|
||||
case let .updateChannelPts(channelId, _, _):
|
||||
peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId))
|
||||
peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)))
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -77,7 +77,7 @@ private func peerIdsRequiringLocalChatStateFromUpdates(_ updates: [Api.Update])
|
||||
}
|
||||
switch update {
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
case let .updateFolderPeers(folderPeers, _, _):
|
||||
for peer in folderPeers {
|
||||
@ -87,7 +87,7 @@ private func peerIdsRequiringLocalChatStateFromUpdates(_ updates: [Api.Update])
|
||||
}
|
||||
}
|
||||
case let .updateReadChannelInbox(_, _, channelId, _, _, _):
|
||||
peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId))
|
||||
peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)))
|
||||
case let .updateReadHistoryInbox(_, _, peer, _, _, _, _):
|
||||
peerIds.insert(peer.peerId)
|
||||
case let .updateDraftMessage(peer, draft):
|
||||
@ -114,7 +114,7 @@ private func peerIdsRequiringLocalChatStateFromUpdateGroups(_ groups: [UpdateGro
|
||||
for update in group.updates {
|
||||
switch update {
|
||||
case let .updateChannel(channelId):
|
||||
channelUpdates.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId))
|
||||
channelUpdates.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)))
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -147,7 +147,7 @@ private func locallyGeneratedMessageTimestampsFromUpdateGroups(_ groups: [Update
|
||||
switch update {
|
||||
case let .updateServiceNotification(_, date, _, _, _, _):
|
||||
if let date = date {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000))
|
||||
if messageTimestamps[peerId] == nil {
|
||||
messageTimestamps[peerId] = [(Namespaces.Message.Local, date)]
|
||||
} else {
|
||||
@ -303,7 +303,7 @@ private func peerIdsRequiringLocalChatStateFromDifference(_ difference: Api.upda
|
||||
}
|
||||
switch update {
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
default:
|
||||
break
|
||||
@ -325,7 +325,7 @@ private func peerIdsRequiringLocalChatStateFromDifference(_ difference: Api.upda
|
||||
}
|
||||
switch update {
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
default:
|
||||
break
|
||||
@ -358,7 +358,7 @@ private func locallyGeneratedMessageTimestampsFromDifference(_ difference: Api.u
|
||||
switch update {
|
||||
case let .updateServiceNotification(_, date, _, _, _, _):
|
||||
if let date = date {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000))
|
||||
if messageTimestamps[peerId] == nil {
|
||||
messageTimestamps[peerId] = [(Namespaces.Message.Local, date)]
|
||||
} else {
|
||||
@ -684,21 +684,21 @@ private func sortedUpdates(_ updates: [Api.Update]) -> [Api.Update] {
|
||||
for update in updates {
|
||||
switch update {
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
updatesByChannel[peerId] = [update]
|
||||
} else {
|
||||
updatesByChannel[peerId]!.append(update)
|
||||
}
|
||||
case let .updateDeleteChannelMessages(channelId, _, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
updatesByChannel[peerId] = [update]
|
||||
} else {
|
||||
updatesByChannel[peerId]!.append(update)
|
||||
}
|
||||
case let .updatePinnedChannelMessages(_, channelId, _, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
updatesByChannel[peerId] = [update]
|
||||
} else {
|
||||
@ -725,14 +725,14 @@ private func sortedUpdates(_ updates: [Api.Update]) -> [Api.Update] {
|
||||
otherUpdates.append(update)
|
||||
}
|
||||
case let .updateChannelWebPage(channelId, _, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
updatesByChannel[peerId] = [update]
|
||||
} else {
|
||||
updatesByChannel[peerId]!.append(update)
|
||||
}
|
||||
case let .updateChannelAvailableMessages(channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
updatesByChannel[peerId] = [update]
|
||||
} else {
|
||||
@ -817,7 +817,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
for update in sortedUpdates(updates) {
|
||||
switch update {
|
||||
case let .updateChannelTooLong(_, channelId, channelPts):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if !channelsToPoll.contains(peerId) {
|
||||
if let channelPts = channelPts, let channelState = state.channelStates[peerId], channelState.pts >= channelPts {
|
||||
Logger.shared.log("State", "channel \(peerId) (\((updatedState.peers[peerId] as? TelegramChannel)?.title ?? "nil")) skip updateChannelTooLong by pts")
|
||||
@ -826,7 +826,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
}
|
||||
case let .updateDeleteChannelMessages(channelId, messages, pts: pts, ptsCount):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if let previousState = updatedState.channelStates[peerId] {
|
||||
if previousState.pts >= pts {
|
||||
Logger.shared.log("State", "channel \(peerId) (\((updatedState.peers[peerId] as? TelegramChannel)?.title ?? "nil")) skip old delete update")
|
||||
@ -877,7 +877,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
Logger.shared.log("State", "Invalid updateEditChannelMessage")
|
||||
}
|
||||
case let .updateChannelWebPage(channelId, apiWebpage, pts, ptsCount):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if let previousState = updatedState.channelStates[peerId] {
|
||||
if previousState.pts >= pts {
|
||||
} else if previousState.pts + ptsCount == pts {
|
||||
@ -903,7 +903,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
}
|
||||
case let .updateChannelAvailableMessages(channelId, minId):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
updatedState.updateMinAvailableMessage(MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: minId))
|
||||
case let .updateDeleteMessages(messages, _, _):
|
||||
updatedState.deleteMessagesWithGlobalIds(messages)
|
||||
@ -980,7 +980,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
if popup {
|
||||
updatedState.addDisplayAlert(text, isDropAuth: type.hasPrefix("AUTH_KEY_DROP_"))
|
||||
} else if let date = date {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000))
|
||||
|
||||
if updatedState.peers[peerId] == nil {
|
||||
updatedState.updatePeer(peerId, { peer in
|
||||
@ -1029,13 +1029,13 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
}
|
||||
case let .updateReadChannelInbox(_, folderId, channelId, maxId, stillUnreadCount, pts):
|
||||
updatedState.resetIncomingReadState(groupId: PeerGroupId(rawValue: folderId ?? 0), peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, maxIncomingReadId: maxId, count: stillUnreadCount, pts: pts)
|
||||
updatedState.resetIncomingReadState(groupId: PeerGroupId(rawValue: folderId ?? 0), peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, maxIncomingReadId: maxId, count: stillUnreadCount, pts: pts)
|
||||
case let .updateReadChannelOutbox(channelId, maxId):
|
||||
updatedState.readOutbox(MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: maxId), timestamp: nil)
|
||||
updatedState.readOutbox(MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: maxId), timestamp: nil)
|
||||
case let .updateChannel(channelId):
|
||||
updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId))
|
||||
updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)))
|
||||
case let .updateChat(chatId):
|
||||
updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId))
|
||||
updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)))
|
||||
case let .updateReadHistoryInbox(_, folderId, peer, maxId, stillUnreadCount, pts, _):
|
||||
updatedState.resetIncomingReadState(groupId: PeerGroupId(rawValue: folderId ?? 0), peerId: peer.peerId, namespace: Namespaces.Message.Cloud, maxIncomingReadId: maxId, count: stillUnreadCount, pts: pts)
|
||||
case let .updateReadHistoryOutbox(peer, maxId, _, _):
|
||||
@ -1043,11 +1043,11 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
case let .updateReadChannelDiscussionInbox(_, channelId, topMsgId, readMaxId, mainChannelId, mainChannelPost):
|
||||
var mainChannelMessage: MessageId?
|
||||
if let mainChannelId = mainChannelId, let mainChannelPost = mainChannelPost {
|
||||
mainChannelMessage = MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: mainChannelId), namespace: Namespaces.Message.Cloud, id: mainChannelPost)
|
||||
mainChannelMessage = MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(mainChannelId)), namespace: Namespaces.Message.Cloud, id: mainChannelPost)
|
||||
}
|
||||
updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: true, mainChannelMessage: mainChannelMessage)
|
||||
updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: true, mainChannelMessage: mainChannelMessage)
|
||||
case let .updateReadChannelDiscussionOutbox(channelId, topMsgId, readMaxId):
|
||||
updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: false, mainChannelMessage: nil)
|
||||
updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: false, mainChannelMessage: nil)
|
||||
case let .updateDialogUnreadMark(flags, peer):
|
||||
switch peer {
|
||||
case let .dialogPeer(peer):
|
||||
@ -1081,9 +1081,9 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
let groupPeerId: PeerId
|
||||
switch participants {
|
||||
case let .chatParticipants(chatId, _, _):
|
||||
groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .chatParticipantsForbidden(_, chatId, _):
|
||||
groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
}
|
||||
updatedState.updateCachedPeerData(groupPeerId, { current in
|
||||
let previous: CachedGroupData
|
||||
@ -1095,9 +1095,9 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
return previous.withUpdatedParticipants(CachedGroupParticipants(apiParticipants: participants))
|
||||
})
|
||||
case let .updateChatParticipantAdd(chatId, userId, inviterId, date, _):
|
||||
let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let inviterPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId)
|
||||
let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
let inviterPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId))
|
||||
updatedState.updateCachedPeerData(groupPeerId, { current in
|
||||
if let current = current as? CachedGroupData, let participants = current.participants {
|
||||
var updatedParticipants = participants.participants
|
||||
@ -1110,8 +1110,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
})
|
||||
case let .updateChatParticipantDelete(chatId, userId, _):
|
||||
let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
updatedState.updateCachedPeerData(groupPeerId, { current in
|
||||
if let current = current as? CachedGroupData, let participants = current.participants {
|
||||
var updatedParticipants = participants.participants
|
||||
@ -1124,8 +1124,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
})
|
||||
case let .updateChatParticipantAdmin(chatId, userId, isAdmin, _):
|
||||
let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
updatedState.updateCachedPeerData(groupPeerId, { current in
|
||||
if let current = current as? CachedGroupData, let participants = current.participants {
|
||||
var updatedParticipants = participants.participants
|
||||
@ -1156,12 +1156,12 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
})
|
||||
case let .updatePinnedChannelMessages(flags, channelId, messages, pts, ptsCount):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
if let previousState = updatedState.channelStates[peerId] {
|
||||
if previousState.pts >= pts {
|
||||
Logger.shared.log("State", "channel \(peerId) (\((updatedState.peers[peerId] as? TelegramChannel)?.title ?? "nil")) skip old pinned messages update")
|
||||
} else if previousState.pts + ptsCount == pts {
|
||||
let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
updatedState.updateMessagesPinned(ids: messages.map { id in
|
||||
MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id)
|
||||
}, pinned: (flags & (1 << 0)) != 0)
|
||||
@ -1190,10 +1190,10 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
return previous.withUpdatedIsBlocked(blocked == .boolTrue)
|
||||
})
|
||||
case let .updateUserStatus(userId, status):
|
||||
updatedState.mergePeerPresences([PeerId(namespace: Namespaces.Peer.CloudUser, id: userId): status], explicit: true)
|
||||
updatedState.mergePeerPresences([PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)): status], explicit: true)
|
||||
case let .updateUserName(userId, firstName, lastName, username):
|
||||
//TODO add contact checking for apply first and last name
|
||||
updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), { peer in
|
||||
updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), { peer in
|
||||
if let user = peer as? TelegramUser {
|
||||
return user.withUpdatedUsername(username)
|
||||
} else {
|
||||
@ -1201,7 +1201,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
})
|
||||
case let .updateUserPhoto(userId, _, photo, _):
|
||||
updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), { peer in
|
||||
updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), { peer in
|
||||
if let user = peer as? TelegramUser {
|
||||
return user.withUpdatedPhoto(parsedTelegramProfilePhoto(photo))
|
||||
} else {
|
||||
@ -1209,7 +1209,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
})
|
||||
case let .updateUserPhone(userId, phone):
|
||||
updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), { peer in
|
||||
updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), { peer in
|
||||
if let user = peer as? TelegramUser {
|
||||
return user.withUpdatedPhone(phone.isEmpty ? nil : phone)
|
||||
} else {
|
||||
@ -1252,7 +1252,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
case let .updateNewEncryptedMessage(message, _):
|
||||
updatedState.addSecretMessages([message])
|
||||
case let .updateEncryptedMessagesRead(chatId, maxDate, date):
|
||||
updatedState.readSecretOutbox(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: chatId), timestamp: maxDate, actionTimestamp: date)
|
||||
updatedState.readSecretOutbox(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), timestamp: maxDate, actionTimestamp: date)
|
||||
case let .updateUserTyping(userId, type):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
let activity = PeerInputActivity(apiType: type, timestamp: date)
|
||||
@ -1261,7 +1261,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
category = .voiceChat
|
||||
}
|
||||
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), category: category), peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), activity: activity)
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), category: category), peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), activity: activity)
|
||||
}
|
||||
case let .updateChatUserTyping(chatId, userId, type):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
@ -1271,11 +1271,11 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
category = .voiceChat
|
||||
}
|
||||
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId), category: category), peerId: userId.peerId, activity: activity)
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), category: category), peerId: userId.peerId, activity: activity)
|
||||
}
|
||||
case let .updateChannelUserTyping(_, channelId, topMsgId, userId, type):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
let threadId = topMsgId.flatMap { makeMessageThreadId(MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: $0)) }
|
||||
|
||||
let activity = PeerInputActivity(apiType: type, timestamp: date)
|
||||
@ -1290,7 +1290,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
case let .updateEncryptedChatTyping(chatId):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: chatId), category: .global), peerId: nil, activity: .typingText)
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), category: .global), peerId: nil, activity: .typingText)
|
||||
}
|
||||
case let .updateDialogPinned(flags, folderId, peer):
|
||||
let groupId: PeerGroupId = folderId.flatMap(PeerGroupId.init(rawValue:)) ?? .root
|
||||
@ -1325,9 +1325,9 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
case let .updateReadMessagesContents(messages, _, _):
|
||||
updatedState.addReadMessagesContents((nil, messages))
|
||||
case let .updateChannelReadMessagesContents(channelId, messages):
|
||||
updatedState.addReadMessagesContents((PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), messages))
|
||||
updatedState.addReadMessagesContents((PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), messages))
|
||||
case let .updateChannelMessageViews(channelId, id, views):
|
||||
updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: id), count: views)
|
||||
updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: id), count: views)
|
||||
/*case let .updateChannelMessageForwards(channelId, id, forwards):
|
||||
updatedState.addUpdateMessageForwardsCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: id), count: forwards)*/
|
||||
case let .updateNewStickerSet(stickerset):
|
||||
@ -1367,8 +1367,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
updatedState.updateGroupCallParticipants(id: id, accessHash: accessHash, participants: participants, version: version)
|
||||
}
|
||||
case let .updateGroupCall(channelId, call):
|
||||
updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), call: call)
|
||||
updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: channelId), call: call)
|
||||
updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), call: call)
|
||||
updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(channelId)), call: call)
|
||||
case let .updatePeerHistoryTTL(_, peer, ttl):
|
||||
updatedState.updateAutoremoveTimeout(peer: peer, value: CachedPeerAutoremoveTimeout.Value(ttl))
|
||||
case let .updateLangPackTooLong(langCode):
|
||||
@ -1791,15 +1791,7 @@ private func resetChannels(network: Network, peers: [Peer], state: AccountMutabl
|
||||
continue loop
|
||||
}
|
||||
|
||||
let peerId: PeerId
|
||||
switch apiPeer {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = apiPeer.peerId
|
||||
|
||||
if readStates[peerId] == nil {
|
||||
readStates[peerId] = [:]
|
||||
@ -1967,7 +1959,7 @@ private func pollChannel(network: Network, peer: Peer, state: AccountMutableStat
|
||||
Logger.shared.log("State", "Invalid updateEditChannelMessage")
|
||||
}
|
||||
case let .updatePinnedChannelMessages(flags, channelId, messages, _, _):
|
||||
let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
updatedState.updateMessagesPinned(ids: messages.map { id in
|
||||
MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id)
|
||||
}, pinned: (flags & (1 << 0)) != 0)
|
||||
|
@ -18,11 +18,11 @@ func channelUpdatesByPeerId(updates: [ChannelUpdate]) -> [PeerId: [ChannelUpdate
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
peerId = apiMessagePeerId(message)
|
||||
case let .updateDeleteChannelMessages(channelId, _, _, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
case let .updateEditChannelMessage(message, _, _):
|
||||
peerId = apiMessagePeerId(message)
|
||||
case let .updateChannelWebPage(channelId, _, _, _):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ private func removeMessages(postbox: Postbox, network: Network, stateManager: Ac
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .affectedMessages(pts, ptsCount):
|
||||
stateManager.addUpdateGroups([.updateChannelPts(channelId: peer.id.id, pts: pts, ptsCount: ptsCount)])
|
||||
stateManager.addUpdateGroups([.updateChannelPts(channelId: peer.id.id._internalGetInt32Value(), pts: pts, ptsCount: ptsCount)])
|
||||
}
|
||||
}
|
||||
return .complete()
|
||||
@ -267,7 +267,7 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net
|
||||
} else if peer.id.namespace == Namespaces.Peer.CloudGroup {
|
||||
let deleteUser: Signal<Void, NoError>
|
||||
if operation.deleteGloballyIfPossible {
|
||||
deleteUser = network.request(Api.functions.messages.deleteChat(chatId: peer.id.id))
|
||||
deleteUser = network.request(Api.functions.messages.deleteChat(chatId: peer.id.id._internalGetInt32Value()))
|
||||
|> `catch` { _ in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
@ -275,7 +275,7 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net
|
||||
return .complete()
|
||||
}
|
||||
} else {
|
||||
deleteUser = network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peer.id.id, userId: Api.InputUser.inputUserSelf))
|
||||
deleteUser = network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peer.id.id._internalGetInt32Value(), userId: Api.InputUser.inputUserSelf))
|
||||
|> map { result -> Api.Updates? in
|
||||
return result
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ private func requestActivity(postbox: Postbox, network: Network, accountPeerId:
|
||||
return .complete()
|
||||
}
|
||||
} else if let peer = peer as? TelegramSecretChat, activity == .typingText {
|
||||
return network.request(Api.functions.messages.setEncryptedTyping(peer: .inputEncryptedChat(chatId: peer.id.id, accessHash: peer.accessHash), typing: .boolTrue))
|
||||
return network.request(Api.functions.messages.setEncryptedTyping(peer: .inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash), typing: .boolTrue))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ private func initialHandshakeAccept(postbox: Postbox, network: Network, peerId:
|
||||
memcpy(&keyFingerprint, bytes.advanced(by: keyHash.count - 8), 8)
|
||||
}
|
||||
|
||||
let result = network.request(Api.functions.messages.acceptEncryption(peer: .inputEncryptedChat(chatId: peerId.id, accessHash: accessHash), gB: Buffer(data: gb), keyFingerprint: keyFingerprint))
|
||||
let result = network.request(Api.functions.messages.acceptEncryption(peer: .inputEncryptedChat(chatId: peerId.id._internalGetInt32Value(), accessHash: accessHash), gB: Buffer(data: gb), keyFingerprint: keyFingerprint))
|
||||
|
||||
let response = result
|
||||
|> map { result -> Api.EncryptedChat? in
|
||||
@ -1636,7 +1636,7 @@ private func sendBoxedDecryptedMessage(postbox: Postbox, network: Network, peer:
|
||||
decryptedMessage.serialize(payload, role: state.role, sequenceInfo: sequenceInfo)
|
||||
let encryptedPayload = encryptedMessageContents(parameters: parameters, data: MemoryBuffer(payload))
|
||||
let sendMessage: Signal<Api.messages.SentEncryptedMessage, MTRpcError>
|
||||
let inputPeer = Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id, accessHash: peer.accessHash)
|
||||
let inputPeer = Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash)
|
||||
|
||||
var flags: Int32 = 0
|
||||
if silent {
|
||||
@ -1676,7 +1676,7 @@ private func requestTerminateSecretChat(postbox: Postbox, network: Network, peer
|
||||
if requestRemoteHistoryRemoval {
|
||||
flags |= 1 << 0
|
||||
}
|
||||
return network.request(Api.functions.messages.discardEncryption(flags: flags, chatId: peerId.id))
|
||||
return network.request(Api.functions.messages.discardEncryption(flags: flags, chatId: peerId.id._internalGetInt32Value()))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ in
|
||||
return .single(nil)
|
||||
@ -1692,7 +1692,7 @@ private func requestTerminateSecretChat(postbox: Postbox, network: Network, peer
|
||||
}
|
||||
|> mapToSignal { peer -> Signal<Void, NoError> in
|
||||
if let peer = peer {
|
||||
return network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id, accessHash: peer.accessHash)))
|
||||
return network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash)))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Bool?, NoError> in
|
||||
return .single(nil)
|
||||
|
@ -83,7 +83,7 @@ func managedSynchronizePinnedChatsOperations(postbox: Postbox, network: Network,
|
||||
let signal = withTakenOperation(postbox: postbox, peerId: entry.peerId, tagLocalIndex: entry.tagLocalIndex, { transaction, entry -> Signal<Void, NoError> in
|
||||
if let entry = entry {
|
||||
if let operation = entry.contents as? SynchronizePinnedChatsOperation {
|
||||
return synchronizePinnedChats(transaction: transaction, postbox: postbox, network: network, accountPeerId: accountPeerId, stateManager: stateManager, groupId: PeerGroupId(rawValue: entry.peerId.id), operation: operation)
|
||||
return synchronizePinnedChats(transaction: transaction, postbox: postbox, network: network, accountPeerId: accountPeerId, stateManager: stateManager, groupId: PeerGroupId(rawValue: entry.peerId.id._internalGetInt32Value()), operation: operation)
|
||||
} else {
|
||||
assertionFailure()
|
||||
}
|
||||
@ -182,15 +182,7 @@ private func synchronizePinnedChats(transaction: Transaction, postbox: Postbox,
|
||||
continue loop
|
||||
}
|
||||
|
||||
let peerId: PeerId
|
||||
switch apiPeer {
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
}
|
||||
let peerId: PeerId = apiPeer.peerId
|
||||
|
||||
remoteItemIds.append(.peer(peerId))
|
||||
|
||||
|
@ -152,15 +152,15 @@ extension Api.Chat {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .chat(chat):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: chat.id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chat.id))
|
||||
case let .chatEmpty(id):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .chatForbidden(id, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .channel(channel):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: channel.id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channel.id))
|
||||
case let .channelForbidden(_, id, _, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,9 +169,9 @@ extension Api.User {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case .user(_, let id, _, _, _, _, _, _, _, _, _, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .userEmpty(id):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,11 +180,11 @@ extension Api.Peer {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .peerChannel(channelId):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
case let .peerChat(chatId):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .peerUser(userId):
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -254,40 +254,40 @@ extension Api.Update {
|
||||
var peerIds: [PeerId] {
|
||||
switch self {
|
||||
case let .updateChannel(channelId):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))]
|
||||
case let .updateChat(chatId):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))]
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))]
|
||||
case let .updateChatParticipantAdd(chatId, userId, inviterId, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId), PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId))]
|
||||
case let .updateChatParticipantAdmin(chatId, userId, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId), PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))]
|
||||
case let .updateChatParticipantDelete(chatId, userId, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId), PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))]
|
||||
case let .updateChatParticipants(participants):
|
||||
switch participants {
|
||||
case let .chatParticipants(chatId, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))]
|
||||
case let .chatParticipantsForbidden(_, chatId, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))]
|
||||
}
|
||||
case let .updateDeleteChannelMessages(channelId, _, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))]
|
||||
case let .updatePinnedChannelMessages(_, channelId, _, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))]
|
||||
case let .updateNewChannelMessage(message, _, _):
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateEditChannelMessage(message, _, _):
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateChannelWebPage(channelId, _, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))]
|
||||
case let .updateNewMessage(message, _, _):
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateEditMessage(message, _, _):
|
||||
return apiMessagePeerIds(message)
|
||||
case let .updateReadChannelInbox(_, _, channelId, _, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))]
|
||||
case let .updateNotifySettings(peer, _):
|
||||
switch peer {
|
||||
case let .notifyPeer(peer):
|
||||
@ -296,14 +296,14 @@ extension Api.Update {
|
||||
return []
|
||||
}
|
||||
case let .updateUserName(userId, _, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))]
|
||||
case let .updateUserPhone(userId, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))]
|
||||
case let .updateUserPhoto(userId, _, _, _):
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))]
|
||||
case let .updateServiceNotification(_, inboxDate, _, _, _, _):
|
||||
if let _ = inboxDate {
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000)]
|
||||
return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000))]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
@ -424,9 +424,9 @@ extension Api.Updates {
|
||||
case .updatesTooLong:
|
||||
return []
|
||||
case let .updateShortMessage(_, id, userId, _, _, _, _, _, _, _, _, _):
|
||||
return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), namespace: Namespaces.Message.Cloud, id: id)]
|
||||
return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), namespace: Namespaces.Message.Cloud, id: id)]
|
||||
case let .updateShortChatMessage(_, id, _, chatId, _, _, _, _, _, _, _, _, _):
|
||||
return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId), namespace: Namespaces.Message.Cloud, id: id)]
|
||||
return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), namespace: Namespaces.Message.Cloud, id: id)]
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,15 +555,15 @@ extension Api.EncryptedChat {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .encryptedChat(id, _, _, _, _, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .encryptedChatDiscarded(_, id):
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .encryptedChatEmpty(id):
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .encryptedChatRequested(_, _, id, _, _, _, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id))
|
||||
case let .encryptedChatWaiting(id, _, _, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -572,9 +572,9 @@ extension Api.EncryptedMessage {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .encryptedMessage(_, chatId, _, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: chatId)
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
case let .encryptedMessageService(_, chatId, _, _):
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: chatId)
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,14 +157,14 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
}
|
||||
|
||||
if let viaBotId = viaBotId {
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: viaBotId))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(viaBotId)))
|
||||
}
|
||||
|
||||
if let media = media {
|
||||
switch media {
|
||||
case let .messageMediaContact(_, _, _, _, userId):
|
||||
if userId != 0 {
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)))
|
||||
}
|
||||
default:
|
||||
break
|
||||
@ -175,7 +175,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
for entity in entities {
|
||||
switch entity {
|
||||
case let .messageEntityMentionName(_, _, userId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)))
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -199,27 +199,27 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL:
|
||||
break
|
||||
case let .messageActionChannelMigrateFrom(_, chatId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)))
|
||||
case let .messageActionChatAddUser(users):
|
||||
for id in users {
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: id))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)))
|
||||
}
|
||||
case let .messageActionChatCreate(_, users):
|
||||
for id in users {
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: id))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)))
|
||||
}
|
||||
case let .messageActionChatDeleteUser(userId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: userId))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)))
|
||||
case let .messageActionChatJoinedByLink(inviterId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)))
|
||||
case let .messageActionChatMigrateTo(channelId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)))
|
||||
case let .messageActionGeoProximityReached(fromId, toId, _):
|
||||
result.append(fromId.peerId)
|
||||
result.append(toId.peerId)
|
||||
case let .messageActionInviteToGroupCall(_, userIds):
|
||||
for id in userIds {
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: id))
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
|
||||
return (TelegramMediaExpiredContent(data: .image), nil)
|
||||
}
|
||||
case let .messageMediaContact(phoneNumber, firstName, lastName, vcard, userId):
|
||||
let contactPeerId: PeerId? = userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let contactPeerId: PeerId? = userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
let mediaContact = TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: contactPeerId, vCardData: vcard.isEmpty ? nil : vcard)
|
||||
return (mediaContact, nil)
|
||||
case let .messageMediaGeo(geo):
|
||||
@ -354,7 +354,7 @@ func messageTextEntitiesFromApiEntities(_ entities: [Api.MessageEntity]) -> [Mes
|
||||
case let .messageEntityTextUrl(offset, length, url):
|
||||
result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextUrl(url: url)))
|
||||
case let .messageEntityMentionName(offset, length, userId):
|
||||
result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextMention(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId))))
|
||||
result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextMention(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)))))
|
||||
case let .messageEntityPhone(offset, length):
|
||||
result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .PhoneNumber))
|
||||
case let .messageEntityCashtag(offset, length):
|
||||
@ -385,10 +385,10 @@ extension StoreMessage {
|
||||
peerId = chatPeerId.peerId
|
||||
authorId = resolvedFromId
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))
|
||||
authorId = resolvedFromId
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))
|
||||
authorId = resolvedFromId
|
||||
}
|
||||
|
||||
@ -444,15 +444,7 @@ extension StoreMessage {
|
||||
}
|
||||
|
||||
if let savedFromPeer = savedFromPeer, let savedFromMsgId = savedFromMsgId {
|
||||
let peerId: PeerId
|
||||
switch savedFromPeer {
|
||||
case let .peerChannel(channelId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
|
||||
case let .peerChat(chatId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
|
||||
case let .peerUser(userId):
|
||||
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
}
|
||||
let peerId: PeerId = savedFromPeer.peerId
|
||||
let messageId: MessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: savedFromMsgId)
|
||||
attributes.append(SourceReferenceMessageAttribute(messageId: messageId))
|
||||
}
|
||||
@ -510,7 +502,7 @@ extension StoreMessage {
|
||||
}
|
||||
|
||||
if let viaBotId = viaBotId {
|
||||
attributes.append(InlineBotMessageAttribute(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: viaBotId), title: nil))
|
||||
attributes.append(InlineBotMessageAttribute(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(viaBotId)), title: nil))
|
||||
}
|
||||
|
||||
if namespace != Namespaces.Message.ScheduledCloud {
|
||||
@ -569,7 +561,7 @@ extension StoreMessage {
|
||||
recentRepliersPeerIds = nil
|
||||
}
|
||||
|
||||
let commentsPeerId = channelId.flatMap { PeerId(namespace: Namespaces.Peer.CloudChannel, id: $0) }
|
||||
let commentsPeerId = channelId.flatMap { PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value($0)) }
|
||||
|
||||
attributes.append(ReplyThreadMessageAttribute(count: repliesCount, latestUsers: recentRepliersPeerIds ?? [], commentsPeerId: commentsPeerId, maxMessageId: maxId, maxReadMessageId: readMaxId))
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user