From 8ab1a7268bd569ae82a7ab8e8ffdeea382c6813b Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 5 Apr 2025 09:55:11 +0400 Subject: [PATCH] Handle all types of confcall invite responses. --- Telegram/Resources/langs/lang.strings | 23 +++++-- .../calls/group/calls_group_call.cpp | 62 +++++++++++++++++-- .../calls/group/calls_group_common.h | 2 + .../group/calls_group_invite_controller.cpp | 6 -- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 23729e3c43..90b11ff4cf 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4812,6 +4812,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_group_call_context_unpin_screen" = "Unpin screencast"; "lng_group_call_context_remove" = "Remove"; "lng_group_call_context_cancel_invite" = "Cancel invitation"; +"lng_group_call_context_stop_ringing" = "Stop calling"; +"lng_group_call_context_ban_from_call" = "Ban from call"; "lng_group_call_remove_channel" = "Remove {channel} from the video chat and ban them?"; "lng_group_call_remove_channel_from_channel" = "Remove {channel} from the live stream?"; "lng_group_call_mac_access" = "Telegram Desktop does not have access to system wide keyboard input required for Push to Talk."; @@ -4940,12 +4942,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_confcall_link_or" = "or"; "lng_confcall_link_join" = "Be the first to join the call and add people from there. {link}"; "lng_confcall_link_join_link" = "Open call {arrow}"; -"lng_confcall_invite_done_user" = "You invited {user} to join the call."; -"lng_confcall_invite_done_many#one" = "You invited **{count} person** to join the call."; -"lng_confcall_invite_done_many#other" = "You invited **{count} people** to join the call."; -"lng_confcall_invite_fail_user" = "You cannot call {user} because of their privacy settings."; -"lng_confcall_invite_fail_many#one" = "You cannot call **{count} person** because of their privacy settings."; -"lng_confcall_invite_fail_many#other" = "You cannot call **{count} people** because of their privacy settings."; +"lng_confcall_invite_done_user" = "You're calling {user} to join."; +"lng_confcall_invite_done_many#one" = "You're calling **{count} person** to join."; +"lng_confcall_invite_done_many#other" = "You're calling **{count} people** to join."; +"lng_confcall_invite_already_user" = "{user} is already in the call."; +"lng_confcall_invite_already_many#one" = "**{count} person** is already in the call."; +"lng_confcall_invite_already_many#other" = "**{count} people** are already in the call."; +"lng_confcall_invite_privacy_user" = "You cannot call {user} because of their privacy settings."; +"lng_confcall_invite_privacy_many#one" = "You cannot call **{count} person** because of their privacy settings."; +"lng_confcall_invite_privacy_many#other" = "You cannot call **{count} people** because of their privacy settings."; +"lng_confcall_invite_fail_user" = "Couldn't call {user} to join."; +"lng_confcall_invite_fail_many#one" = "Couldn't call **{count} person** to join."; +"lng_confcall_invite_fail_many#other" = "Couldn't call **{count} people** to join."; +"lng_confcall_invite_kicked_user" = "{user} was removed from the call."; +"lng_confcall_invite_kicked_many#one" = "**{count} person** was removed from the call."; +"lng_confcall_invite_kicked_many#other" = "**{count} people** were removed from the call."; "lng_no_mic_permission" = "Telegram needs microphone access so that you can make calls and record voice messages."; diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index dc9d1f6af3..bd0c703ccc 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -3819,8 +3819,12 @@ void GroupCall::inviteUsers( state->result.privacyRestricted.push_back(user); } else if (type == u"USER_ALREADY_PARTICIPANT"_q) { state->result.alreadyIn.push_back(user); + } else if (type == u"USER_WAS_KICKED"_q) { + state->result.kicked.push_back(user); } else if (type == u"GROUPCALL_FORBIDDEN"_q) { startRejoin(); + } else { + state->result.failed.push_back(user); } finishRequest(); }).send(); @@ -3989,37 +3993,83 @@ void GroupCall::destroyScreencast() { TextWithEntities ComposeInviteResultToast( const InviteResult &result) { auto text = TextWithEntities(); + const auto append = [&](TextWithEntities part) { + if (!text.empty()) { + text.append(u"\n\n"_q); + } + text.append(part); + }; + const auto invited = int(result.invited.size()); + const auto already = int(result.alreadyIn.size()); const auto restricted = int(result.privacyRestricted.size()); + const auto kicked = int(result.kicked.size()); + const auto failed = int(result.failed.size()); if (invited == 1) { - text.append(tr::lng_confcall_invite_done_user( + append(tr::lng_confcall_invite_done_user( tr::now, lt_user, Ui::Text::Bold(result.invited.front()->shortName()), Ui::Text::RichLangValue)); } else if (invited > 1) { - text.append(tr::lng_confcall_invite_done_many( + append(tr::lng_confcall_invite_done_many( tr::now, lt_count, invited, Ui::Text::RichLangValue)); } - if (invited && restricted) { - text.append(u"\n\n"_q); + if (already == 1) { + append(tr::lng_confcall_invite_already_user( + tr::now, + lt_user, + Ui::Text::Bold(result.alreadyIn.front()->shortName()), + Ui::Text::RichLangValue)); + } else if (already > 1) { + append(tr::lng_confcall_invite_already_many( + tr::now, + lt_count, + already, + Ui::Text::RichLangValue)); } if (restricted == 1) { - text.append(tr::lng_confcall_invite_fail_user( + append(tr::lng_confcall_invite_fail_user( tr::now, lt_user, Ui::Text::Bold(result.privacyRestricted.front()->shortName()), Ui::Text::RichLangValue)); } else if (restricted > 1) { - text.append(tr::lng_confcall_invite_fail_many( + append(tr::lng_confcall_invite_fail_many( tr::now, lt_count, restricted, Ui::Text::RichLangValue)); } + if (kicked == 1) { + append(tr::lng_confcall_invite_kicked_user( + tr::now, + lt_user, + Ui::Text::Bold(result.kicked.front()->shortName()), + Ui::Text::RichLangValue)); + } else if (kicked > 1) { + append(tr::lng_confcall_invite_kicked_many( + tr::now, + lt_count, + kicked, + Ui::Text::RichLangValue)); + } + if (failed == 1) { + append(tr::lng_confcall_invite_fail_user( + tr::now, + lt_user, + Ui::Text::Bold(result.failed.front()->shortName()), + Ui::Text::RichLangValue)); + } else if (failed > 1) { + append(tr::lng_confcall_invite_fail_many( + tr::now, + lt_count, + failed, + Ui::Text::RichLangValue)); + } return text; } diff --git a/Telegram/SourceFiles/calls/group/calls_group_common.h b/Telegram/SourceFiles/calls/group/calls_group_common.h index e82a12f611..93412787c0 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_common.h +++ b/Telegram/SourceFiles/calls/group/calls_group_common.h @@ -57,6 +57,8 @@ struct InviteResult { std::vector> invited; std::vector> alreadyIn; std::vector> privacyRestricted; + std::vector> kicked; + std::vector> failed; }; struct StartConferenceInfo { diff --git a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp index e5eb07be35..68182df06a 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_invite_controller.cpp @@ -511,10 +511,6 @@ object_ptr PrepareInviteBox( } const auto done = [=](InviteResult result) { (*close)(); - if (result.invited.empty() - && result.privacyRestricted.empty()) { - return; - } showToast({ ComposeInviteResultToast(result) }); }; call->inviteUsers( @@ -566,8 +562,6 @@ object_ptr PrepareInviteBox( lt_count, result.invited.size(), Ui::Text::RichLangValue)); - } else { - Unexpected("Result in GroupCall::inviteUsers."); } }); };