mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Add type metadata to accessHash
This commit is contained in:
parent
17595d72dd
commit
6076a912fc
@ -188,7 +188,6 @@
|
||||
09FDAEE62140477F00BF856F /* MtProtoKitDynamic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09FDAEE52140477F00BF856F /* MtProtoKitDynamic.framework */; };
|
||||
D000CACF21FB6E380011B15D /* NotificationService.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = D000CAC821FB6E370011B15D /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
D001D5AA1F878DA300DF975A /* PhoneCountries.txt in Resources */ = {isa = PBXBuildFile; fileRef = D001D5A91F878DA300DF975A /* PhoneCountries.txt */; };
|
||||
D008184E22B5796E008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008184D22B5796E008A895F /* BuildConfig.framework */; };
|
||||
D008185022B5797A008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008184F22B5797A008A895F /* BuildConfig.framework */; };
|
||||
D008185222B57986008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008185122B57986008A895F /* BuildConfig.framework */; };
|
||||
D008185422B57994008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008185322B57994008A895F /* BuildConfig.framework */; };
|
||||
@ -205,7 +204,6 @@
|
||||
D015E04D225D2D8F00CB9E8A /* WebP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D015E04C225D2D8F00CB9E8A /* WebP.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||
D015E050225D303F00CB9E8A /* WebP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D015E04C225D2D8F00CB9E8A /* WebP.framework */; };
|
||||
D015E051225D303F00CB9E8A /* WebP.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D015E04C225D2D8F00CB9E8A /* WebP.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D01A47551F4DBED700383CC1 /* HockeySDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D01A47541F4DBED700383CC1 /* HockeySDK.framework */; };
|
||||
D021D4D9219CAEDD0064BEBA /* Config-Fork.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = D021D4D8219CAEDD0064BEBA /* Config-Fork.xcconfig */; };
|
||||
D02CF5FD215D9ABF00E0F56A /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0AA1A671D568BA400152314 /* UserNotifications.framework */; };
|
||||
D02CF5FE215D9ABF00E0F56A /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0AA1A691D568BA400152314 /* UserNotificationsUI.framework */; };
|
||||
@ -1099,11 +1097,9 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D008184E22B5796E008A895F /* BuildConfig.framework in Frameworks */,
|
||||
D0CAD6A421C03BEB001E3055 /* FFMpeg.framework in Frameworks */,
|
||||
09C50E88217385CF009E676F /* WatchConnectivity.framework in Frameworks */,
|
||||
09FDAEE62140477F00BF856F /* MtProtoKitDynamic.framework in Frameworks */,
|
||||
D01A47551F4DBED700383CC1 /* HockeySDK.framework in Frameworks */,
|
||||
D0A18D631E149043004C6734 /* PushKit.framework in Frameworks */,
|
||||
D0B844601DACF561005F29E1 /* libc++.tbd in Frameworks */,
|
||||
D06706621D5118F500DED3E3 /* TelegramCore.framework in Frameworks */,
|
||||
|
||||
@ -103,7 +103,15 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
restrictionInfo = nil
|
||||
}
|
||||
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHash, 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))
|
||||
let accessHashValue = accessHash.flatMap { value -> TelegramPeerAccessHash in
|
||||
if isMin {
|
||||
return .genericPublic(value)
|
||||
} else {
|
||||
return .personal(value)
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
case let .channelForbidden(flags, id, accessHash, title, untilDate):
|
||||
let info: TelegramChannelInfo
|
||||
if (flags & Int32(1 << 8)) != 0 {
|
||||
@ -112,7 +120,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
info = .broadcast(TelegramChannelBroadcastInfo(flags: []))
|
||||
}
|
||||
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: 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: 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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +129,8 @@ func mergeGroupOrChannel(lhs: Peer?, rhs: Api.Chat) -> Peer? {
|
||||
case .chat, .chatEmpty, .chatForbidden, .channelForbidden:
|
||||
return parseTelegramGroupOrChannel(chat: rhs)
|
||||
case let .channel(flags, _, accessHash, title, username, photo, _, _, _, _, _, defaultBannedRights, _/*feed*//*, feedId*/):
|
||||
if accessHash != nil && (flags & (1 << 12)) == 0 {
|
||||
let isMin = (flags & (1 << 12)) != 0
|
||||
if accessHash != nil && !isMin {
|
||||
return parseTelegramGroupOrChannel(chat: rhs)
|
||||
} else if let lhs = lhs as? TelegramChannel {
|
||||
var channelFlags = lhs.flags
|
||||
|
||||
@ -56,7 +56,7 @@ 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)
|
||||
self = .user(id: user.id.id, accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -64,7 +64,7 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable {
|
||||
self = .group(id: group.id.id)
|
||||
case let channel as TelegramChannel:
|
||||
if let accessHash = channel.accessHash {
|
||||
self = .channel(id: channel.id.id, accessHash: accessHash)
|
||||
self = .channel(id: channel.id.id, accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -104,12 +104,12 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable {
|
||||
func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
||||
switch peer {
|
||||
case let user as TelegramUser:
|
||||
return Api.InputPeer.inputPeerUser(userId: user.id.id, accessHash: user.accessHash ?? 0)
|
||||
return Api.InputPeer.inputPeerUser(userId: user.id.id, accessHash: user.accessHash?.value ?? 0)
|
||||
case let group as TelegramGroup:
|
||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
||||
case let channel as TelegramChannel:
|
||||
if let accessHash = channel.accessHash {
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id, accessHash: accessHash)
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id, accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -121,12 +121,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!)
|
||||
return Api.InputPeer.inputPeerUser(userId: user.id.id, accessHash: user.accessHash!.value)
|
||||
case let group as TelegramGroup:
|
||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
||||
case let channel as TelegramChannel:
|
||||
if let accessHash = channel.accessHash {
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id, accessHash: accessHash)
|
||||
return Api.InputPeer.inputPeerChannel(channelId: channel.id.id, accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -137,7 +137,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)
|
||||
return Api.InputChannel.inputChannel(channelId: channel.id.id, accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -145,7 +145,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)
|
||||
return Api.InputUser.inputUser(userId: user.id.id, accessHash: accessHash.value)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ public func loadedPeerFromMessage(account: Account, peerId: PeerId, messageId: M
|
||||
return account.postbox.transaction { transaction -> Signal<Peer?, NoError> in
|
||||
if let peer = transaction.getPeer(peerId) {
|
||||
if let user = peer as? TelegramUser {
|
||||
if user.accessHash != 0 {
|
||||
if let accessHash = user.accessHash, accessHash.value != 0 {
|
||||
return .single(user)
|
||||
} else {
|
||||
let messageSignal: Signal<Api.messages.Messages?, NoError>?
|
||||
@ -50,7 +50,7 @@ public func loadedPeerFromMessage(account: Account, peerId: PeerId, messageId: M
|
||||
|
||||
for user in apiUsers {
|
||||
let telegramUser = TelegramUser(user: user)
|
||||
if telegramUser.id == peerId && telegramUser.accessHash != 0 {
|
||||
if telegramUser.id == peerId, let accessHash = telegramUser.accessHash, accessHash.value != 0 {
|
||||
if let presence = TelegramUserPresence(apiUser: user) {
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: account.peerId, peerPresences: [telegramUser.id: presence])
|
||||
}
|
||||
|
||||
@ -3,4 +3,13 @@ import Foundation
|
||||
public enum TelegramPeerAccessHash: Hashable {
|
||||
case personal(Int64)
|
||||
case genericPublic(Int64)
|
||||
|
||||
public var value: Int64 {
|
||||
switch self {
|
||||
case let .personal(personal):
|
||||
return personal
|
||||
case let .genericPublic(genericPublic):
|
||||
return genericPublic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public struct TelegramChannelFlags: OptionSet {
|
||||
|
||||
public final class TelegramChannel: Peer {
|
||||
public let id: PeerId
|
||||
public let accessHash: Int64?
|
||||
public let accessHash: TelegramPeerAccessHash?
|
||||
public let title: String
|
||||
public let username: String?
|
||||
public let photo: [TelegramMediaImageRepresentation]
|
||||
@ -169,7 +169,7 @@ public final class TelegramChannel: Peer {
|
||||
public let associatedPeerId: PeerId? = nil
|
||||
public let notificationSettingsPeerId: PeerId? = nil
|
||||
|
||||
public init(id: PeerId, accessHash: Int64?, title: String, username: String?, photo: [TelegramMediaImageRepresentation], creationDate: Int32, version: Int32, participationStatus: TelegramChannelParticipationStatus, info: TelegramChannelInfo, flags: TelegramChannelFlags, restrictionInfo: PeerAccessRestrictionInfo?, adminRights: TelegramChatAdminRights?, bannedRights: TelegramChatBannedRights?, defaultBannedRights: TelegramChatBannedRights?) {
|
||||
public init(id: PeerId, accessHash: TelegramPeerAccessHash?, title: String, username: String?, photo: [TelegramMediaImageRepresentation], creationDate: Int32, version: Int32, participationStatus: TelegramChannelParticipationStatus, info: TelegramChannelInfo, flags: TelegramChannelFlags, restrictionInfo: PeerAccessRestrictionInfo?, adminRights: TelegramChatAdminRights?, bannedRights: TelegramChatBannedRights?, defaultBannedRights: TelegramChatBannedRights?) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
self.title = title
|
||||
@ -188,7 +188,17 @@ public final class TelegramChannel: Peer {
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.id = PeerId(decoder.decodeInt64ForKey("i", orElse: 0))
|
||||
self.accessHash = decoder.decodeOptionalInt64ForKey("ah")
|
||||
let accessHash = decoder.decodeOptionalInt64ForKey("ah")
|
||||
let accessHashType: Int32 = decoder.decodeInt32ForKey("aht", orElse: 0)
|
||||
if let accessHash = accessHash {
|
||||
if accessHashType == 0 {
|
||||
self.accessHash = .personal(accessHash)
|
||||
} else {
|
||||
self.accessHash = .genericPublic(accessHash)
|
||||
}
|
||||
} else {
|
||||
self.accessHash = nil
|
||||
}
|
||||
self.title = decoder.decodeStringForKey("t", orElse: "")
|
||||
self.username = decoder.decodeOptionalStringForKey("un")
|
||||
self.photo = decoder.decodeObjectArrayForKey("ph")
|
||||
@ -206,7 +216,14 @@ public final class TelegramChannel: Peer {
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt64(self.id.toInt64(), forKey: "i")
|
||||
if let accessHash = self.accessHash {
|
||||
encoder.encodeInt64(accessHash, forKey: "ah")
|
||||
switch accessHash {
|
||||
case let .personal(value):
|
||||
encoder.encodeInt64(value, forKey: "ah")
|
||||
encoder.encodeInt32(0, forKey: "aht")
|
||||
case let .genericPublic(value):
|
||||
encoder.encodeInt64(value, forKey: "ah")
|
||||
encoder.encodeInt32(1, forKey: "aht")
|
||||
}
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "ah")
|
||||
}
|
||||
|
||||
@ -61,15 +61,11 @@ public struct BotUserInfo: PostboxCoding, Equatable {
|
||||
encoder.encodeNil(forKey: "ip")
|
||||
}
|
||||
}
|
||||
|
||||
public static func ==(lhs: BotUserInfo, rhs: BotUserInfo) -> Bool {
|
||||
return lhs.flags == rhs.flags && lhs.inlinePlaceholder == rhs.inlinePlaceholder
|
||||
}
|
||||
}
|
||||
|
||||
public final class TelegramUser: Peer {
|
||||
public let id: PeerId
|
||||
public let accessHash: Int64?
|
||||
public let accessHash: TelegramPeerAccessHash?
|
||||
public let firstName: String?
|
||||
public let lastName: String?
|
||||
public let username: String?
|
||||
@ -100,7 +96,7 @@ public final class TelegramUser: Peer {
|
||||
public let associatedPeerId: PeerId? = nil
|
||||
public let notificationSettingsPeerId: PeerId? = nil
|
||||
|
||||
public init(id: PeerId, accessHash: Int64?, firstName: String?, lastName: String?, username: String?, phone: String?, photo: [TelegramMediaImageRepresentation], botInfo: BotUserInfo?, restrictionInfo: PeerAccessRestrictionInfo?, flags: UserInfoFlags) {
|
||||
public init(id: PeerId, accessHash: TelegramPeerAccessHash?, firstName: String?, lastName: String?, username: String?, phone: String?, photo: [TelegramMediaImageRepresentation], botInfo: BotUserInfo?, restrictionInfo: PeerAccessRestrictionInfo?, flags: UserInfoFlags) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
self.firstName = firstName
|
||||
@ -117,8 +113,13 @@ public final class TelegramUser: Peer {
|
||||
self.id = PeerId(decoder.decodeInt64ForKey("i", orElse: 0))
|
||||
|
||||
let accessHash: Int64 = decoder.decodeInt64ForKey("ah", orElse: 0)
|
||||
let accessHashType: Int32 = decoder.decodeInt32ForKey("aht", orElse: 0)
|
||||
if accessHash != 0 {
|
||||
self.accessHash = accessHash
|
||||
if accessHashType == 0 {
|
||||
self.accessHash = .personal(accessHash)
|
||||
} else {
|
||||
self.accessHash = .genericPublic(accessHash)
|
||||
}
|
||||
} else {
|
||||
self.accessHash = nil
|
||||
}
|
||||
@ -146,7 +147,14 @@ public final class TelegramUser: Peer {
|
||||
encoder.encodeInt64(self.id.toInt64(), forKey: "i")
|
||||
|
||||
if let accessHash = self.accessHash {
|
||||
encoder.encodeInt64(accessHash, forKey: "ah")
|
||||
switch accessHash {
|
||||
case let .personal(value):
|
||||
encoder.encodeInt64(value, forKey: "ah")
|
||||
encoder.encodeInt32(0, forKey: "aht")
|
||||
case let .genericPublic(value):
|
||||
encoder.encodeInt64(value, forKey: "ah")
|
||||
encoder.encodeInt32(1, forKey: "aht")
|
||||
}
|
||||
}
|
||||
|
||||
if let firstName = self.firstName {
|
||||
@ -242,7 +250,7 @@ public final class TelegramUser: Peer {
|
||||
func parsedTelegramProfilePhoto(_ photo: Api.UserProfilePhoto) -> [TelegramMediaImageRepresentation] {
|
||||
var representations: [TelegramMediaImageRepresentation] = []
|
||||
switch photo {
|
||||
case let .userProfilePhoto(photoId, photoSmall, photoBig, dcId):
|
||||
case let .userProfilePhoto(_, photoSmall, photoBig, dcId):
|
||||
let smallResource: TelegramMediaResource
|
||||
let fullSizeResource: TelegramMediaResource
|
||||
switch photoSmall {
|
||||
@ -267,6 +275,15 @@ extension TelegramUser {
|
||||
case let .user(flags, id, accessHash, firstName, lastName, username, phone, photo, _, _, restrictionReason, botInlinePlaceholder, _):
|
||||
let representations: [TelegramMediaImageRepresentation] = photo.flatMap(parsedTelegramProfilePhoto) ?? []
|
||||
|
||||
let isMin = (flags & (1 << 20)) != 0
|
||||
let accessHashValue = accessHash.flatMap { value -> TelegramPeerAccessHash in
|
||||
if isMin {
|
||||
return .genericPublic(value)
|
||||
} else {
|
||||
return .personal(value)
|
||||
}
|
||||
}
|
||||
|
||||
var userFlags: UserInfoFlags = []
|
||||
if (flags & (1 << 17)) != 0 {
|
||||
userFlags.insert(.isVerified)
|
||||
@ -295,7 +312,7 @@ extension TelegramUser {
|
||||
|
||||
let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init)
|
||||
|
||||
self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: accessHash, 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: 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: [])
|
||||
}
|
||||
@ -303,7 +320,7 @@ extension TelegramUser {
|
||||
|
||||
static func merge(_ lhs: TelegramUser?, rhs: Api.User) -> TelegramUser? {
|
||||
switch rhs {
|
||||
case let .user(flags, _, _, _, _, username, _, photo, _, _, restrictionReason, botInlinePlaceholder, _):
|
||||
case let .user(flags, _, rhsAccessHash, _, _, username, _, photo, _, _, restrictionReason, botInlinePlaceholder, _):
|
||||
let isMin = (flags & (1 << 20)) != 0
|
||||
if !isMin {
|
||||
return TelegramUser(user: rhs)
|
||||
@ -338,7 +355,22 @@ extension TelegramUser {
|
||||
|
||||
let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init)
|
||||
|
||||
return TelegramUser(id: lhs.id, accessHash: lhs.accessHash, firstName: lhs.firstName, lastName: lhs.lastName, username: username, phone: lhs.phone, photo: telegramPhoto, botInfo: botInfo, restrictionInfo: restrictionInfo, flags: userFlags)
|
||||
let rhsAccessHashValue = rhsAccessHash.flatMap { value -> TelegramPeerAccessHash in
|
||||
if isMin {
|
||||
return .genericPublic(value)
|
||||
} else {
|
||||
return .personal(value)
|
||||
}
|
||||
}
|
||||
|
||||
let accessHash: TelegramPeerAccessHash?
|
||||
if let rhsAccessHashValue = rhsAccessHashValue, case .personal = rhsAccessHashValue {
|
||||
accessHash = rhsAccessHashValue
|
||||
} else {
|
||||
accessHash = lhs.accessHash ?? rhsAccessHashValue
|
||||
}
|
||||
|
||||
return TelegramUser(id: lhs.id, accessHash: accessHash, firstName: lhs.firstName, lastName: lhs.lastName, username: username, phone: lhs.phone, photo: telegramPhoto, botInfo: botInfo, restrictionInfo: restrictionInfo, flags: userFlags)
|
||||
} else {
|
||||
return TelegramUser(user: rhs)
|
||||
}
|
||||
|
||||
@ -58,23 +58,6 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
||||
|
||||
var displayInputTextPanel = false
|
||||
|
||||
/*if case .group = chatPresentationInterfaceState.chatLocation {
|
||||
if chatPresentationInterfaceState.interfaceState.editMessage != nil {
|
||||
displayInputTextPanel = true
|
||||
} else {
|
||||
if let currentPanel = currentPanel as? ChatFeedNavigationInputPanelNode {
|
||||
currentPanel.interfaceInteraction = interfaceInteraction
|
||||
currentPanel.updateThemeAndStrings(theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
||||
return currentPanel
|
||||
} else {
|
||||
let panel = ChatFeedNavigationInputPanelNode(theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
||||
panel.context = context
|
||||
panel.interfaceInteraction = interfaceInteraction
|
||||
return panel
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if let peer = chatPresentationInterfaceState.renderedPeer?.peer {
|
||||
if let secretChat = peer as? TelegramSecretChat {
|
||||
switch secretChat.embeddedState {
|
||||
@ -100,17 +83,7 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
||||
break
|
||||
}
|
||||
} else if let channel = peer as? TelegramChannel {
|
||||
if channel.hasBannedPermission(.banSendMessages) != nil {
|
||||
if let currentPanel = currentPanel as? ChatRestrictedInputPanelNode {
|
||||
return currentPanel
|
||||
} else {
|
||||
let panel = ChatRestrictedInputPanelNode()
|
||||
panel.context = context
|
||||
panel.interfaceInteraction = interfaceInteraction
|
||||
return panel
|
||||
}
|
||||
}
|
||||
|
||||
var isMember: Bool = false
|
||||
switch channel.participationStatus {
|
||||
case .kicked:
|
||||
if let currentPanel = currentPanel as? DeleteChatInputPanelNode {
|
||||
@ -121,9 +94,23 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
||||
panel.interfaceInteraction = interfaceInteraction
|
||||
return panel
|
||||
}
|
||||
case .member, .left:
|
||||
case .member:
|
||||
isMember = true
|
||||
case .left:
|
||||
break
|
||||
}
|
||||
|
||||
if isMember && channel.hasBannedPermission(.banSendMessages) != nil {
|
||||
if let currentPanel = currentPanel as? ChatRestrictedInputPanelNode {
|
||||
return currentPanel
|
||||
} else {
|
||||
let panel = ChatRestrictedInputPanelNode()
|
||||
panel.context = context
|
||||
panel.interfaceInteraction = interfaceInteraction
|
||||
return panel
|
||||
}
|
||||
}
|
||||
|
||||
switch channel.info {
|
||||
case .broadcast:
|
||||
if chatPresentationInterfaceState.interfaceState.editMessage != nil, channel.hasPermission(.editAllMessages) {
|
||||
|
||||
@ -23,7 +23,7 @@ func loadLegacyUser(database: SqliteInterface, id: Int32) -> (TelegramUser, Tele
|
||||
photo.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 600.0, height: 600.0), resource: resource))
|
||||
}
|
||||
|
||||
let user = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: cursor.getInt32(at: 0)), accessHash: accessHash == 0 ? nil : accessHash, firstName: firstName.isEmpty ? nil : firstName, lastName: lastName.isEmpty ? nil : lastName, username: username.isEmpty ? nil : username, phone: phone.isEmpty ? nil : phone, photo: photo, botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let user = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: cursor.getInt32(at: 0)), accessHash: accessHash == 0 ? nil : .personal(accessHash), firstName: firstName.isEmpty ? nil : firstName, lastName: lastName.isEmpty ? nil : lastName, username: username.isEmpty ? nil : username, phone: phone.isEmpty ? nil : phone, photo: photo, botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
|
||||
let status: UserPresenceStatus
|
||||
let lastSeen = cursor.getInt32(at: 7)
|
||||
|
||||
@ -338,6 +338,8 @@
|
||||
D03AA4DF202DBF6F0056C405 /* ChatContextResultPeekContentNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4DE202DBF6F0056C405 /* ChatContextResultPeekContentNode.swift */; };
|
||||
D03AA4E5202DF8840056C405 /* StickerPreviewPeekContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4E4202DF8840056C405 /* StickerPreviewPeekContent.swift */; };
|
||||
D03AA4E7202DFB160056C405 /* ItemListEditableReorderControlNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4E6202DFB160056C405 /* ItemListEditableReorderControlNode.swift */; };
|
||||
D03AE67322B9459C0078411C /* HockeySDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D03AE67222B9459C0078411C /* HockeySDK.framework */; };
|
||||
D03AE67522B945D30078411C /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D03AE67422B945D30078411C /* BuildConfig.framework */; };
|
||||
D04203152037162700490EA5 /* MediaInputPaneTrendingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04203142037162700490EA5 /* MediaInputPaneTrendingItem.swift */; };
|
||||
D04281ED200E3B28009DDE36 /* ItemListControllerSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281EC200E3B28009DDE36 /* ItemListControllerSearch.swift */; };
|
||||
D04281EF200E3D88009DDE36 /* GroupInfoSearchItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281EE200E3D88009DDE36 /* GroupInfoSearchItem.swift */; };
|
||||
@ -1611,6 +1613,8 @@
|
||||
D03ADB4A1D70443F005A521C /* ReplyAccessoryPanelNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplyAccessoryPanelNode.swift; sourceTree = "<group>"; };
|
||||
D03ADB4C1D7045C9005A521C /* ChatInterfaceStateAccessoryPanels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatInterfaceStateAccessoryPanels.swift; sourceTree = "<group>"; };
|
||||
D03ADB4E1D70546B005A521C /* AccessoryPanelNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccessoryPanelNode.swift; sourceTree = "<group>"; };
|
||||
D03AE67222B9459C0078411C /* HockeySDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = HockeySDK.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D03AE67422B945D30078411C /* BuildConfig.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = BuildConfig.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D03E5E081E55C49C0029569A /* DebugAccountsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebugAccountsController.swift; sourceTree = "<group>"; };
|
||||
D03E5E0E1E55F8B90029569A /* ChannelVisibilityController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChannelVisibilityController.swift; sourceTree = "<group>"; };
|
||||
D04203142037162700490EA5 /* MediaInputPaneTrendingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaInputPaneTrendingItem.swift; sourceTree = "<group>"; };
|
||||
@ -2395,6 +2399,8 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D03AE67522B945D30078411C /* BuildConfig.framework in Frameworks */,
|
||||
D03AE67322B9459C0078411C /* HockeySDK.framework in Frameworks */,
|
||||
D02D634A22B85B94006BE519 /* PushKit.framework in Frameworks */,
|
||||
D00818CD22B595CB008A895F /* LightweightAccountData.framework in Frameworks */,
|
||||
D008184A22B57225008A895F /* WatchCommon.framework in Frameworks */,
|
||||
@ -3514,6 +3520,8 @@
|
||||
D08D45281D5E340200A7428A /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D03AE67422B945D30078411C /* BuildConfig.framework */,
|
||||
D03AE67222B9459C0078411C /* HockeySDK.framework */,
|
||||
D02D634922B85B94006BE519 /* PushKit.framework */,
|
||||
D00818CC22B595CB008A895F /* LightweightAccountData.framework */,
|
||||
D008184922B57225008A895F /* WatchCommon.framework */,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user