Merge commit '5c01d9527969870ec4e370b33f4a4d9387e62257'

This commit is contained in:
Ali 2023-01-13 21:14:49 +04:00
commit 0cc27f6782
5 changed files with 34 additions and 21 deletions

View File

@ -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

View File

@ -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)

View File

@ -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 []
}

View File

@ -12,13 +12,22 @@ 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<PeerId, CreateChannelError> {
public enum CreateChannelMode {
case channel
case supergroup(isForum: Bool)
}
private func createChannel(account: Account, title: String, description: String?, username: String?, mode: CreateChannelMode, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal<PeerId, CreateChannelError> {
return account.postbox.transaction { transaction -> Signal<PeerId, CreateChannelError> in
var flags: Int32 = 0
if isSupergroup {
flags |= (1 << 1)
} else {
switch mode {
case .channel:
flags |= (1 << 0)
case let .supergroup(isForum):
flags |= (1 << 1)
if isForum {
flags |= (1 << 5)
}
}
if isForHistoryImport {
flags |= (1 << 3)
@ -81,12 +90,12 @@ private func createChannel(account: Account, title: String, description: String?
|> switchToLatest
}
func _internal_createChannel(account: Account, title: String, description: String?) -> Signal<PeerId, CreateChannelError> {
return createChannel(account: account, title: title, description: description, isSupergroup: false)
func _internal_createChannel(account: Account, title: String, description: String?, username: String?) -> Signal<PeerId, CreateChannelError> {
return createChannel(account: account, title: title, description: description, username: nil, mode: .channel)
}
func _internal_createSupergroup(account: Account, title: String, description: String?, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal<PeerId, CreateChannelError> {
return createChannel(account: account, title: title, description: description, isSupergroup: true, location: location, isForHistoryImport: isForHistoryImport)
func _internal_createSupergroup(account: Account, title: String, description: String?, username: String?, isForum: Bool, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal<PeerId, CreateChannelError> {
return createChannel(account: account, title: title, description: description, username: username, mode: .supergroup(isForum: isForum), location: location, isForHistoryImport: isForHistoryImport)
}
public enum DeleteChannelError {

View File

@ -288,12 +288,12 @@ public extension TelegramEngine {
return _internal_updateDefaultChannelMemberBannedRights(account: self.account, peerId: peerId, rights: rights)
}
public func createChannel(title: String, description: String?) -> Signal<PeerId, CreateChannelError> {
return _internal_createChannel(account: self.account, title: title, description: description)
public func createChannel(title: String, description: String?, username: String? = nil) -> Signal<PeerId, CreateChannelError> {
return _internal_createChannel(account: self.account, title: title, description: description, username: username)
}
public func createSupergroup(title: String, description: String?, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal<PeerId, CreateChannelError> {
return _internal_createSupergroup(account: self.account, title: title, description: description, location: location, isForHistoryImport: isForHistoryImport)
public func createSupergroup(title: String, description: String?, username: String? = nil, isForum: Bool = false, location: (latitude: Double, longitude: Double, address: String)? = nil, isForHistoryImport: Bool = false) -> Signal<PeerId, CreateChannelError> {
return _internal_createSupergroup(account: self.account, title: title, description: description, username: username, isForum: isForum, location: location, isForHistoryImport: isForHistoryImport)
}
public func deleteChannel(peerId: PeerId) -> Signal<Void, DeleteChannelError> {