Allow discard invite or cancel ringing.

This commit is contained in:
John Preston 2025-04-05 13:51:23 +05:00
parent 344c0f6427
commit 55c05d1a6e
4 changed files with 30 additions and 10 deletions

View file

@ -4811,7 +4811,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_group_call_context_pin_screen" = "Pin screencast";
"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_cancel_invite" = "Discard invite";
"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?";

View file

@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_changes.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_histories.h"
#include "data/data_session.h"
#include "media/audio/media_audio_track.h"
#include "platform/platform_specific.h"
@ -982,7 +983,8 @@ void Instance::declineIncomingConferenceInvites(CallId conferenceId) {
void Instance::declineOutgoingConferenceInvite(
CallId conferenceId,
not_null<UserData*> user) {
not_null<UserData*> user,
bool discard) {
const auto i = _conferenceInvites.find(conferenceId);
if (i == end(_conferenceInvites)) {
return;
@ -992,10 +994,22 @@ void Instance::declineOutgoingConferenceInvite(
return;
}
const auto api = &user->session().api();
for (const auto &messageId : base::take(j->second.outgoing)) {
api->request(MTPphone_DeclineConferenceCallInvite(
MTP_int(messageId.bare)
)).send();
auto ids = base::take(j->second.outgoing);
auto inputs = QVector<MTPint>();
for (const auto &messageId : ids) {
if (discard) {
inputs.push_back(MTP_int(messageId.bare));
} else {
api->request(MTPphone_DeclineConferenceCallInvite(
MTP_int(messageId.bare)
)).send();
}
}
if (!inputs.empty()) {
user->owner().histories().deleteMessages(
user->owner().history(user),
std::move(inputs),
true);
}
if (!j->second.incoming.empty()) {
return;

View file

@ -138,7 +138,8 @@ public:
void declineIncomingConferenceInvites(CallId conferenceId);
void declineOutgoingConferenceInvite(
CallId conferenceId,
not_null<UserData*> user);
not_null<UserData*> user,
bool discard = false);
[[nodiscard]] FnMut<void()> addAsyncWaiter();

View file

@ -1468,14 +1468,19 @@ base::unique_qptr<Ui::PopupMenu> Members::Controller::createRowContextMenu(
&& participantPeer->isUser()
&& conference) {
const auto id = conference->id();
const auto cancelInvite = [=] {
const auto cancelInvite = [=](bool discard) {
Core::App().calls().declineOutgoingConferenceInvite(
id,
participantPeer->asUser());
participantPeer->asUser(),
discard);
};
result->addAction(
tr::lng_group_call_context_stop_ringing(tr::now),
[=] { cancelInvite(false); });
result->addAction(
tr::lng_group_call_context_cancel_invite(tr::now),
cancelInvite);
[=] { cancelInvite(true); });
result->addSeparator();
}
result->addAction(
(participantPeer->isUser()