mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
93265ce74d
@ -2943,14 +2943,19 @@ public extension Api.functions.communities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(873155725)
|
buffer.appendInt32(655623442)
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
community.serialize(buffer, true)
|
community.serialize(buffer, true)
|
||||||
serializeString(slug, buffer: buffer, boxed: false)
|
serializeString(slug, buffer: buffer, boxed: false)
|
||||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(title!, 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)
|
let reader = BufferReader(buffer)
|
||||||
var result: Api.ExportedCommunityInvite?
|
var result: Api.ExportedCommunityInvite?
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
|
@ -369,6 +369,7 @@ private final class CallSessionManagerContext {
|
|||||||
|
|
||||||
private let ringingSubscribers = Bag<([CallSessionRingingState]) -> Void>()
|
private let ringingSubscribers = Bag<([CallSessionRingingState]) -> Void>()
|
||||||
private var contexts: [CallSessionInternalId: CallSessionContext] = [:]
|
private var contexts: [CallSessionInternalId: CallSessionContext] = [:]
|
||||||
|
private var futureContextSubscribers: [CallSessionInternalId: Bag<(CallSession) -> Void>] = [:]
|
||||||
private var contextIdByStableId: [CallSessionStableId: CallSessionInternalId] = [:]
|
private var contextIdByStableId: [CallSessionStableId: CallSessionInternalId] = [:]
|
||||||
|
|
||||||
private var enqueuedSignalingData: [Int64: [Data]] = [:]
|
private var enqueuedSignalingData: [Int64: [Data]] = [:]
|
||||||
@ -443,7 +444,10 @@ private final class CallSessionManagerContext {
|
|||||||
return Signal { [weak self] subscriber in
|
return Signal { [weak self] subscriber in
|
||||||
let disposable = MetaDisposable()
|
let disposable = MetaDisposable()
|
||||||
queue.async {
|
queue.async {
|
||||||
if let strongSelf = self, let context = strongSelf.contexts[internalId] {
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let context = strongSelf.contexts[internalId] {
|
||||||
let index = context.subscribers.add { next in
|
let index = context.subscribers.add { next in
|
||||||
subscriber.putNext(next)
|
subscriber.putNext(next)
|
||||||
}
|
}
|
||||||
@ -459,8 +463,22 @@ private final class CallSessionManagerContext {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
subscriber.putNext(CallSession(id: internalId, stableId: nil, isOutgoing: false, type: .audio, state: .terminated(id: nil, reason: .error(.generic), options: []), isVideoPossible: true))
|
if strongSelf.futureContextSubscribers[internalId] == nil {
|
||||||
subscriber.putCompletion()
|
strongSelf.futureContextSubscribers[internalId] = Bag()
|
||||||
|
}
|
||||||
|
let index = strongSelf.futureContextSubscribers[internalId]?.add({ session in
|
||||||
|
subscriber.putNext(session)
|
||||||
|
})
|
||||||
|
if let index = index {
|
||||||
|
disposable.set(ActionDisposable {
|
||||||
|
queue.async {
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.futureContextSubscribers[internalId]?.remove(index)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return disposable
|
return disposable
|
||||||
@ -517,6 +535,11 @@ private final class CallSessionManagerContext {
|
|||||||
for subscriber in context.subscribers.copyItems() {
|
for subscriber in context.subscribers.copyItems() {
|
||||||
subscriber(session)
|
subscriber(session)
|
||||||
}
|
}
|
||||||
|
if let futureSubscribers = self.futureContextSubscribers[internalId] {
|
||||||
|
for subscriber in futureSubscribers.copyItems() {
|
||||||
|
subscriber(session)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)))
|
return account.network.request(Api.functions.communities.getExportedInvites(community: .inputCommunityDialogFilter(filterId: id)))
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { _ -> Signal<Api.communities.ExportedInvites?, NoError> in
|
|> `catch` { _ -> Signal<Api.communities.ExportedInvites?, NoError> in
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
}
|
}
|
||||||
|> mapToSignal { result -> Signal<[ExportedChatFolderLink], NoError> in
|
|> mapToSignal { result -> Signal<[ExportedChatFolderLink]?, NoError> in
|
||||||
guard let result = result else {
|
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 {
|
switch result {
|
||||||
case let .exportedInvites(invites, chats, users):
|
case let .exportedInvites(invites, chats, users):
|
||||||
var peers: [Peer] = []
|
var peers: [Peer] = []
|
||||||
@ -139,19 +139,38 @@ public enum EditChatFolderLinkError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
func _internal_editChatFolderLink(account: Account, filterId: Int32, link: ExportedChatFolderLink, title: String?, revoke: Bool) -> Signal<Never, EditChatFolderLinkError> {
|
func _internal_editChatFolderLink(account: Account, filterId: Int32, link: ExportedChatFolderLink, title: String?, peerIds: [EnginePeer.Id]?, revoke: Bool) -> Signal<ExportedChatFolderLink, EditChatFolderLinkError> {
|
||||||
var flags: Int32 = 0
|
return account.postbox.transaction { transaction -> Signal<ExportedChatFolderLink, EditChatFolderLinkError> in
|
||||||
if revoke {
|
var flags: Int32 = 0
|
||||||
flags |= 1 << 0
|
if revoke {
|
||||||
|
flags |= 1 << 0
|
||||||
|
}
|
||||||
|
if title != nil {
|
||||||
|
flags |= 1 << 1
|
||||||
|
}
|
||||||
|
var peers: [Api.InputPeer]?
|
||||||
|
if let peerIds = peerIds {
|
||||||
|
flags |= 1 << 2
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|> map { result in
|
||||||
|
switch result {
|
||||||
|
case let .exportedCommunityInvite(flags, title, url, peers):
|
||||||
|
return ExportedChatFolderLink(
|
||||||
|
title: title,
|
||||||
|
link: url,
|
||||||
|
peerIds: peers.map(\.peerId),
|
||||||
|
isRevoked: (flags & (1 << 0)) != 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if title != nil {
|
|> castError(EditChatFolderLinkError.self)
|
||||||
flags |= 1 << 1
|
|> switchToLatest
|
||||||
}
|
|
||||||
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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,12 +1030,12 @@ public extension TelegramEngine {
|
|||||||
return _internal_exportChatFolder(account: self.account, filterId: filterId, title: title, peerIds: peerIds)
|
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)
|
return _internal_getExportedChatFolderLinks(account: self.account, id: id)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func editChatFolderLink(filterId: Int32, link: ExportedChatFolderLink, title: String?, revoke: Bool) -> Signal<Never, EditChatFolderLinkError> {
|
public func editChatFolderLink(filterId: Int32, link: ExportedChatFolderLink, title: String?, peerIds: [EnginePeer.Id]?, revoke: Bool) -> Signal<ExportedChatFolderLink, EditChatFolderLinkError> {
|
||||||
return _internal_editChatFolderLink(account: self.account, filterId: filterId, link: link, title: title, revoke: revoke)
|
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> {
|
public func revokeChatFolderLink(filterId: Int32, link: ExportedChatFolderLink) -> Signal<Never, RevokeChatFolderLinkError> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user