mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +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 */; };
|
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, ); }; };
|
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 */; };
|
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 */; };
|
D008185022B5797A008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008184F22B5797A008A895F /* BuildConfig.framework */; };
|
||||||
D008185222B57986008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008185122B57986008A895F /* BuildConfig.framework */; };
|
D008185222B57986008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008185122B57986008A895F /* BuildConfig.framework */; };
|
||||||
D008185422B57994008A895F /* BuildConfig.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D008185322B57994008A895F /* 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, ); }; };
|
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 */; };
|
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, ); }; };
|
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 */; };
|
D021D4D9219CAEDD0064BEBA /* Config-Fork.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = D021D4D8219CAEDD0064BEBA /* Config-Fork.xcconfig */; };
|
||||||
D02CF5FD215D9ABF00E0F56A /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0AA1A671D568BA400152314 /* UserNotifications.framework */; };
|
D02CF5FD215D9ABF00E0F56A /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0AA1A671D568BA400152314 /* UserNotifications.framework */; };
|
||||||
D02CF5FE215D9ABF00E0F56A /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0AA1A691D568BA400152314 /* UserNotificationsUI.framework */; };
|
D02CF5FE215D9ABF00E0F56A /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0AA1A691D568BA400152314 /* UserNotificationsUI.framework */; };
|
||||||
@ -1099,11 +1097,9 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
D008184E22B5796E008A895F /* BuildConfig.framework in Frameworks */,
|
|
||||||
D0CAD6A421C03BEB001E3055 /* FFMpeg.framework in Frameworks */,
|
D0CAD6A421C03BEB001E3055 /* FFMpeg.framework in Frameworks */,
|
||||||
09C50E88217385CF009E676F /* WatchConnectivity.framework in Frameworks */,
|
09C50E88217385CF009E676F /* WatchConnectivity.framework in Frameworks */,
|
||||||
09FDAEE62140477F00BF856F /* MtProtoKitDynamic.framework in Frameworks */,
|
09FDAEE62140477F00BF856F /* MtProtoKitDynamic.framework in Frameworks */,
|
||||||
D01A47551F4DBED700383CC1 /* HockeySDK.framework in Frameworks */,
|
|
||||||
D0A18D631E149043004C6734 /* PushKit.framework in Frameworks */,
|
D0A18D631E149043004C6734 /* PushKit.framework in Frameworks */,
|
||||||
D0B844601DACF561005F29E1 /* libc++.tbd in Frameworks */,
|
D0B844601DACF561005F29E1 /* libc++.tbd in Frameworks */,
|
||||||
D06706621D5118F500DED3E3 /* TelegramCore.framework in Frameworks */,
|
D06706621D5118F500DED3E3 /* TelegramCore.framework in Frameworks */,
|
||||||
|
|||||||
@ -32,87 +32,95 @@ func imageRepresentationsForApiChatPhoto(_ photo: Api.ChatPhoto) -> [TelegramMed
|
|||||||
|
|
||||||
func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||||
switch chat {
|
switch chat {
|
||||||
case let .chat(flags, id, title, photo, participantsCount, date, version, migratedTo, adminRights, defaultBannedRights):
|
case let .chat(flags, id, title, photo, participantsCount, date, version, migratedTo, adminRights, defaultBannedRights):
|
||||||
let left = (flags & ((1 << 1) | (1 << 2))) != 0
|
let left = (flags & ((1 << 1) | (1 << 2))) != 0
|
||||||
var migrationReference: TelegramGroupToChannelMigrationReference?
|
var migrationReference: TelegramGroupToChannelMigrationReference?
|
||||||
if let migratedTo = migratedTo {
|
if let migratedTo = migratedTo {
|
||||||
switch migratedTo {
|
switch migratedTo {
|
||||||
case let .inputChannel(channelId, accessHash):
|
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: channelId), accessHash: accessHash)
|
||||||
case .inputChannelEmpty:
|
case .inputChannelEmpty:
|
||||||
break
|
break
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var groupFlags = TelegramGroupFlags()
|
}
|
||||||
var role: TelegramGroupRole = .member
|
var groupFlags = TelegramGroupFlags()
|
||||||
if (flags & (1 << 0)) != 0 {
|
var role: TelegramGroupRole = .member
|
||||||
role = .creator
|
if (flags & (1 << 0)) != 0 {
|
||||||
} else if let adminRights = adminRights {
|
role = .creator
|
||||||
role = .admin(TelegramChatAdminRights(apiAdminRights: adminRights))
|
} else if let adminRights = adminRights {
|
||||||
|
role = .admin(TelegramChatAdminRights(apiAdminRights: adminRights))
|
||||||
|
}
|
||||||
|
if (flags & (1 << 5)) != 0 {
|
||||||
|
groupFlags.insert(.deactivated)
|
||||||
|
}
|
||||||
|
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))
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, defaultBannedRights, _):
|
||||||
|
let isMin = (flags & (1 << 20)) != 0
|
||||||
|
|
||||||
|
let participationStatus: TelegramChannelParticipationStatus
|
||||||
|
if (flags & Int32(1 << 1)) != 0 {
|
||||||
|
participationStatus = .kicked
|
||||||
|
} else if (flags & Int32(1 << 2)) != 0 {
|
||||||
|
participationStatus = .left
|
||||||
|
} else {
|
||||||
|
participationStatus = .member
|
||||||
|
}
|
||||||
|
|
||||||
|
let info: TelegramChannelInfo
|
||||||
|
if (flags & Int32(1 << 8)) != 0 {
|
||||||
|
let infoFlags = TelegramChannelGroupFlags()
|
||||||
|
info = .group(TelegramChannelGroupInfo(flags: infoFlags))
|
||||||
|
} else {
|
||||||
|
var infoFlags = TelegramChannelBroadcastFlags()
|
||||||
|
if (flags & Int32(1 << 11)) != 0 {
|
||||||
|
infoFlags.insert(.messagesShouldHaveSignatures)
|
||||||
}
|
}
|
||||||
if (flags & (1 << 5)) != 0 {
|
if (flags & Int32(1 << 20)) != 0 {
|
||||||
groupFlags.insert(.deactivated)
|
infoFlags.insert(.hasDiscussionGroup)
|
||||||
}
|
}
|
||||||
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))
|
info = .broadcast(TelegramChannelBroadcastInfo(flags: infoFlags))
|
||||||
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)
|
|
||||||
case let .chatForbidden(id, title):
|
var channelFlags = TelegramChannelFlags()
|
||||||
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)
|
if (flags & Int32(1 << 0)) != 0 {
|
||||||
case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, defaultBannedRights, _):
|
channelFlags.insert(.isCreator)
|
||||||
let isMin = (flags & (1 << 20)) != 0
|
}
|
||||||
|
if (flags & Int32(1 << 7)) != 0 {
|
||||||
let participationStatus: TelegramChannelParticipationStatus
|
channelFlags.insert(.isVerified)
|
||||||
if (flags & Int32(1 << 1)) != 0 {
|
}
|
||||||
participationStatus = .kicked
|
if (flags & Int32(1 << 19)) != 0 {
|
||||||
} else if (flags & Int32(1 << 2)) != 0 {
|
channelFlags.insert(.isScam)
|
||||||
participationStatus = .left
|
}
|
||||||
|
|
||||||
|
let restrictionInfo: PeerAccessRestrictionInfo?
|
||||||
|
if let restrictionReason = restrictionReason {
|
||||||
|
restrictionInfo = PeerAccessRestrictionInfo(reason: restrictionReason)
|
||||||
|
} else {
|
||||||
|
restrictionInfo = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
let accessHashValue = accessHash.flatMap { value -> TelegramPeerAccessHash in
|
||||||
|
if isMin {
|
||||||
|
return .genericPublic(value)
|
||||||
} else {
|
} else {
|
||||||
participationStatus = .member
|
return .personal(value)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
let info: TelegramChannelInfo
|
|
||||||
if (flags & Int32(1 << 8)) != 0 {
|
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))
|
||||||
let infoFlags = TelegramChannelGroupFlags()
|
case let .channelForbidden(flags, id, accessHash, title, untilDate):
|
||||||
info = .group(TelegramChannelGroupInfo(flags: infoFlags))
|
let info: TelegramChannelInfo
|
||||||
} else {
|
if (flags & Int32(1 << 8)) != 0 {
|
||||||
var infoFlags = TelegramChannelBroadcastFlags()
|
info = .group(TelegramChannelGroupInfo(flags: []))
|
||||||
if (flags & Int32(1 << 11)) != 0 {
|
} else {
|
||||||
infoFlags.insert(.messagesShouldHaveSignatures)
|
info = .broadcast(TelegramChannelBroadcastInfo(flags: []))
|
||||||
}
|
}
|
||||||
if (flags & Int32(1 << 20)) != 0 {
|
|
||||||
infoFlags.insert(.hasDiscussionGroup)
|
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)
|
||||||
}
|
|
||||||
info = .broadcast(TelegramChannelBroadcastInfo(flags: infoFlags))
|
|
||||||
}
|
|
||||||
|
|
||||||
var channelFlags = TelegramChannelFlags()
|
|
||||||
if (flags & Int32(1 << 0)) != 0 {
|
|
||||||
channelFlags.insert(.isCreator)
|
|
||||||
}
|
|
||||||
if (flags & Int32(1 << 7)) != 0 {
|
|
||||||
channelFlags.insert(.isVerified)
|
|
||||||
}
|
|
||||||
if (flags & Int32(1 << 19)) != 0 {
|
|
||||||
channelFlags.insert(.isScam)
|
|
||||||
}
|
|
||||||
|
|
||||||
let restrictionInfo: PeerAccessRestrictionInfo?
|
|
||||||
if let restrictionReason = restrictionReason {
|
|
||||||
restrictionInfo = PeerAccessRestrictionInfo(reason: restrictionReason)
|
|
||||||
} else {
|
|
||||||
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))
|
|
||||||
case let .channelForbidden(flags, id, accessHash, title, untilDate):
|
|
||||||
let info: TelegramChannelInfo
|
|
||||||
if (flags & Int32(1 << 8)) != 0 {
|
|
||||||
info = .group(TelegramChannelGroupInfo(flags: []))
|
|
||||||
} else {
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +129,8 @@ func mergeGroupOrChannel(lhs: Peer?, rhs: Api.Chat) -> Peer? {
|
|||||||
case .chat, .chatEmpty, .chatForbidden, .channelForbidden:
|
case .chat, .chatEmpty, .chatForbidden, .channelForbidden:
|
||||||
return parseTelegramGroupOrChannel(chat: rhs)
|
return parseTelegramGroupOrChannel(chat: rhs)
|
||||||
case let .channel(flags, _, accessHash, title, username, photo, _, _, _, _, _, defaultBannedRights, _/*feed*//*, feedId*/):
|
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)
|
return parseTelegramGroupOrChannel(chat: rhs)
|
||||||
} else if let lhs = lhs as? TelegramChannel {
|
} else if let lhs = lhs as? TelegramChannel {
|
||||||
var channelFlags = lhs.flags
|
var channelFlags = lhs.flags
|
||||||
@ -132,11 +141,11 @@ func mergeGroupOrChannel(lhs: Peer?, rhs: Api.Chat) -> Peer? {
|
|||||||
}
|
}
|
||||||
var info = lhs.info
|
var info = lhs.info
|
||||||
switch info {
|
switch info {
|
||||||
case .broadcast:
|
case .broadcast:
|
||||||
break
|
break
|
||||||
case .group:
|
case .group:
|
||||||
let infoFlags = TelegramChannelGroupFlags()
|
let infoFlags = TelegramChannelGroupFlags()
|
||||||
info = .group(TelegramChannelGroupInfo(flags: infoFlags))
|
info = .group(TelegramChannelGroupInfo(flags: infoFlags))
|
||||||
}
|
}
|
||||||
return TelegramChannel(id: lhs.id, accessHash: lhs.accessHash, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: lhs.creationDate, version: lhs.version, participationStatus: lhs.participationStatus, info: info, flags: channelFlags, restrictionInfo: lhs.restrictionInfo, adminRights: lhs.adminRights, bannedRights: lhs.bannedRights, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init))
|
return TelegramChannel(id: lhs.id, accessHash: lhs.accessHash, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: lhs.creationDate, version: lhs.version, participationStatus: lhs.participationStatus, info: info, flags: channelFlags, restrictionInfo: lhs.restrictionInfo, adminRights: lhs.adminRights, bannedRights: lhs.bannedRights, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable {
|
|||||||
switch peer {
|
switch peer {
|
||||||
case let user as TelegramUser:
|
case let user as TelegramUser:
|
||||||
if let accessHash = user.accessHash {
|
if let accessHash = user.accessHash {
|
||||||
self = .user(id: user.id.id, accessHash: accessHash)
|
self = .user(id: user.id.id, accessHash: accessHash.value)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable {
|
|||||||
self = .group(id: group.id.id)
|
self = .group(id: group.id.id)
|
||||||
case let channel as TelegramChannel:
|
case let channel as TelegramChannel:
|
||||||
if let accessHash = channel.accessHash {
|
if let accessHash = channel.accessHash {
|
||||||
self = .channel(id: channel.id.id, accessHash: accessHash)
|
self = .channel(id: channel.id.id, accessHash: accessHash.value)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -104,12 +104,12 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable {
|
|||||||
func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
||||||
switch peer {
|
switch peer {
|
||||||
case let user as TelegramUser:
|
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:
|
case let group as TelegramGroup:
|
||||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
||||||
case let channel as TelegramChannel:
|
case let channel as TelegramChannel:
|
||||||
if let accessHash = channel.accessHash {
|
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 {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -121,12 +121,12 @@ func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
|||||||
func apiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
func apiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
||||||
switch peer {
|
switch peer {
|
||||||
case let user as TelegramUser where user.accessHash != nil:
|
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:
|
case let group as TelegramGroup:
|
||||||
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
||||||
case let channel as TelegramChannel:
|
case let channel as TelegramChannel:
|
||||||
if let accessHash = channel.accessHash {
|
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 {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ func apiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
|||||||
|
|
||||||
func apiInputChannel(_ peer: Peer) -> Api.InputChannel? {
|
func apiInputChannel(_ peer: Peer) -> Api.InputChannel? {
|
||||||
if let channel = peer as? TelegramChannel, let accessHash = channel.accessHash {
|
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 {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ func apiInputChannel(_ peer: Peer) -> Api.InputChannel? {
|
|||||||
|
|
||||||
func apiInputUser(_ peer: Peer) -> Api.InputUser? {
|
func apiInputUser(_ peer: Peer) -> Api.InputUser? {
|
||||||
if let user = peer as? TelegramUser, let accessHash = user.accessHash {
|
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 {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ public func loadedPeerFromMessage(account: Account, peerId: PeerId, messageId: M
|
|||||||
return account.postbox.transaction { transaction -> Signal<Peer?, NoError> in
|
return account.postbox.transaction { transaction -> Signal<Peer?, NoError> in
|
||||||
if let peer = transaction.getPeer(peerId) {
|
if let peer = transaction.getPeer(peerId) {
|
||||||
if let user = peer as? TelegramUser {
|
if let user = peer as? TelegramUser {
|
||||||
if user.accessHash != 0 {
|
if let accessHash = user.accessHash, accessHash.value != 0 {
|
||||||
return .single(user)
|
return .single(user)
|
||||||
} else {
|
} else {
|
||||||
let messageSignal: Signal<Api.messages.Messages?, NoError>?
|
let messageSignal: Signal<Api.messages.Messages?, NoError>?
|
||||||
@ -50,7 +50,7 @@ public func loadedPeerFromMessage(account: Account, peerId: PeerId, messageId: M
|
|||||||
|
|
||||||
for user in apiUsers {
|
for user in apiUsers {
|
||||||
let telegramUser = TelegramUser(user: user)
|
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) {
|
if let presence = TelegramUserPresence(apiUser: user) {
|
||||||
updatePeerPresences(transaction: transaction, accountPeerId: account.peerId, peerPresences: [telegramUser.id: presence])
|
updatePeerPresences(transaction: transaction, accountPeerId: account.peerId, peerPresences: [telegramUser.id: presence])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,4 +3,13 @@ import Foundation
|
|||||||
public enum TelegramPeerAccessHash: Hashable {
|
public enum TelegramPeerAccessHash: Hashable {
|
||||||
case personal(Int64)
|
case personal(Int64)
|
||||||
case genericPublic(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 final class TelegramChannel: Peer {
|
||||||
public let id: PeerId
|
public let id: PeerId
|
||||||
public let accessHash: Int64?
|
public let accessHash: TelegramPeerAccessHash?
|
||||||
public let title: String
|
public let title: String
|
||||||
public let username: String?
|
public let username: String?
|
||||||
public let photo: [TelegramMediaImageRepresentation]
|
public let photo: [TelegramMediaImageRepresentation]
|
||||||
@ -169,7 +169,7 @@ public final class TelegramChannel: Peer {
|
|||||||
public let associatedPeerId: PeerId? = nil
|
public let associatedPeerId: PeerId? = nil
|
||||||
public let notificationSettingsPeerId: 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.id = id
|
||||||
self.accessHash = accessHash
|
self.accessHash = accessHash
|
||||||
self.title = title
|
self.title = title
|
||||||
@ -188,7 +188,17 @@ public final class TelegramChannel: Peer {
|
|||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
self.id = PeerId(decoder.decodeInt64ForKey("i", orElse: 0))
|
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.title = decoder.decodeStringForKey("t", orElse: "")
|
||||||
self.username = decoder.decodeOptionalStringForKey("un")
|
self.username = decoder.decodeOptionalStringForKey("un")
|
||||||
self.photo = decoder.decodeObjectArrayForKey("ph")
|
self.photo = decoder.decodeObjectArrayForKey("ph")
|
||||||
@ -206,7 +216,14 @@ public final class TelegramChannel: Peer {
|
|||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
encoder.encodeInt64(self.id.toInt64(), forKey: "i")
|
encoder.encodeInt64(self.id.toInt64(), forKey: "i")
|
||||||
if let accessHash = self.accessHash {
|
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 {
|
} else {
|
||||||
encoder.encodeNil(forKey: "ah")
|
encoder.encodeNil(forKey: "ah")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,15 +61,11 @@ public struct BotUserInfo: PostboxCoding, Equatable {
|
|||||||
encoder.encodeNil(forKey: "ip")
|
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 final class TelegramUser: Peer {
|
||||||
public let id: PeerId
|
public let id: PeerId
|
||||||
public let accessHash: Int64?
|
public let accessHash: TelegramPeerAccessHash?
|
||||||
public let firstName: String?
|
public let firstName: String?
|
||||||
public let lastName: String?
|
public let lastName: String?
|
||||||
public let username: String?
|
public let username: String?
|
||||||
@ -100,7 +96,7 @@ public final class TelegramUser: Peer {
|
|||||||
public let associatedPeerId: PeerId? = nil
|
public let associatedPeerId: PeerId? = nil
|
||||||
public let notificationSettingsPeerId: 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.id = id
|
||||||
self.accessHash = accessHash
|
self.accessHash = accessHash
|
||||||
self.firstName = firstName
|
self.firstName = firstName
|
||||||
@ -117,8 +113,13 @@ public final class TelegramUser: Peer {
|
|||||||
self.id = PeerId(decoder.decodeInt64ForKey("i", orElse: 0))
|
self.id = PeerId(decoder.decodeInt64ForKey("i", orElse: 0))
|
||||||
|
|
||||||
let accessHash: Int64 = decoder.decodeInt64ForKey("ah", orElse: 0)
|
let accessHash: Int64 = decoder.decodeInt64ForKey("ah", orElse: 0)
|
||||||
|
let accessHashType: Int32 = decoder.decodeInt32ForKey("aht", orElse: 0)
|
||||||
if accessHash != 0 {
|
if accessHash != 0 {
|
||||||
self.accessHash = accessHash
|
if accessHashType == 0 {
|
||||||
|
self.accessHash = .personal(accessHash)
|
||||||
|
} else {
|
||||||
|
self.accessHash = .genericPublic(accessHash)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.accessHash = nil
|
self.accessHash = nil
|
||||||
}
|
}
|
||||||
@ -146,7 +147,14 @@ public final class TelegramUser: Peer {
|
|||||||
encoder.encodeInt64(self.id.toInt64(), forKey: "i")
|
encoder.encodeInt64(self.id.toInt64(), forKey: "i")
|
||||||
|
|
||||||
if let accessHash = self.accessHash {
|
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 {
|
if let firstName = self.firstName {
|
||||||
@ -242,7 +250,7 @@ public final class TelegramUser: Peer {
|
|||||||
func parsedTelegramProfilePhoto(_ photo: Api.UserProfilePhoto) -> [TelegramMediaImageRepresentation] {
|
func parsedTelegramProfilePhoto(_ photo: Api.UserProfilePhoto) -> [TelegramMediaImageRepresentation] {
|
||||||
var representations: [TelegramMediaImageRepresentation] = []
|
var representations: [TelegramMediaImageRepresentation] = []
|
||||||
switch photo {
|
switch photo {
|
||||||
case let .userProfilePhoto(photoId, photoSmall, photoBig, dcId):
|
case let .userProfilePhoto(_, photoSmall, photoBig, dcId):
|
||||||
let smallResource: TelegramMediaResource
|
let smallResource: TelegramMediaResource
|
||||||
let fullSizeResource: TelegramMediaResource
|
let fullSizeResource: TelegramMediaResource
|
||||||
switch photoSmall {
|
switch photoSmall {
|
||||||
@ -267,6 +275,15 @@ extension TelegramUser {
|
|||||||
case let .user(flags, id, accessHash, firstName, lastName, username, phone, photo, _, _, restrictionReason, botInlinePlaceholder, _):
|
case let .user(flags, id, accessHash, firstName, lastName, username, phone, photo, _, _, restrictionReason, botInlinePlaceholder, _):
|
||||||
let representations: [TelegramMediaImageRepresentation] = photo.flatMap(parsedTelegramProfilePhoto) ?? []
|
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 = []
|
var userFlags: UserInfoFlags = []
|
||||||
if (flags & (1 << 17)) != 0 {
|
if (flags & (1 << 17)) != 0 {
|
||||||
userFlags.insert(.isVerified)
|
userFlags.insert(.isVerified)
|
||||||
@ -295,7 +312,7 @@ extension TelegramUser {
|
|||||||
|
|
||||||
let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init)
|
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):
|
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: 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? {
|
static func merge(_ lhs: TelegramUser?, rhs: Api.User) -> TelegramUser? {
|
||||||
switch rhs {
|
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
|
let isMin = (flags & (1 << 20)) != 0
|
||||||
if !isMin {
|
if !isMin {
|
||||||
return TelegramUser(user: rhs)
|
return TelegramUser(user: rhs)
|
||||||
@ -338,7 +355,22 @@ extension TelegramUser {
|
|||||||
|
|
||||||
let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init)
|
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 {
|
} else {
|
||||||
return TelegramUser(user: rhs)
|
return TelegramUser(user: rhs)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,23 +58,6 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
|||||||
|
|
||||||
var displayInputTextPanel = false
|
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 peer = chatPresentationInterfaceState.renderedPeer?.peer {
|
||||||
if let secretChat = peer as? TelegramSecretChat {
|
if let secretChat = peer as? TelegramSecretChat {
|
||||||
switch secretChat.embeddedState {
|
switch secretChat.embeddedState {
|
||||||
@ -100,7 +83,24 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if let channel = peer as? TelegramChannel {
|
} else if let channel = peer as? TelegramChannel {
|
||||||
if channel.hasBannedPermission(.banSendMessages) != nil {
|
var isMember: Bool = false
|
||||||
|
switch channel.participationStatus {
|
||||||
|
case .kicked:
|
||||||
|
if let currentPanel = currentPanel as? DeleteChatInputPanelNode {
|
||||||
|
return currentPanel
|
||||||
|
} else {
|
||||||
|
let panel = DeleteChatInputPanelNode()
|
||||||
|
panel.context = context
|
||||||
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
|
return panel
|
||||||
|
}
|
||||||
|
case .member:
|
||||||
|
isMember = true
|
||||||
|
case .left:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if isMember && channel.hasBannedPermission(.banSendMessages) != nil {
|
||||||
if let currentPanel = currentPanel as? ChatRestrictedInputPanelNode {
|
if let currentPanel = currentPanel as? ChatRestrictedInputPanelNode {
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
@ -111,61 +111,48 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch channel.participationStatus {
|
switch channel.info {
|
||||||
case .kicked:
|
case .broadcast:
|
||||||
if let currentPanel = currentPanel as? DeleteChatInputPanelNode {
|
if chatPresentationInterfaceState.interfaceState.editMessage != nil, channel.hasPermission(.editAllMessages) {
|
||||||
|
displayInputTextPanel = true
|
||||||
|
} else if !channel.hasPermission(.sendMessages) {
|
||||||
|
if let currentPanel = currentPanel as? ChatChannelSubscriberInputPanelNode {
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = DeleteChatInputPanelNode()
|
let panel = ChatChannelSubscriberInputPanelNode()
|
||||||
panel.context = context
|
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
|
panel.context = context
|
||||||
return panel
|
return panel
|
||||||
}
|
}
|
||||||
case .member, .left:
|
}
|
||||||
|
case .group:
|
||||||
|
switch channel.participationStatus {
|
||||||
|
case .kicked, .left:
|
||||||
|
if let currentPanel = currentPanel as? ChatChannelSubscriberInputPanelNode {
|
||||||
|
return currentPanel
|
||||||
|
} else {
|
||||||
|
let panel = ChatChannelSubscriberInputPanelNode()
|
||||||
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
|
panel.context = context
|
||||||
|
return panel
|
||||||
|
}
|
||||||
|
case .member:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch channel.info {
|
|
||||||
case .broadcast:
|
|
||||||
if chatPresentationInterfaceState.interfaceState.editMessage != nil, channel.hasPermission(.editAllMessages) {
|
|
||||||
displayInputTextPanel = true
|
|
||||||
} else if !channel.hasPermission(.sendMessages) {
|
|
||||||
if let currentPanel = currentPanel as? ChatChannelSubscriberInputPanelNode {
|
|
||||||
return currentPanel
|
|
||||||
} else {
|
|
||||||
let panel = ChatChannelSubscriberInputPanelNode()
|
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
|
||||||
panel.context = context
|
|
||||||
return panel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case .group:
|
|
||||||
switch channel.participationStatus {
|
|
||||||
case .kicked, .left:
|
|
||||||
if let currentPanel = currentPanel as? ChatChannelSubscriberInputPanelNode {
|
|
||||||
return currentPanel
|
|
||||||
} else {
|
|
||||||
let panel = ChatChannelSubscriberInputPanelNode()
|
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
|
||||||
panel.context = context
|
|
||||||
return panel
|
|
||||||
}
|
|
||||||
case .member:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if let group = peer as? TelegramGroup {
|
} else if let group = peer as? TelegramGroup {
|
||||||
switch group.membership {
|
switch group.membership {
|
||||||
case .Removed, .Left:
|
case .Removed, .Left:
|
||||||
if let currentPanel = currentPanel as? DeleteChatInputPanelNode {
|
if let currentPanel = currentPanel as? DeleteChatInputPanelNode {
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = DeleteChatInputPanelNode()
|
let panel = DeleteChatInputPanelNode()
|
||||||
panel.context = context
|
panel.context = context
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
return panel
|
return panel
|
||||||
}
|
}
|
||||||
case .Member:
|
case .Member:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if group.hasBannedPermission(.banSendMessages) {
|
if group.hasBannedPermission(.banSendMessages) {
|
||||||
|
|||||||
@ -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))
|
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 status: UserPresenceStatus
|
||||||
let lastSeen = cursor.getInt32(at: 7)
|
let lastSeen = cursor.getInt32(at: 7)
|
||||||
|
|||||||
@ -338,6 +338,8 @@
|
|||||||
D03AA4DF202DBF6F0056C405 /* ChatContextResultPeekContentNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4DE202DBF6F0056C405 /* ChatContextResultPeekContentNode.swift */; };
|
D03AA4DF202DBF6F0056C405 /* ChatContextResultPeekContentNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4DE202DBF6F0056C405 /* ChatContextResultPeekContentNode.swift */; };
|
||||||
D03AA4E5202DF8840056C405 /* StickerPreviewPeekContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4E4202DF8840056C405 /* StickerPreviewPeekContent.swift */; };
|
D03AA4E5202DF8840056C405 /* StickerPreviewPeekContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4E4202DF8840056C405 /* StickerPreviewPeekContent.swift */; };
|
||||||
D03AA4E7202DFB160056C405 /* ItemListEditableReorderControlNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D03AA4E6202DFB160056C405 /* ItemListEditableReorderControlNode.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 */; };
|
D04203152037162700490EA5 /* MediaInputPaneTrendingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04203142037162700490EA5 /* MediaInputPaneTrendingItem.swift */; };
|
||||||
D04281ED200E3B28009DDE36 /* ItemListControllerSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281EC200E3B28009DDE36 /* ItemListControllerSearch.swift */; };
|
D04281ED200E3B28009DDE36 /* ItemListControllerSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281EC200E3B28009DDE36 /* ItemListControllerSearch.swift */; };
|
||||||
D04281EF200E3D88009DDE36 /* GroupInfoSearchItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281EE200E3D88009DDE36 /* GroupInfoSearchItem.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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
D04203142037162700490EA5 /* MediaInputPaneTrendingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaInputPaneTrendingItem.swift; sourceTree = "<group>"; };
|
||||||
@ -2395,6 +2399,8 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
D03AE67522B945D30078411C /* BuildConfig.framework in Frameworks */,
|
||||||
|
D03AE67322B9459C0078411C /* HockeySDK.framework in Frameworks */,
|
||||||
D02D634A22B85B94006BE519 /* PushKit.framework in Frameworks */,
|
D02D634A22B85B94006BE519 /* PushKit.framework in Frameworks */,
|
||||||
D00818CD22B595CB008A895F /* LightweightAccountData.framework in Frameworks */,
|
D00818CD22B595CB008A895F /* LightweightAccountData.framework in Frameworks */,
|
||||||
D008184A22B57225008A895F /* WatchCommon.framework in Frameworks */,
|
D008184A22B57225008A895F /* WatchCommon.framework in Frameworks */,
|
||||||
@ -3514,6 +3520,8 @@
|
|||||||
D08D45281D5E340200A7428A /* Frameworks */ = {
|
D08D45281D5E340200A7428A /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
D03AE67422B945D30078411C /* BuildConfig.framework */,
|
||||||
|
D03AE67222B9459C0078411C /* HockeySDK.framework */,
|
||||||
D02D634922B85B94006BE519 /* PushKit.framework */,
|
D02D634922B85B94006BE519 /* PushKit.framework */,
|
||||||
D00818CC22B595CB008A895F /* LightweightAccountData.framework */,
|
D00818CC22B595CB008A895F /* LightweightAccountData.framework */,
|
||||||
D008184922B57225008A895F /* WatchCommon.framework */,
|
D008184922B57225008A895F /* WatchCommon.framework */,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user