mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Forbid anonymous admins joining group calls.
This commit is contained in:
parent
d773f2c765
commit
d5216a30c7
4 changed files with 41 additions and 8 deletions
|
@ -1477,6 +1477,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_game_tag" = "Game";
|
"lng_game_tag" = "Game";
|
||||||
|
|
||||||
"lng_context_view_profile" = "View profile";
|
"lng_context_view_profile" = "View profile";
|
||||||
|
"lng_context_send_message" = "Send message";
|
||||||
"lng_context_view_group" = "View group info";
|
"lng_context_view_group" = "View group info";
|
||||||
"lng_context_view_channel" = "View channel info";
|
"lng_context_view_channel" = "View channel info";
|
||||||
//"lng_context_view_feed_info" = "View feed info";
|
//"lng_context_view_feed_info" = "View feed info";
|
||||||
|
@ -1843,6 +1844,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_group_call_no_members" = "No members";
|
"lng_group_call_no_members" = "No members";
|
||||||
"lng_group_call_members#one" = "{count} member";
|
"lng_group_call_members#one" = "{count} member";
|
||||||
"lng_group_call_members#other" = "{count} members";
|
"lng_group_call_members#other" = "{count} members";
|
||||||
|
"lng_group_call_no_anonymous" = "Anonymous admins can't join voice chats :(";
|
||||||
|
"lng_group_call_context_mute" = "Mute";
|
||||||
|
|
||||||
"lng_no_mic_permission" = "Telegram needs access to your microphone so that you can make calls and record voice messages.";
|
"lng_no_mic_permission" = "Telegram needs access to your microphone so that you can make calls and record voice messages.";
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
@ -112,16 +113,22 @@ void GroupCall::setState(State state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::start() {
|
void GroupCall::start() {
|
||||||
const auto randomId = rand_value<int32>();
|
|
||||||
_createRequestId = _api.request(MTPphone_CreateGroupCall(
|
_createRequestId = _api.request(MTPphone_CreateGroupCall(
|
||||||
_channel->inputChannel,
|
_channel->inputChannel,
|
||||||
MTP_int(randomId)
|
MTP_int(rand_value<int32>())
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
_acceptFields = true;
|
_acceptFields = true;
|
||||||
_channel->session().api().applyUpdates(result);
|
_channel->session().api().applyUpdates(result);
|
||||||
_acceptFields = false;
|
_acceptFields = false;
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
int a = error.code();
|
LOG(("Call Error: Could not create, error: %1"
|
||||||
|
).arg(error.type()));
|
||||||
|
hangup();
|
||||||
|
if (error.type() == u"GROUP_CALL_ANONYMOUS_FORBIDDEN"_q) {
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.text = tr::lng_group_call_no_anonymous(tr::now),
|
||||||
|
});
|
||||||
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +213,11 @@ void GroupCall::rejoin() {
|
||||||
LOG(("Call Error: Could not join, error: %1"
|
LOG(("Call Error: Could not join, error: %1"
|
||||||
).arg(error.type()));
|
).arg(error.type()));
|
||||||
hangup();
|
hangup();
|
||||||
|
if (error.type() == u"GROUP_CALL_ANONYMOUS_FORBIDDEN"_q) {
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.text = tr::lng_group_call_no_anonymous(tr::now),
|
||||||
|
});
|
||||||
|
}
|
||||||
}).send();
|
}).send();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -401,10 +413,14 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
||||||
}
|
}
|
||||||
if (data.is_left() && data.vsource().v == _mySsrc) {
|
if (data.is_left() && data.vsource().v == _mySsrc) {
|
||||||
// I was removed from the call, rejoin.
|
// I was removed from the call, rejoin.
|
||||||
|
LOG(("Call Info: Rejoin after got 'left' with my source."));
|
||||||
setState(State::Joining);
|
setState(State::Joining);
|
||||||
rejoin();
|
rejoin();
|
||||||
} else if (!data.is_left() && data.vsource().v != _mySsrc) {
|
} else if (!data.is_left() && data.vsource().v != _mySsrc) {
|
||||||
// I joined from another device, hangup.
|
// I joined from another device, hangup.
|
||||||
|
LOG(("Call Info: Hangup after '!left' with source %1, my %2."
|
||||||
|
).arg(data.vsource().v
|
||||||
|
).arg(_mySsrc));
|
||||||
_mySsrc = 0;
|
_mySsrc = 0;
|
||||||
hangup();
|
hangup();
|
||||||
}
|
}
|
||||||
|
@ -550,11 +566,14 @@ void GroupCall::checkJoined() {
|
||||||
MTP_int(_mySsrc)
|
MTP_int(_mySsrc)
|
||||||
)).done([=](const MTPBool &result) {
|
)).done([=](const MTPBool &result) {
|
||||||
if (!mtpIsTrue(result)) {
|
if (!mtpIsTrue(result)) {
|
||||||
|
LOG(("Call Info: Rejoin after FALSE in checkGroupCall."));
|
||||||
rejoin();
|
rejoin();
|
||||||
} else if (state() == State::Connecting) {
|
} else if (state() == State::Connecting) {
|
||||||
_checkJoinedTimer.callOnce(kCheckJoinedTimeout);
|
_checkJoinedTimer.callOnce(kCheckJoinedTimeout);
|
||||||
}
|
}
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
|
LOG(("Call Info: Rejoin after error '%1' in checkGroupCall."
|
||||||
|
).arg(error.type()));
|
||||||
rejoin();
|
rejoin();
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
@ -585,6 +604,8 @@ void GroupCall::sendMutedUpdate() {
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
_updateMuteRequestId = 0;
|
_updateMuteRequestId = 0;
|
||||||
if (error.type() == u"GROUP_CALL_FORBIDDEN"_q) {
|
if (error.type() == u"GROUP_CALL_FORBIDDEN"_q) {
|
||||||
|
LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember."
|
||||||
|
).arg(error.type()));
|
||||||
rejoin();
|
rejoin();
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
|
@ -615,6 +636,8 @@ void GroupCall::toggleMute(not_null<UserData*> user, bool mute) {
|
||||||
_channel->session().api().applyUpdates(result);
|
_channel->session().api().applyUpdates(result);
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
if (error.type() == u"GROUP_CALL_FORBIDDEN"_q) {
|
if (error.type() == u"GROUP_CALL_FORBIDDEN"_q) {
|
||||||
|
LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember."
|
||||||
|
).arg(error.type()));
|
||||||
rejoin();
|
rejoin();
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
|
|
|
@ -5413,12 +5413,14 @@ void HistoryWidget::setupGroupCallTracker() {
|
||||||
const auto channel = _history->peer->asChannel();
|
const auto channel = _history->peer->asChannel();
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (channel->amAnonymous()) {
|
||||||
const auto call = channel->call();
|
Ui::ShowMultilineToast({
|
||||||
if (!call) {
|
.text = tr::lng_group_call_no_anonymous(tr::now),
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
} else if (const auto call = channel->call()) {
|
||||||
Core::App().calls().joinGroupCall(channel, call->input());
|
Core::App().calls().joinGroupCall(channel, call->input());
|
||||||
|
}
|
||||||
}, _groupCallBar->lifetime());
|
}, _groupCallBar->lifetime());
|
||||||
|
|
||||||
_groupCallBarHeight = 0;
|
_groupCallBarHeight = 0;
|
||||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/dropdown_menu.h"
|
#include "ui/widgets/dropdown_menu.h"
|
||||||
#include "ui/effects/radial_animation.h"
|
#include "ui/effects/radial_animation.h"
|
||||||
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/special_buttons.h"
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/unread_badge.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
@ -212,7 +213,11 @@ void TopBarWidget::onCall() {
|
||||||
if (const auto user = peer->asUser()) {
|
if (const auto user = peer->asUser()) {
|
||||||
Core::App().calls().startOutgoingCall(user, false);
|
Core::App().calls().startOutgoingCall(user, false);
|
||||||
} else if (const auto megagroup = peer->asMegagroup()) {
|
} else if (const auto megagroup = peer->asMegagroup()) {
|
||||||
if (const auto call = megagroup->call()) {
|
if (megagroup->amAnonymous()) {
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.text = tr::lng_group_call_no_anonymous(tr::now),
|
||||||
|
});
|
||||||
|
} else if (const auto call = megagroup->call()) {
|
||||||
Core::App().calls().joinGroupCall(megagroup, call->input());
|
Core::App().calls().joinGroupCall(megagroup, call->input());
|
||||||
} else {
|
} else {
|
||||||
Core::App().calls().startGroupCall(megagroup);
|
Core::App().calls().startGroupCall(megagroup);
|
||||||
|
|
Loading…
Add table
Reference in a new issue