diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index cb10455f34..0b130b4cb9 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -205,7 +205,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { } switch action { - case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionAttachMenuBotAllowed, .messageActionRequestedPeer: + case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionAttachMenuBotAllowed: break case let .messageActionChannelMigrateFrom(_, chatId): result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))) @@ -230,6 +230,8 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { for id in userIds { result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))) } + case let .messageActionRequestedPeer(_, peer): + result.append(peer.peerId) } return result diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift index fb060d8df3..09f9611cd8 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift @@ -53,7 +53,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { case botAdminRights = "br" } - public var isCreator: Bool? + public var isCreator: Bool public var hasUsername: Bool? public var isForum: Bool? public var botParticipant: Bool @@ -61,7 +61,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { public var botAdminRights: TelegramChatAdminRights? public init( - isCreator: Bool?, + isCreator: Bool, hasUsername: Bool?, isForum: Bool?, botParticipant: Bool, @@ -79,7 +79,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.isCreator = try container.decodeIfPresent(Bool.self, forKey: .isCreator) + self.isCreator = try container.decode(Bool.self, forKey: .isCreator) self.hasUsername = try container.decodeIfPresent(Bool.self, forKey: .hasUsername) self.isForum = try container.decodeIfPresent(Bool.self, forKey: .isForum) self.botParticipant = try container.decode(Bool.self, forKey: .botParticipant) @@ -90,7 +90,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.isCreator, forKey: .isCreator) + try container.encode(self.isCreator, forKey: .isCreator) try container.encodeIfPresent(self.hasUsername, forKey: .hasUsername) try container.encodeIfPresent(self.isForum, forKey: .isForum) try container.encode(self.botParticipant, forKey: .botParticipant) @@ -107,13 +107,13 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { case botAdminRights = "br" } - public var isCreator: Bool? + public var isCreator: Bool public var hasUsername: Bool? public var userAdminRights: TelegramChatAdminRights? public var botAdminRights: TelegramChatAdminRights? public init( - isCreator: Bool?, + isCreator: Bool, hasUsername: Bool?, userAdminRights: TelegramChatAdminRights?, botAdminRights: TelegramChatAdminRights? @@ -127,7 +127,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.isCreator = try container.decodeIfPresent(Bool.self, forKey: .isCreator) + self.isCreator = try container.decode(Bool.self, forKey: .isCreator) self.hasUsername = try container.decodeIfPresent(Bool.self, forKey: .hasUsername) self.userAdminRights = try container.decodeIfPresent(TelegramChatAdminRights.self, forKey: .userAdminRights) self.botAdminRights = try container.decodeIfPresent(TelegramChatAdminRights.self, forKey: .botAdminRights) @@ -136,7 +136,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.isCreator, forKey: .isCreator) + try container.encode(self.isCreator, forKey: .isCreator) try container.encodeIfPresent(self.hasUsername, forKey: .hasUsername) try container.encodeIfPresent(self.userAdminRights, forKey: .userAdminRights) try container.encodeIfPresent(self.botAdminRights, forKey: .botAdminRights) diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift index 6c70c97153..2f13e42a94 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift @@ -357,6 +357,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { return [from, to] case let .inviteToGroupPhoneCall(_, _, peerIds): return peerIds + case let .requestedPeer(_, peerId): + return [peerId] default: return [] } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelCreation.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelCreation.swift index 12ba575b96..74085fc056 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelCreation.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelCreation.swift @@ -12,7 +12,7 @@ public enum CreateChannelError { case serverProvided(String) } -private func createChannel(account: Account, title: String, description: String?, isSupergroup:Bool, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal { +private func createChannel(account: Account, title: String, description: String?, isSupergroup:Bool, location: (latitude: Double, longitude: Double, address: String)? = nil, isForum: Bool = false, isForHistoryImport: Bool = false) -> Signal { return account.postbox.transaction { transaction -> Signal in var flags: Int32 = 0 if isSupergroup { @@ -23,6 +23,9 @@ private func createChannel(account: Account, title: String, description: String? if isForHistoryImport { flags |= (1 << 3) } + if isForum { + flags |= (1 << 5) + } var geoPoint: Api.InputGeoPoint? var address: String? @@ -85,8 +88,8 @@ func _internal_createChannel(account: Account, title: String, description: Strin return createChannel(account: account, title: title, description: description, isSupergroup: false) } -func _internal_createSupergroup(account: Account, title: String, description: String?, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal { - return createChannel(account: account, title: title, description: description, isSupergroup: true, location: location, isForHistoryImport: isForHistoryImport) +func _internal_createSupergroup(account: Account, title: String, description: String?, location: (latitude: Double, longitude: Double, address: String)? = nil, isForum: Bool = false, isForHistoryImport: Bool = false) -> Signal { + return createChannel(account: account, title: title, description: description, isSupergroup: true, location: location, isForum: isForum, isForHistoryImport: isForHistoryImport) } public enum DeleteChannelError { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift index 347b9d86e2..dc640fd1cc 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift @@ -292,8 +292,8 @@ public extension TelegramEngine { return _internal_createChannel(account: self.account, title: title, description: description) } - public func createSupergroup(title: String, description: String?, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal { - return _internal_createSupergroup(account: self.account, title: title, description: description, location: location, isForHistoryImport: isForHistoryImport) + public func createSupergroup(title: String, description: String?, location: (latitude: Double, longitude: Double, address: String)? = nil, isForum: Bool = false, isForHistoryImport: Bool = false) -> Signal { + return _internal_createSupergroup(account: self.account, title: title, description: description, location: location, isForum: isForum, isForHistoryImport: isForHistoryImport) } public func deleteChannel(peerId: PeerId) -> Signal {