Add td_api::getAvailableVoiceChatAliases.
This commit is contained in:
parent
574884510b
commit
62cfe3bdd9
td
@ -4553,6 +4553,9 @@ sendCallRating call_id:int32 rating:int32 comment:string problems:vector<CallPro
|
||||
sendCallDebugInformation call_id:int32 debug_information:string = Ok;
|
||||
|
||||
|
||||
//@description Returns list of user and chat, which can be used as aliases to join a voice chat in the chat @chat_id Chat identifier
|
||||
getAvailableVoiceChatAliases chat_id:int53 = MessageSenders;
|
||||
|
||||
//@description Creates a voice chat (a group call bound to a chat). Available only for basic groups, supergroups and channels; requires can_manage_voice_chats rights @chat_id Chat identifier
|
||||
createVoiceChat chat_id:int53 = GroupCallId;
|
||||
|
||||
@ -4561,7 +4564,7 @@ getGroupCall group_call_id:int32 = GroupCall;
|
||||
|
||||
//@description Joins a group call
|
||||
//@group_call_id Group call identifier
|
||||
//@participant_alias Identifier of the group call participant, which will be used to join the call
|
||||
//@participant_alias Identifier of the group call participant, which will be used to join the call; voice chats only
|
||||
//@payload Group join payload; received from tgcalls
|
||||
//@source Caller synchronization source identifier; received from tgcalls
|
||||
//@is_muted True, if the user's microphone is muted
|
||||
|
@ -31,6 +31,60 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class GetGroupCallJoinAsQuery : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::messageSenders>> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit GetGroupCallJoinAsQuery(Promise<td_api::object_ptr<td_api::messageSenders>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id) {
|
||||
dialog_id_ = dialog_id;
|
||||
|
||||
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||
CHECK(input_peer != nullptr);
|
||||
|
||||
send_query(G()->net_query_creator().create(telegram_api::phone_getGroupCallJoinAs(std::move(input_peer))));
|
||||
}
|
||||
|
||||
void on_result(uint64 id, BufferSlice packet) override {
|
||||
auto result_ptr = fetch_result<telegram_api::phone_getGroupCallJoinAs>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(id, result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetGroupCallJoinAsQuery: " << to_string(ptr);
|
||||
|
||||
td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetGroupCallJoinAsQuery");
|
||||
td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery");
|
||||
|
||||
vector<td_api::object_ptr<td_api::MessageSender>> participant_aliaces;
|
||||
for (auto &peer : ptr->peers_) {
|
||||
DialogId dialog_id(peer);
|
||||
if (!dialog_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << dialog_id << " as join as peer for " << dialog_id_;
|
||||
continue;
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::User) {
|
||||
td->messages_manager_->force_create_dialog(dialog_id, "GetGroupCallJoinAsQuery");
|
||||
}
|
||||
|
||||
participant_aliaces.push_back(td->messages_manager_->get_message_sender_object(dialog_id));
|
||||
}
|
||||
|
||||
promise_.set_value(td_api::make_object<td_api::messageSenders>(static_cast<int32>(participant_aliaces.size()),
|
||||
std::move(participant_aliaces)));
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class CreateGroupCallQuery : public Td::ResultHandler {
|
||||
Promise<InputGroupCallId> promise_;
|
||||
DialogId dialog_id_;
|
||||
@ -780,6 +834,21 @@ bool GroupCallManager::can_manage_group_call(InputGroupCallId input_group_call_i
|
||||
return can_manage_group_calls(group_call->dialog_id).is_ok();
|
||||
}
|
||||
|
||||
void GroupCallManager::get_group_call_join_as(DialogId dialog_id,
|
||||
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise) {
|
||||
if (!dialog_id.is_valid()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
|
||||
}
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id)) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access chat"));
|
||||
}
|
||||
|
||||
td_->create_handler<GetGroupCallJoinAsQuery>(std::move(promise))->send(dialog_id);
|
||||
}
|
||||
|
||||
void GroupCallManager::create_voice_chat(DialogId dialog_id, Promise<GroupCallId> &&promise) {
|
||||
if (!dialog_id.is_valid()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
|
||||
|
@ -45,6 +45,8 @@ class GroupCallManager : public Actor {
|
||||
|
||||
GroupCallId get_group_call_id(InputGroupCallId input_group_call_id, DialogId dialog_id);
|
||||
|
||||
void get_group_call_join_as(DialogId dialog_id, Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
||||
|
||||
void create_voice_chat(DialogId dialog_id, Promise<GroupCallId> &&promise);
|
||||
|
||||
void get_group_call(GroupCallId group_call_id, Promise<td_api::object_ptr<td_api::groupCall>> &&promise);
|
||||
|
@ -5963,6 +5963,12 @@ void Td::on_request(uint64 id, td_api::sendCallDebugInformation &request) {
|
||||
std::move(request.debug_information_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getAvailableVoiceChatAliases &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
group_call_manager_->get_group_call_join_as(DialogId(request.chat_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::createVoiceChat &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -699,6 +699,8 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, td_api::sendCallDebugInformation &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getAvailableVoiceChatAliases &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::createVoiceChat &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getGroupCall &request);
|
||||
|
@ -2665,6 +2665,8 @@ class CliClient final : public Actor {
|
||||
as_call_id(call_id), rating, "Wow, such good call! (TDLib test)", std::move(problems)));
|
||||
} else if (op == "scdi" || op == "SendCallDebugInformation") {
|
||||
send_request(td_api::make_object<td_api::sendCallDebugInformation>(as_call_id(args), "{}"));
|
||||
} else if (op == "gavca") {
|
||||
send_request(td_api::make_object<td_api::getAvailableVoiceChatAliases>(as_chat_id(args)));
|
||||
} else if (op == "cvc") {
|
||||
send_request(td_api::make_object<td_api::createVoiceChat>(as_chat_id(args)));
|
||||
} else if (op == "ggc") {
|
||||
|
Loading…
Reference in New Issue
Block a user