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 {
|
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
|
break
|
||||||
case let .messageActionChannelMigrateFrom(_, chatId):
|
case let .messageActionChannelMigrateFrom(_, chatId):
|
||||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(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 {
|
for id in userIds {
|
||||||
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)))
|
result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)))
|
||||||
}
|
}
|
||||||
|
case let .messageActionRequestedPeer(_, peer):
|
||||||
|
result.append(peer.peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -53,7 +53,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable {
|
|||||||
case botAdminRights = "br"
|
case botAdminRights = "br"
|
||||||
}
|
}
|
||||||
|
|
||||||
public var isCreator: Bool?
|
public var isCreator: Bool
|
||||||
public var hasUsername: Bool?
|
public var hasUsername: Bool?
|
||||||
public var isForum: Bool?
|
public var isForum: Bool?
|
||||||
public var botParticipant: Bool
|
public var botParticipant: Bool
|
||||||
@ -61,7 +61,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable {
|
|||||||
public var botAdminRights: TelegramChatAdminRights?
|
public var botAdminRights: TelegramChatAdminRights?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
isCreator: Bool?,
|
isCreator: Bool,
|
||||||
hasUsername: Bool?,
|
hasUsername: Bool?,
|
||||||
isForum: Bool?,
|
isForum: Bool?,
|
||||||
botParticipant: Bool,
|
botParticipant: Bool,
|
||||||
@ -79,7 +79,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable {
|
|||||||
public init(from decoder: Decoder) throws {
|
public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
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.hasUsername = try container.decodeIfPresent(Bool.self, forKey: .hasUsername)
|
||||||
self.isForum = try container.decodeIfPresent(Bool.self, forKey: .isForum)
|
self.isForum = try container.decodeIfPresent(Bool.self, forKey: .isForum)
|
||||||
self.botParticipant = try container.decode(Bool.self, forKey: .botParticipant)
|
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 {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
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.hasUsername, forKey: .hasUsername)
|
||||||
try container.encodeIfPresent(self.isForum, forKey: .isForum)
|
try container.encodeIfPresent(self.isForum, forKey: .isForum)
|
||||||
try container.encode(self.botParticipant, forKey: .botParticipant)
|
try container.encode(self.botParticipant, forKey: .botParticipant)
|
||||||
@ -107,13 +107,13 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable {
|
|||||||
case botAdminRights = "br"
|
case botAdminRights = "br"
|
||||||
}
|
}
|
||||||
|
|
||||||
public var isCreator: Bool?
|
public var isCreator: Bool
|
||||||
public var hasUsername: Bool?
|
public var hasUsername: Bool?
|
||||||
public var userAdminRights: TelegramChatAdminRights?
|
public var userAdminRights: TelegramChatAdminRights?
|
||||||
public var botAdminRights: TelegramChatAdminRights?
|
public var botAdminRights: TelegramChatAdminRights?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
isCreator: Bool?,
|
isCreator: Bool,
|
||||||
hasUsername: Bool?,
|
hasUsername: Bool?,
|
||||||
userAdminRights: TelegramChatAdminRights?,
|
userAdminRights: TelegramChatAdminRights?,
|
||||||
botAdminRights: TelegramChatAdminRights?
|
botAdminRights: TelegramChatAdminRights?
|
||||||
@ -127,7 +127,7 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable {
|
|||||||
public init(from decoder: Decoder) throws {
|
public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
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.hasUsername = try container.decodeIfPresent(Bool.self, forKey: .hasUsername)
|
||||||
self.userAdminRights = try container.decodeIfPresent(TelegramChatAdminRights.self, forKey: .userAdminRights)
|
self.userAdminRights = try container.decodeIfPresent(TelegramChatAdminRights.self, forKey: .userAdminRights)
|
||||||
self.botAdminRights = try container.decodeIfPresent(TelegramChatAdminRights.self, forKey: .botAdminRights)
|
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 {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
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.hasUsername, forKey: .hasUsername)
|
||||||
try container.encodeIfPresent(self.userAdminRights, forKey: .userAdminRights)
|
try container.encodeIfPresent(self.userAdminRights, forKey: .userAdminRights)
|
||||||
try container.encodeIfPresent(self.botAdminRights, forKey: .botAdminRights)
|
try container.encodeIfPresent(self.botAdminRights, forKey: .botAdminRights)
|
||||||
|
@ -357,6 +357,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
return [from, to]
|
return [from, to]
|
||||||
case let .inviteToGroupPhoneCall(_, _, peerIds):
|
case let .inviteToGroupPhoneCall(_, _, peerIds):
|
||||||
return peerIds
|
return peerIds
|
||||||
|
case let .requestedPeer(_, peerId):
|
||||||
|
return [peerId]
|
||||||
default:
|
default:
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public enum CreateChannelError {
|
|||||||
case serverProvided(String)
|
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
|
return account.postbox.transaction { transaction -> Signal<PeerId, CreateChannelError> in
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if isSupergroup {
|
if isSupergroup {
|
||||||
@ -23,6 +23,9 @@ private func createChannel(account: Account, title: String, description: String?
|
|||||||
if isForHistoryImport {
|
if isForHistoryImport {
|
||||||
flags |= (1 << 3)
|
flags |= (1 << 3)
|
||||||
}
|
}
|
||||||
|
if isForum {
|
||||||
|
flags |= (1 << 5)
|
||||||
|
}
|
||||||
|
|
||||||
var geoPoint: Api.InputGeoPoint?
|
var geoPoint: Api.InputGeoPoint?
|
||||||
var address: String?
|
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)
|
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> {
|
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, isForHistoryImport: isForHistoryImport)
|
return createChannel(account: account, title: title, description: description, isSupergroup: true, location: location, isForum: isForum, isForHistoryImport: isForHistoryImport)
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DeleteChannelError {
|
public enum DeleteChannelError {
|
||||||
|
@ -292,8 +292,8 @@ public extension TelegramEngine {
|
|||||||
return _internal_createChannel(account: self.account, title: title, description: description)
|
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> {
|
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, isForHistoryImport: isForHistoryImport)
|
return _internal_createSupergroup(account: self.account, title: title, description: description, location: location, isForum: isForum, isForHistoryImport: isForHistoryImport)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteChannel(peerId: PeerId) -> Signal<Void, DeleteChannelError> {
|
public func deleteChannel(peerId: PeerId) -> Signal<Void, DeleteChannelError> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user