Forbid anonymous admins joining group calls.
This commit is contained in:
parent
d773f2c765
commit
d5216a30c7
|
@ -1477,6 +1477,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_game_tag" = "Game";
|
||||
|
||||
"lng_context_view_profile" = "View profile";
|
||||
"lng_context_send_message" = "Send message";
|
||||
"lng_context_view_group" = "View group info";
|
||||
"lng_context_view_channel" = "View channel 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_members#one" = "{count} member";
|
||||
"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.";
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "apiwrap.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "ui/toasts/common_toasts.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
|
@ -112,16 +113,22 @@ void GroupCall::setState(State state) {
|
|||
}
|
||||
|
||||
void GroupCall::start() {
|
||||
const auto randomId = rand_value<int32>();
|
||||
_createRequestId = _api.request(MTPphone_CreateGroupCall(
|
||||
_channel->inputChannel,
|
||||
MTP_int(randomId)
|
||||
MTP_int(rand_value<int32>())
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
_acceptFields = true;
|
||||
_channel->session().api().applyUpdates(result);
|
||||
_acceptFields = false;
|
||||
}).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();
|
||||
}
|
||||
|
||||
|
@ -206,6 +213,11 @@ void GroupCall::rejoin() {
|
|||
LOG(("Call Error: Could not join, 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();
|
||||
});
|
||||
});
|
||||
|
@ -401,10 +413,14 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
|||
}
|
||||
if (data.is_left() && data.vsource().v == _mySsrc) {
|
||||
// I was removed from the call, rejoin.
|
||||
LOG(("Call Info: Rejoin after got 'left' with my source."));
|
||||
setState(State::Joining);
|
||||
rejoin();
|
||||
} else if (!data.is_left() && data.vsource().v != _mySsrc) {
|
||||
// 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;
|
||||
hangup();
|
||||
}
|
||||
|
@ -550,11 +566,14 @@ void GroupCall::checkJoined() {
|
|||
MTP_int(_mySsrc)
|
||||
)).done([=](const MTPBool &result) {
|
||||
if (!mtpIsTrue(result)) {
|
||||
LOG(("Call Info: Rejoin after FALSE in checkGroupCall."));
|
||||
rejoin();
|
||||
} else if (state() == State::Connecting) {
|
||||
_checkJoinedTimer.callOnce(kCheckJoinedTimeout);
|
||||
}
|
||||
}).fail([=](const RPCError &error) {
|
||||
LOG(("Call Info: Rejoin after error '%1' in checkGroupCall."
|
||||
).arg(error.type()));
|
||||
rejoin();
|
||||
}).send();
|
||||
}
|
||||
|
@ -585,6 +604,8 @@ void GroupCall::sendMutedUpdate() {
|
|||
}).fail([=](const RPCError &error) {
|
||||
_updateMuteRequestId = 0;
|
||||
if (error.type() == u"GROUP_CALL_FORBIDDEN"_q) {
|
||||
LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember."
|
||||
).arg(error.type()));
|
||||
rejoin();
|
||||
}
|
||||
}).send();
|
||||
|
@ -615,6 +636,8 @@ void GroupCall::toggleMute(not_null<UserData*> user, bool mute) {
|
|||
_channel->session().api().applyUpdates(result);
|
||||
}).fail([=](const RPCError &error) {
|
||||
if (error.type() == u"GROUP_CALL_FORBIDDEN"_q) {
|
||||
LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember."
|
||||
).arg(error.type()));
|
||||
rejoin();
|
||||
}
|
||||
}).send();
|
||||
|
|
|
@ -5413,12 +5413,14 @@ void HistoryWidget::setupGroupCallTracker() {
|
|||
const auto channel = _history->peer->asChannel();
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
const auto call = channel->call();
|
||||
if (!call) {
|
||||
} else if (channel->amAnonymous()) {
|
||||
Ui::ShowMultilineToast({
|
||||
.text = tr::lng_group_call_no_anonymous(tr::now),
|
||||
});
|
||||
return;
|
||||
} else if (const auto call = channel->call()) {
|
||||
Core::App().calls().joinGroupCall(channel, call->input());
|
||||
}
|
||||
Core::App().calls().joinGroupCall(channel, call->input());
|
||||
}, _groupCallBar->lifetime());
|
||||
|
||||
_groupCallBarHeight = 0;
|
||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "ui/effects/radial_animation.h"
|
||||
#include "ui/toasts/common_toasts.h"
|
||||
#include "ui/special_buttons.h"
|
||||
#include "ui/unread_badge.h"
|
||||
#include "ui/ui_utility.h"
|
||||
|
@ -212,7 +213,11 @@ void TopBarWidget::onCall() {
|
|||
if (const auto user = peer->asUser()) {
|
||||
Core::App().calls().startOutgoingCall(user, false);
|
||||
} 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());
|
||||
} else {
|
||||
Core::App().calls().startGroupCall(megagroup);
|
||||
|
|
Loading…
Reference in New Issue