Update API [skip ci]

This commit is contained in:
Ali 2023-03-24 15:53:19 +04:00
parent b08561daab
commit 45e4728ae0
3 changed files with 35 additions and 22 deletions

View File

@ -2943,14 +2943,19 @@ public extension Api.functions.communities {
}
}
public extension Api.functions.communities {
static func editExportedInvite(flags: Int32, community: Api.InputCommunity, slug: String, title: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.ExportedCommunityInvite>) {
static func editExportedInvite(flags: Int32, community: Api.InputCommunity, slug: String, title: String?, peers: [Api.InputPeer]?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.ExportedCommunityInvite>) {
let buffer = Buffer()
buffer.appendInt32(873155725)
buffer.appendInt32(655623442)
serializeInt32(flags, buffer: buffer, boxed: false)
community.serialize(buffer, true)
serializeString(slug, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "communities.editExportedInvite", parameters: [("flags", String(describing: flags)), ("community", String(describing: community)), ("slug", String(describing: slug)), ("title", String(describing: title))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.ExportedCommunityInvite? in
if Int(flags) & Int(1 << 2) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(peers!.count))
for item in peers! {
item.serialize(buffer, true)
}}
return (FunctionDescription(name: "communities.editExportedInvite", parameters: [("flags", String(describing: flags)), ("community", String(describing: community)), ("slug", String(describing: slug)), ("title", String(describing: title)), ("peers", String(describing: peers))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.ExportedCommunityInvite? in
let reader = BufferReader(buffer)
var result: Api.ExportedCommunityInvite?
if let signature = reader.readInt32() {

View File

@ -84,17 +84,17 @@ func _internal_exportChatFolder(account: Account, filterId: Int32, title: String
}
}
func _internal_getExportedChatFolderLinks(account: Account, id: Int32) -> Signal<[ExportedChatFolderLink], NoError> {
func _internal_getExportedChatFolderLinks(account: Account, id: Int32) -> Signal<[ExportedChatFolderLink]?, NoError> {
return account.network.request(Api.functions.communities.getExportedInvites(community: .inputCommunityDialogFilter(filterId: id)))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.communities.ExportedInvites?, NoError> in
return .single(nil)
}
|> mapToSignal { result -> Signal<[ExportedChatFolderLink], NoError> in
|> mapToSignal { result -> Signal<[ExportedChatFolderLink]?, NoError> in
guard let result = result else {
return .single([])
return .single(nil)
}
return account.postbox.transaction { transaction -> [ExportedChatFolderLink] in
return account.postbox.transaction { transaction -> [ExportedChatFolderLink]? in
switch result {
case let .exportedInvites(invites, chats, users):
var peers: [Peer] = []
@ -139,19 +139,27 @@ public enum EditChatFolderLinkError {
case generic
}
func _internal_editChatFolderLink(account: Account, filterId: Int32, link: ExportedChatFolderLink, title: String?, revoke: Bool) -> Signal<Never, EditChatFolderLinkError> {
var flags: Int32 = 0
if revoke {
flags |= 1 << 0
func _internal_editChatFolderLink(account: Account, filterId: Int32, link: ExportedChatFolderLink, title: String?, peerIds: [EnginePeer.Id]?, revoke: Bool) -> Signal<Never, EditChatFolderLinkError> {
return account.postbox.transaction { transaction -> Signal<Never, EditChatFolderLinkError> in
var flags: Int32 = 0
if revoke {
flags |= 1 << 0
}
if title != nil {
flags |= 1 << 1
}
var peers: [Api.InputPeer]?
if let peerIds = peerIds {
peers = peerIds.compactMap(transaction.getPeer).compactMap(apiInputPeer)
}
return account.network.request(Api.functions.communities.editExportedInvite(flags: flags, community: .inputCommunityDialogFilter(filterId: filterId), slug: link.slug, title: title, peers: peers))
|> mapError { _ -> EditChatFolderLinkError in
return .generic
}
|> ignoreValues
}
if title != nil {
flags |= 1 << 1
}
return account.network.request(Api.functions.communities.editExportedInvite(flags: flags, community: .inputCommunityDialogFilter(filterId: filterId), slug: link.slug, title: title))
|> mapError { _ -> EditChatFolderLinkError in
return .generic
}
|> ignoreValues
|> castError(EditChatFolderLinkError.self)
|> switchToLatest
}

View File

@ -1030,12 +1030,12 @@ public extension TelegramEngine {
return _internal_exportChatFolder(account: self.account, filterId: filterId, title: title, peerIds: peerIds)
}
public func getExportedChatFolderLinks(id: Int32) -> Signal<[ExportedChatFolderLink], NoError> {
public func getExportedChatFolderLinks(id: Int32) -> Signal<[ExportedChatFolderLink]?, NoError> {
return _internal_getExportedChatFolderLinks(account: self.account, id: id)
}
public func editChatFolderLink(filterId: Int32, link: ExportedChatFolderLink, title: String?, revoke: Bool) -> Signal<Never, EditChatFolderLinkError> {
return _internal_editChatFolderLink(account: self.account, filterId: filterId, link: link, title: title, revoke: revoke)
public func editChatFolderLink(filterId: Int32, link: ExportedChatFolderLink, title: String?, peerIds: [EnginePeer.Id]?, revoke: Bool) -> Signal<Never, EditChatFolderLinkError> {
return _internal_editChatFolderLink(account: self.account, filterId: filterId, link: link, title: title, peerIds: peerIds, revoke: revoke)
}
public func revokeChatFolderLink(filterId: Int32, link: ExportedChatFolderLink) -> Signal<Never, RevokeChatFolderLinkError> {