mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update API
This commit is contained in:
parent
9fe022a499
commit
58e641230a
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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 []
|
||||
}
|
||||
|
@ -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<PeerId, CreateChannelError> {
|
||||
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<PeerId, CreateChannelError> {
|
||||
return account.postbox.transaction { transaction -> Signal<PeerId, CreateChannelError> 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<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?, location: (latitude: Double, longitude: Double, address: String)? = nil, isForum: Bool = false, isForHistoryImport: Bool = false) -> Signal<PeerId, CreateChannelError> {
|
||||
return createChannel(account: account, title: title, description: description, isSupergroup: true, location: location, isForum: isForum, isForHistoryImport: isForHistoryImport)
|
||||
}
|
||||
|
||||
public enum DeleteChannelError {
|
||||
|
@ -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<PeerId, CreateChannelError> {
|
||||
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<PeerId, CreateChannelError> {
|
||||
return _internal_createSupergroup(account: self.account, title: title, description: description, location: location, isForum: isForum, isForHistoryImport: isForHistoryImport)
|
||||
}
|
||||
|
||||
public func deleteChannel(peerId: PeerId) -> Signal<Void, DeleteChannelError> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user