Update layer 122.

This commit is contained in:
levlam 2020-11-29 15:41:03 +03:00
parent 3e95f8d9cc
commit 7f9681313a
12 changed files with 71 additions and 44 deletions

View File

@ -1632,8 +1632,8 @@ messageCall is_video:Bool discard_reason:CallDiscardReason duration:int32 = Mess
//@description A message with information about a group call @group_call_id Group call identifier @duration Call duration; for finished calls only
messageGroupCall group_call_id:string duration:int32 = MessageContent;
//@description A message with information about an invite to a group call @group_call_id Group call identifier @user_id Invited user identifier
messageInviteToGroupCall group_call_id:string user_id:int32 = MessageContent;
//@description A message with information about an invite to a group call @group_call_id Group call identifier @user_ids Invited user identifiers
messageInviteGroupCallMembers group_call_id:string user_ids:vector<int32> = MessageContent;
//@description A newly created basic group @title Title of the basic group @member_user_ids User identifiers of members in the basic group
messageBasicGroupChatCreate title:string member_user_ids:vector<int32> = MessageContent;
@ -4320,9 +4320,9 @@ joinGroupCall group_call_id:string payload:groupCallPayload source:int32 is_mute
//@group_call_id Group call identifier @mute_new_members New value of the mute_new_members setting
toggleGroupCallMuteNewMembers group_call_id:string mute_new_members:Bool = Ok;
//@description Invites a user to a chat group call by sending a service message of type messageInviteToGroupCall
//@group_call_id Group call identifier @user_id User identifier
inviteGroupCallMember group_call_id:string user_id:int32 = Ok;
//@description Invites users to a group call. Sends a service message of type messageInviteToGroupCall for voice chats
//@group_call_id Group call identifier @user_ids User identifiers
inviteGroupCallMembers group_call_id:string user_ids:vector<int32> = Ok;
//@description Toggles whether a group call member is muted. Requires can_manage_calls rights to mute other group call members
//@group_call_id Group call identifier @user_id User identifier @is_muted Pass true if the user must be muted and false otherwise

Binary file not shown.

View File

@ -170,7 +170,7 @@ messageActionSecureValuesSent#d95c6154 types:Vector<SecureValueType> = MessageAc
messageActionContactSignUp#f3f25f76 = MessageAction;
messageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = MessageAction;
messageActionGroupCall#7a0d7f42 flags:# call:InputGroupCall duration:flags.0?int = MessageAction;
messageActionInviteToGroupCall#f25f03a call:InputGroupCall user_id:int = MessageAction;
messageActionInviteToGroupCall#76b9f11a call:InputGroupCall users:Vector<int> = MessageAction;
dialog#2c171f72 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog;
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
@ -1178,7 +1178,7 @@ inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall;
groupCallParticipant#56b087c9 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true user_id:int date:int active_date:flags.3?int source:int = GroupCallParticipant;
phone.groupCall#985c2087 call:GroupCall sources:Vector<int> participants:Vector<GroupCallParticipant> participants_next_offset:string users:Vector<User> = phone.GroupCall;
phone.groupCall#66ab0bfc call:GroupCall participants:Vector<GroupCallParticipant> participants_next_offset:string users:Vector<User> = phone.GroupCall;
phone.groupParticipants#9cfeb92d count:int participants:Vector<GroupCallParticipant> next_offset:string users:Vector<User> version:int = phone.GroupParticipants;
@ -1540,11 +1540,11 @@ phone.createGroupCall#e428fa02 channel:InputChannel random_id:int = Updates;
phone.joinGroupCall#5f9c8e62 flags:# muted:flags.0?true call:InputGroupCall params:DataJSON = Updates;
phone.leaveGroupCall#500377f9 call:InputGroupCall source:int = Updates;
phone.editGroupCallMember#63146ae4 flags:# muted:flags.0?true call:InputGroupCall user_id:InputUser = Updates;
phone.inviteToGroupCall#dd698f84 call:InputGroupCall user_id:InputUser = Updates;
phone.inviteToGroupCall#7b393160 call:InputGroupCall users:Vector<InputUser> = Updates;
phone.discardGroupCall#7a777135 call:InputGroupCall = Updates;
phone.toggleGroupCallSettings#74bbb43d flags:# call:InputGroupCall join_muted:flags.0?Bool = Updates;
phone.getGroupCall#c7cb017 call:InputGroupCall = phone.GroupCall;
phone.getGroupParticipants#ae1910a4 call:InputGroupCall offset:string limit:int = phone.GroupParticipants;
phone.getGroupParticipants#c9f1d285 call:InputGroupCall ids:Vector<int> sources:Vector<int> offset:string limit:int = phone.GroupParticipants;
phone.checkGroupCall#b74a7bea call:InputGroupCall source:int = Bool;
langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference;

