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 {
|
||||
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() {
|
||||
|
@ -369,6 +369,7 @@ private final class CallSessionManagerContext {
|
||||
|
||||
private let ringingSubscribers = Bag<([CallSessionRingingState]) -> Void>()
|
||||
private var contexts: [CallSessionInternalId: CallSessionContext] = [:]
|
||||
private var futureContextSubscribers: [CallSessionInternalId: Bag<(CallSession) -> Void>] = [:]
|
||||
private var contextIdByStableId: [CallSessionStableId: CallSessionInternalId] = [:]
|
||||
|
||||
private var enqueuedSignalingData: [Int64: [Data]] = [:]
|
||||
@ -443,7 +444,10 @@ private final class CallSessionManagerContext {
|
||||
return Signal { [weak self] subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
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
|
||||
subscriber.putNext(next)
|
||||
}
|
||||
@ -459,8 +463,22 @@ private final class CallSessionManagerContext {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
subscriber.putNext(CallSession(id: internalId, stableId: nil, isOutgoing: false, type: .audio, state: .terminated(id: nil, reason: .error(.generic), options: []), isVideoPossible: true))
|
||||
subscriber.putCompletion()
|
||||
if strongSelf.futureContextSubscribers[internalId] == nil {
|
||||
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
|
||||
@ -517,6 +535,11 @@ private final class CallSessionManagerContext {
|
||||
for subscriber in context.subscribers.copyItems() {
|
||||
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)))
|
||||
|> 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,7 +139,8 @@ public enum EditChatFolderLinkError {
|
||||
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> {
|
||||
return account.postbox.transaction { transaction -> Signal<ExportedChatFolderLink, EditChatFolderLinkError> in
|
||||
var flags: Int32 = 0
|
||||
if revoke {
|
||||
flags |= 1 << 0
|
||||
@ -147,11 +148,29 @@ func _internal_editChatFolderLink(account: Account, filterId: Int32, link: Expor
|
||||
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))
|
||||
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
|
||||
}
|
||||
|> ignoreValues
|
||||
|> 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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|> castError(EditChatFolderLinkError.self)
|
||||
|> switchToLatest
|
||||
|
||||
}
|
||||
|
||||
|
@ -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<ExportedChatFolderLink, 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> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user