From 9a2215de29345336012e19c5a0e0406c2714bba9 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 15 Apr 2025 19:30:05 +0400 Subject: [PATCH] Conference --- Telegram/Telegram-iOS/en.lproj/Localizable.strings | 1 + .../Sources/PresentationGroupCall.swift | 8 ++++---- .../Sources/State/ConferenceCallE2EContext.swift | 2 +- .../Sources/SendInviteLinkScreen.swift | 2 +- submodules/TelegramVoip/Sources/GroupCallContext.swift | 10 +++++----- .../TgVoipWebrtc/OngoingCallThreadLocalContext.h | 2 +- .../Sources/OngoingCallThreadLocalContext.mm | 10 +++++----- submodules/TgVoipWebrtc/tgcalls | 2 +- third-party/td/TdBinding/Public/TdBinding/TdBinding.h | 2 +- third-party/td/TdBinding/Sources/TdBinding.mm | 4 ++-- third-party/td/td | 2 +- 11 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 211b5f8ab6..23ac7ddcb1 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -14187,3 +14187,4 @@ Sorry for the inconvenience."; "SendInviteLink.TextCallsRestrictedOneUser" = "%@ does not accept calls."; "SendInviteLink.TextCallsRestrictedMultipleUsers_1" = "{user_list}, and **%d** more person do not accept calls."; "SendInviteLink.TextCallsRestrictedMultipleUsers_any" = "{user_list}, and **%d** more people do not accept calls."; +"SendInviteLink.TextCallsRestrictedSendInviteLink" = "You can try to send an invite link instead."; diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index d842760168..95faea142d 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -356,8 +356,8 @@ private final class ConferenceCallE2EContextStateImpl: ConferenceCallE2EContextS return self.call.takeOutgoingBroadcastBlocks() } - func encrypt(message: Data, channelId: Int32) -> Data? { - return self.call.encrypt(message, channelId: channelId) + func encrypt(message: Data, channelId: Int32, plaintextPrefixLength: Int) -> Data? { + return self.call.encrypt(message, channelId: channelId, plaintextPrefixLength: plaintextPrefixLength) } func decrypt(message: Data, userId: Int64) -> Data? { @@ -374,9 +374,9 @@ class OngoingGroupCallEncryptionContextImpl: OngoingGroupCallEncryptionContext { self.channelId = channelId } - func encrypt(message: Data) -> Data? { + func encrypt(message: Data, plaintextPrefixLength: Int) -> Data? { let channelId = self.channelId - return self.e2eCall.with({ $0.state?.encrypt(message: message, channelId: channelId) }) + return self.e2eCall.with({ $0.state?.encrypt(message: message, channelId: channelId, plaintextPrefixLength: plaintextPrefixLength) }) } func decrypt(message: Data, userId: Int64) -> Data? { diff --git a/submodules/TelegramCore/Sources/State/ConferenceCallE2EContext.swift b/submodules/TelegramCore/Sources/State/ConferenceCallE2EContext.swift index f14d7ba965..2015fd0755 100644 --- a/submodules/TelegramCore/Sources/State/ConferenceCallE2EContext.swift +++ b/submodules/TelegramCore/Sources/State/ConferenceCallE2EContext.swift @@ -13,7 +13,7 @@ public protocol ConferenceCallE2EContextState: AnyObject { func takeOutgoingBroadcastBlocks() -> [Data] - func encrypt(message: Data, channelId: Int32) -> Data? + func encrypt(message: Data, channelId: Int32, plaintextPrefixLength: Int) -> Data? func decrypt(message: Data, userId: Int64) -> Data? } diff --git a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift index 7190f13e27..5c0dea7506 100644 --- a/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift +++ b/submodules/TelegramUI/Components/SendInviteLinkScreen/Sources/SendInviteLinkScreen.swift @@ -791,7 +791,7 @@ private final class SendInviteLinkScreenComponent: Component { } } case .groupCall: - text = " " + text = environment.strings.SendInviteLink_TextCallsRestrictedSendInviteLink } let body = MarkdownAttributeSet(font: Font.regular(15.0), textColor: environment.theme.list.itemPrimaryTextColor) diff --git a/submodules/TelegramVoip/Sources/GroupCallContext.swift b/submodules/TelegramVoip/Sources/GroupCallContext.swift index e631caf116..5a61471cac 100644 --- a/submodules/TelegramVoip/Sources/GroupCallContext.swift +++ b/submodules/TelegramVoip/Sources/GroupCallContext.swift @@ -217,7 +217,7 @@ final class OngoingGroupCallBroadcastPartTaskImpl: NSObject, OngoingGroupCallBro } public protocol OngoingGroupCallEncryptionContext: AnyObject { - func encrypt(message: Data) -> Data? + func encrypt(message: Data, plaintextPrefixLength: Int) -> Data? func decrypt(message: Data, userId: Int64) -> Data? } @@ -645,9 +645,9 @@ public final class OngoingGroupCallContext { isConference: isConference, isActiveByDefault: audioIsActiveByDefault, encryptDecrypt: encryptionContext.flatMap { encryptionContext in - return { data, userId, isEncrypt in + return { data, userId, isEncrypt, plaintextPrefixLength in if isEncrypt { - return encryptionContext.encrypt(message: data) + return encryptionContext.encrypt(message: data, plaintextPrefixLength: Int(plaintextPrefixLength)) } else { return encryptionContext.decrypt(message: data, userId: userId) } @@ -755,9 +755,9 @@ public final class OngoingGroupCallContext { isConference: isConference, isActiveByDefault: audioIsActiveByDefault, encryptDecrypt: encryptionContext.flatMap { encryptionContext in - return { data, userId, isEncrypt in + return { data, userId, isEncrypt, plaintextPrefixLength in if isEncrypt { - return encryptionContext.encrypt(message: data) + return encryptionContext.encrypt(message: data, plaintextPrefixLength: Int(plaintextPrefixLength)) } else { return encryptionContext.decrypt(message: data, userId: userId) } diff --git a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h index 128aac0758..7061cadab0 100644 --- a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h +++ b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h @@ -457,7 +457,7 @@ onMutedSpeechActivityDetected:(void (^ _Nullable)(bool))onMutedSpeechActivityDet audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice isConference:(bool)isConference isActiveByDefault:(bool)isActiveByDefault -encryptDecrypt:(NSData * _Nullable (^ _Nullable)(NSData * _Nonnull, int64_t, bool))encryptDecrypt; +encryptDecrypt:(NSData * _Nullable (^ _Nullable)(NSData * _Nonnull, int64_t, bool, int32_t))encryptDecrypt; - (void)stop:(void (^ _Nullable)())completion; diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index ef3a51e1e3..00025f77a2 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -2389,7 +2389,7 @@ onMutedSpeechActivityDetected:(void (^ _Nullable)(bool))onMutedSpeechActivityDet audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice isConference:(bool)isConference isActiveByDefault:(bool)isActiveByDefault -encryptDecrypt:(NSData * _Nullable (^ _Nullable)(NSData * _Nonnull, int64_t, bool))encryptDecrypt { +encryptDecrypt:(NSData * _Nullable (^ _Nullable)(NSData * _Nonnull, int64_t, bool, int32_t))encryptDecrypt { self = [super init]; if (self != nil) { _queue = queue; @@ -2458,12 +2458,12 @@ encryptDecrypt:(NSData * _Nullable (^ _Nullable)(NSData * _Nonnull, int64_t, boo std::string statsLogPathValue(statsLogPath.length == 0 ? "" : statsLogPath.UTF8String); - std::function(std::vector const &, int64_t, bool)> mappedEncryptDecrypt; + std::function(std::vector const &, int64_t, bool, int32_t)> mappedEncryptDecrypt; if (encryptDecrypt) { - NSData * _Nullable (^encryptDecryptBlock)(NSData * _Nonnull, int64_t, bool) = [encryptDecrypt copy]; - mappedEncryptDecrypt = [encryptDecryptBlock](std::vector const &message, int64_t userId, bool isEncrypt) -> std::vector { + NSData * _Nullable (^encryptDecryptBlock)(NSData * _Nonnull, int64_t, bool, int32_t) = [encryptDecrypt copy]; + mappedEncryptDecrypt = [encryptDecryptBlock](std::vector const &message, int64_t userId, bool isEncrypt, int32_t plaintextPrefixLength) -> std::vector { NSData *mappedMessage = [[NSData alloc] initWithBytes:message.data() length:message.size()]; - NSData *result = encryptDecryptBlock(mappedMessage, userId, isEncrypt); + NSData *result = encryptDecryptBlock(mappedMessage, userId, isEncrypt, plaintextPrefixLength); if (!result) { return std::vector(); } diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 36161286bd..e87034dbdd 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 36161286bd7fae1b9bb2e8dad817ae9af6d68055 +Subproject commit e87034dbdd8c209318aca57c4ff417117398d14f diff --git a/third-party/td/TdBinding/Public/TdBinding/TdBinding.h b/third-party/td/TdBinding/Public/TdBinding/TdBinding.h index f871989564..79df862c39 100644 --- a/third-party/td/TdBinding/Public/TdBinding/TdBinding.h +++ b/third-party/td/TdBinding/Public/TdBinding/TdBinding.h @@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable NSData *)generateRemoveParticipantsBlock:(NSArray *)participantIds; -- (nullable NSData *)encrypt:(NSData *)message channelId:(int32_t)channelId; +- (nullable NSData *)encrypt:(NSData *)message channelId:(int32_t)channelId plaintextPrefixLength:(NSInteger)plaintextPrefixLength; - (nullable NSData *)decrypt:(NSData *)message userId:(int64_t)userId; @end diff --git a/third-party/td/TdBinding/Sources/TdBinding.mm b/third-party/td/TdBinding/Sources/TdBinding.mm index 434143ae44..cd60c2e2b5 100644 --- a/third-party/td/TdBinding/Sources/TdBinding.mm +++ b/third-party/td/TdBinding/Sources/TdBinding.mm @@ -287,9 +287,9 @@ static NSString *hexStringFromData(NSData *data) { return [[NSData alloc] initWithBytes:result.value().data() length:result.value().size()]; } -- (nullable NSData *)encrypt:(NSData *)message channelId:(int32_t)channelId { +- (nullable NSData *)encrypt:(NSData *)message channelId:(int32_t)channelId plaintextPrefixLength:(NSInteger)plaintextPrefixLength { std::string mappedMessage((uint8_t *)message.bytes, ((uint8_t *)message.bytes) + message.length); - auto result = tde2e_api::call_encrypt(_callId, channelId, mappedMessage); + auto result = tde2e_api::call_encrypt(_callId, channelId, mappedMessage, (size_t)plaintextPrefixLength); if (!result.is_ok()) { return nil; } diff --git a/third-party/td/td b/third-party/td/td index 04adfc87de..ec42a57073 160000 --- a/third-party/td/td +++ b/third-party/td/td @@ -1 +1 @@ -Subproject commit 04adfc87deea4c804def118e88c89a08c388b32b +Subproject commit ec42a570737be64397632eba84b5e0916e2c8388