From bd1f523e965b21b09934a08cf1c11e8cf0669f17 Mon Sep 17 00:00:00 2001 From: overtake Date: Tue, 16 Mar 2021 19:59:27 +0400 Subject: [PATCH 1/2] - reset invite links [skip ci] --- submodules/TelegramCore/Sources/GroupCalls.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/submodules/TelegramCore/Sources/GroupCalls.swift b/submodules/TelegramCore/Sources/GroupCalls.swift index 9b7eec5c9e..2e12c0d761 100644 --- a/submodules/TelegramCore/Sources/GroupCalls.swift +++ b/submodules/TelegramCore/Sources/GroupCalls.swift @@ -1016,6 +1016,7 @@ public final class GroupCallParticipantsContext { private var activityRankResetTimer: SwiftSignalKit.Timer? private let updateDefaultMuteDisposable = MetaDisposable() + private let resetInviteLinksDisposable = MetaDisposable() private let updateShouldBeRecordingDisposable = MetaDisposable() public struct ServiceState { @@ -1146,6 +1147,7 @@ public final class GroupCallParticipantsContext { self.updateDefaultMuteDisposable.dispose() self.updateShouldBeRecordingDisposable.dispose() self.activityRankResetTimer?.invalidate() + resetInviteLinksDisposable.dispose() } public func addUpdates(updates: [Update]) { @@ -1617,6 +1619,16 @@ public final class GroupCallParticipantsContext { })) } + public func resetInviteLinks() { + self.resetInviteLinksDisposable.set((self.account.network.request(Api.functions.phone.toggleGroupCallSettings(flags: 1 << 1, call: .inputGroupCall(id: self.id, accessHash: self.accessHash), joinMuted: nil)) + |> deliverOnMainQueue).start(next: { [weak self] updates in + guard let strongSelf = self else { + return + } + strongSelf.account.stateManager.addUpdates(updates) + })) + } + public func loadMore(token: String) { if token != self.stateValue.state.nextParticipantsFetchOffset { Logger.shared.log("GroupCallParticipantsContext", "loadMore called with an invalid token \(token) (the valid one is \(String(describing: self.stateValue.state.nextParticipantsFetchOffset)))") From f260e8e55038e9f88a6d0ed965a986a901ebc22b Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 16 Mar 2021 20:05:11 +0400 Subject: [PATCH 2/2] Cleanup --- .../Sources/AccountStateManagementUtils.swift | 17 +++++++++---- .../Sources/GroupCallContext.swift | 24 +++++++++++++++++-- submodules/TgVoipWebrtc/tgcalls | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift index bf4ddea375..56777b8b79 100644 --- a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift @@ -109,16 +109,25 @@ private func peerIdsRequiringLocalChatStateFromUpdateGroups(_ groups: [UpdateGro for group in groups { peerIds.formUnion(peerIdsRequiringLocalChatStateFromUpdates(group.updates)) - - /*for chat in group.chats { - if let channel = parseTelegramGroupOrChannel(chat: chat) as? TelegramChannel { + + var channelUpdates = Set() + for update in group.updates { + switch update { + case let .updateChannel(channelId): + channelUpdates.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)) + default: + break + } + } + for chat in group.chats { + if let channel = parseTelegramGroupOrChannel(chat: chat) as? TelegramChannel, channelUpdates.contains(channel.id) { if let accessHash = channel.accessHash, case .personal = accessHash { if case .member = channel.participationStatus { peerIds.insert(channel.id) } } } - }*/ + } switch group { case let .ensurePeerHasLocalState(peerId): diff --git a/submodules/TelegramVoip/Sources/GroupCallContext.swift b/submodules/TelegramVoip/Sources/GroupCallContext.swift index 728a7e8b4e..8a292348d9 100644 --- a/submodules/TelegramVoip/Sources/GroupCallContext.swift +++ b/submodules/TelegramVoip/Sources/GroupCallContext.swift @@ -38,12 +38,23 @@ private final class NetworkBroadcastPartSource: BroadcastPartSource { private let callId: Int64 private let accessHash: Int64 private var dataSource: AudioBroadcastDataSource? + + #if DEBUG + private let debugDumpDirectory: TempBoxDirectory? + #endif init(queue: Queue, account: Account, callId: Int64, accessHash: Int64) { self.queue = queue self.account = account self.callId = callId self.accessHash = accessHash + + #if DEBUG + self.debugDumpDirectory = nil + /*let debugDumpDirectory = TempBox.shared.tempDirectory() + self.debugDumpDirectory = debugDumpDirectory + print("Debug streaming dump path: \(debugDumpDirectory.path)")*/ + #endif } func requestPart(timestampMilliseconds: Int64, durationMilliseconds: Int64, completion: @escaping (OngoingGroupCallBroadcastPart) -> Void, rejoinNeeded: @escaping () -> Void) -> Disposable { @@ -60,8 +71,7 @@ private final class NetworkBroadcastPartSource: BroadcastPartSource { } else { dataSource = getAudioBroadcastDataSource(account: self.account, callId: self.callId, accessHash: self.accessHash) } - - let account = self.account + let callId = self.callId let accessHash = self.accessHash @@ -79,6 +89,10 @@ private final class NetworkBroadcastPartSource: BroadcastPartSource { } } |> deliverOn(self.queue) + + #if DEBUG + let debugDumpDirectory = self.debugDumpDirectory + #endif return signal.start(next: { result in guard let result = result else { @@ -88,6 +102,12 @@ private final class NetworkBroadcastPartSource: BroadcastPartSource { let part: OngoingGroupCallBroadcastPart switch result.status { case let .data(dataValue): + #if DEBUG + if let debugDumpDirectory = debugDumpDirectory { + let _ = try? dataValue.write(to: URL(fileURLWithPath: debugDumpDirectory.path + "/" + "\(timestampIdMilliseconds).ogg")) + } + #endif + part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .success, oggData: dataValue) case .notReady: part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .notReady, oggData: Data()) diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 1c16a122c5..e80667a343 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 1c16a122c5cad736c4545fd1e37539adc4c4cb52 +Subproject commit e80667a343b62f6b8b2c3e0a828222096a497990