Binary file not shown.

View File

@ -141,12 +141,9 @@ class InviteToGroupCallQuery : public Td::ResultHandler {
explicit InviteToGroupCallQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(InputGroupCallId group_call_id, UserId user_id) {
auto input_user = td->contacts_manager_->get_input_user(user_id);
CHECK(input_user != nullptr);
void send(InputGroupCallId group_call_id, vector<tl_object_ptr<telegram_api::InputUser>> input_users) {
send_query(G()->net_query_creator().create(
telegram_api::phone_inviteToGroupCall(group_call_id.get_input_group_call(), std::move(input_user))));
telegram_api::phone_inviteToGroupCall(group_call_id.get_input_group_call(), std::move(input_users))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -511,16 +508,32 @@ void GroupCallManager::toggle_group_call_mute_new_members(InputGroupCallId group
td_->create_handler<ToggleGroupCallSettingsQuery>(std::move(promise))->send(flags, group_call_id, mute_new_members);
}
void GroupCallManager::invite_group_call_member(InputGroupCallId group_call_id, UserId user_id,
Promise<Unit> &&promise) {
if (!td_->contacts_manager_->have_input_user(user_id)) {
return promise.set_error(Status::Error(400, "Have no access to the user"));
void GroupCallManager::invite_group_call_members(InputGroupCallId group_call_id, vector<UserId> &&user_ids,
Promise<Unit> &&promise) {
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
auto my_user_id = td_->contacts_manager_->get_my_id();
for (auto user_id : user_ids) {
auto input_user = td_->contacts_manager_->get_input_user(user_id);
if (input_user == nullptr) {
return promise.set_error(Status::Error(400, "User not found"));
}
if (user_id == my_user_id) {
// can't invite self
continue;
}
input_users.push_back(std::move(input_user));
}
td_->create_handler<InviteToGroupCallQuery>(std::move(promise))->send(group_call_id, user_id);
if (input_users.empty()) {
return promise.set_value(Unit());
}
td_->create_handler<InviteToGroupCallQuery>(std::move(promise))->send(group_call_id, std::move(input_users));
}
void GroupCallManager::toggle_group_call_member_is_muted(InputGroupCallId group_call_id, UserId user_id,
bool is_muted, Promise<Unit> &&promise) {
void GroupCallManager::toggle_group_call_member_is_muted(InputGroupCallId group_call_id, UserId user_id, bool is_muted,
Promise<Unit> &&promise) {
if (!td_->contacts_manager_->have_input_user(user_id)) {
return promise.set_error(Status::Error(400, "Have no access to the user"));
}

View File

@ -39,7 +39,7 @@ class GroupCallManager : public Actor {
void toggle_group_call_mute_new_members(InputGroupCallId group_call_id, bool mute_new_members,
Promise<Unit> &&promise);
void invite_group_call_member(InputGroupCallId group_call_id, UserId user_id, Promise<Unit> &&promise);
void invite_group_call_members(InputGroupCallId group_call_id, vector<UserId> &&user_ids, Promise<Unit> &&promise);
void toggle_group_call_member_is_muted(InputGroupCallId group_call_id, UserId user_id, bool is_muted,
Promise<Unit> &&promise);

View File

@ -724,11 +724,11 @@ class MessageGroupCall : public MessageContent {
class MessageInviteToGroupCall : public MessageContent {
public:
InputGroupCallId group_call_id;
UserId user_id;
vector<UserId> user_ids;
MessageInviteToGroupCall() = default;
MessageInviteToGroupCall(InputGroupCallId group_call_id, UserId user_id)
: group_call_id(group_call_id), user_id(user_id) {
MessageInviteToGroupCall(InputGroupCallId group_call_id, vector<UserId> &&user_ids)
: group_call_id(group_call_id), user_ids(std::move(user_ids)) {
}
MessageContentType get_type() const override {
@ -1023,7 +1023,7 @@ static void store(const MessageContent *content, StorerT &storer) {
case MessageContentType::InviteToGroupCall: {
auto m = static_cast<const MessageInviteToGroupCall *>(content);
store(m->group_call_id, storer);
store(m->user_id, storer);
store(m->user_ids, storer);
break;
}
default:
@ -1416,7 +1416,7 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
case MessageContentType::InviteToGroupCall: {
auto m = make_unique<MessageInviteToGroupCall>();
parse(m->group_call_id, parser);
parse(m->user_id, parser);
parse(m->user_ids, parser);
content = std::move(m);
break;
}
@ -3311,7 +3311,7 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
case MessageContentType::InviteToGroupCall: {
auto old_ = static_cast<const MessageInviteToGroupCall *>(old_content);
auto new_ = static_cast<const MessageInviteToGroupCall *>(new_content);
if (old_->group_call_id != new_->group_call_id || old_->user_id != new_->user_id) {
if (old_->group_call_id != new_->group_call_id || old_->user_ids != new_->user_ids) {
need_update = true;
}
if (!old_->group_call_id.is_identical(new_->group_call_id)) {
@ -4557,13 +4557,20 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
}
case telegram_api::messageActionInviteToGroupCall::ID: {
auto invite_to_group_call = move_tl_object_as<telegram_api::messageActionInviteToGroupCall>(action);
UserId user_id(invite_to_group_call->user_id_);
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive messageActionInviteToGroupCall with invalid " << user_id << " in " << owner_dialog_id;
break;
vector<UserId> user_ids;
user_ids.reserve(invite_to_group_call->users_.size());
for (auto &user : invite_to_group_call->users_) {
UserId user_id(user);
if (user_id.is_valid()) {
user_ids.push_back(user_id);
} else {
LOG(ERROR) << "Receive messageActionInviteToGroupCall with invalid " << user_id << " in " << owner_dialog_id;
}
}
return make_unique<MessageInviteToGroupCall>(InputGroupCallId(invite_to_group_call->call_), user_id);
return td::make_unique<MessageInviteToGroupCall>(InputGroupCallId(invite_to_group_call->call_),
std::move(user_ids));
}
default:
UNREACHABLE();
@ -4781,9 +4788,9 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
}
case MessageContentType::InviteToGroupCall: {
auto *m = static_cast<const MessageInviteToGroupCall *>(content);
return make_tl_object<td_api::messageInviteToGroupCall>(
return make_tl_object<td_api::messageInviteGroupCallMembers>(
m->group_call_id.get_group_call_id(),
td->contacts_manager_->get_user_id_object(m->user_id, "MessageInviteToGroupCall"));
td->contacts_manager_->get_user_ids_object(m->user_ids, "MessageInviteToGroupCall"));
}
default:
UNREACHABLE();
@ -5302,7 +5309,7 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
break;
case MessageContentType::InviteToGroupCall: {
auto content = static_cast<const MessageInviteToGroupCall *>(message_content);
dependencies.user_ids.insert(content->user_id);
dependencies.user_ids.insert(content->user_ids.begin(), content->user_ids.end());
break;
}
default:

View File

@ -6058,12 +6058,16 @@ void Td::on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &requ
group_call_manager_->toggle_group_call_mute_new_members(group_call_id, request.mute_new_members_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::inviteGroupCallMember &request) {
void Td::on_request(uint64 id, const td_api::inviteGroupCallMembers &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
TRY_RESULT_PROMISE(promise, group_call_id, InputGroupCallId::from_group_call_id(request.group_call_id_));
group_call_manager_->invite_group_call_member(group_call_id, UserId(request.user_id_), std::move(promise));
vector<UserId> user_ids;
for (auto &user_id : request.user_ids_) {
user_ids.emplace_back(user_id);
}
group_call_manager_->invite_group_call_members(group_call_id, std::move(user_ids), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleGroupCallMemberIsMuted &request) {

View File

@ -698,7 +698,7 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &request);
void on_request(uint64 id, const td_api::inviteGroupCallMember &request);
void on_request(uint64 id, const td_api::inviteGroupCallMembers &request);
void on_request(uint64 id, const td_api::toggleGroupCallMemberIsMuted &request);

View File

@ -618,8 +618,10 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
}
case telegram_api::messageActionInviteToGroupCall::ID: {
auto invite_to_group_call = static_cast<const telegram_api::messageActionInviteToGroupCall *>(action);
if (!is_acceptable_user(UserId(invite_to_group_call->user_id_))) {
return false;
for (auto &user : invite_to_group_call->users_) {
if (!is_acceptable_user(UserId(user))) {
return false;
}
}
break;
}

View File

@ -2853,10 +2853,10 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::toggleGroupCallMuteNewMembers>(as_group_call_id(args), op == "tgcmnme"));
} else if (op == "igcm") {
string group_call_id;
string user_id;
std::tie(group_call_id, user_id) = split(args);
string user_ids;
std::tie(group_call_id, user_ids) = split(args);
send_request(
td_api::make_object<td_api::inviteGroupCallMember>(as_group_call_id(group_call_id), as_user_id(user_id)));
td_api::make_object<td_api::inviteGroupCallMembers>(as_group_call_id(group_call_id), as_user_ids(user_ids)));
} else if (op == "tgcmim") {
string group_call_id;
string user_id;

View File

@ -12,6 +12,7 @@
#include "td/utils/misc.h"
#include "td/utils/Random.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/PromiseFuture.h"
#include "td/actor/MultiPromise.h"
#include "td/telegram/td_api_json.h"