Allow to join group call as a chat.
This commit is contained in:
parent
7a19e5dbe5
commit
c611553ece
@ -4553,8 +4553,8 @@ createVoiceChat chat_id:int53 = GroupCallId;
|
||||
//@description Returns information about a group call @group_call_id Group call identifier
|
||||
getGroupCall group_call_id:int32 = GroupCall;
|
||||
|
||||
//@description Joins a group call @group_call_id Group call identifier @payload Group join payload, received from tgcalls. Use null to cancel previous joinGroupCall request @source Caller synchronization source identifier; received from tgcalls @is_muted True, if the user's microphone is muted
|
||||
joinGroupCall group_call_id:int32 payload:groupCallPayload source:int32 is_muted:Bool = GroupCallJoinResponse;
|
||||
//@description Joins a group call @group_call_id Group call identifier @as_chat_id If not 0, identifier of the chat, which will be used to join the call @payload Group join payload, received from tgcalls. Use null to cancel previous joinGroupCall request @source Caller synchronization source identifier; received from tgcalls @is_muted True, if the user's microphone is muted
|
||||
joinGroupCall group_call_id:int32 as_chat_id:int53 payload:groupCallPayload source:int32 is_muted:Bool = GroupCallJoinResponse;
|
||||
|
||||
//@description Sets group call title. Requires groupCall.can_be_managed group call flag @group_call_id Group call identifier @title New group call title; 1-128 characters
|
||||
setGroupCallTitle group_call_id:int32 title:string = Ok;
|
||||
|
@ -184,18 +184,25 @@ class GetGroupCallParticipantsQuery : public Td::ResultHandler {
|
||||
class JoinGroupCallQuery : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
InputGroupCallId input_group_call_id_;
|
||||
DialogId as_dialog_id_;
|
||||
uint64 generation_ = 0;
|
||||
|
||||
public:
|
||||
explicit JoinGroupCallQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
NetQueryRef send(InputGroupCallId input_group_call_id, const string &payload, bool is_muted, uint64 generation) {
|
||||
NetQueryRef send(InputGroupCallId input_group_call_id, DialogId as_dialog_id, const string &payload, bool is_muted,
|
||||
uint64 generation) {
|
||||
input_group_call_id_ = input_group_call_id;
|
||||
as_dialog_id_ = as_dialog_id;
|
||||
generation_ = generation;
|
||||
|
||||
auto join_as_input_peer =
|
||||
td->messages_manager_->get_input_peer(DialogId(td->contacts_manager_->get_my_id()), AccessRights::Read);
|
||||
tl_object_ptr<telegram_api::InputPeer> join_as_input_peer;
|
||||
if (as_dialog_id.is_valid()) {
|
||||
join_as_input_peer = td->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Read);
|
||||
} else {
|
||||
join_as_input_peer = make_tl_object<telegram_api::inputPeerSelf>();
|
||||
}
|
||||
CHECK(join_as_input_peer != nullptr);
|
||||
|
||||
int32 flags = 0;
|
||||
@ -1526,7 +1533,7 @@ int32 GroupCallManager::cancel_join_group_call_request(InputGroupCallId input_gr
|
||||
return audio_source;
|
||||
}
|
||||
|
||||
void GroupCallManager::join_group_call(GroupCallId group_call_id,
|
||||
void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_dialog_id,
|
||||
td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source,
|
||||
bool is_muted,
|
||||
Promise<td_api::object_ptr<td_api::groupCallJoinResponse>> &&promise) {
|
||||
@ -1546,6 +1553,15 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id,
|
||||
|
||||
cancel_join_group_call_request(input_group_call_id);
|
||||
|
||||
if (as_dialog_id != DialogId()) {
|
||||
if (!td_->messages_manager_->have_dialog_force(as_dialog_id)) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->messages_manager_->have_input_peer(as_dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
}
|
||||
|
||||
if (audio_source == 0) {
|
||||
return promise.set_error(Status::Error(400, "Audio source must be non-zero"));
|
||||
}
|
||||
@ -1606,12 +1622,20 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id,
|
||||
result.move_as_error());
|
||||
});
|
||||
request->query_ref = td_->create_handler<JoinGroupCallQuery>(std::move(query_promise))
|
||||
->send(input_group_call_id, json_payload, is_muted, generation);
|
||||
->send(input_group_call_id, as_dialog_id, json_payload, is_muted, generation);
|
||||
|
||||
if (group_call->is_inited && td_->contacts_manager_->have_user_force(td_->contacts_manager_->get_my_id())) {
|
||||
if (group_call->is_inited) {
|
||||
GroupCallParticipant group_call_participant;
|
||||
group_call_participant.is_self = true;
|
||||
group_call_participant.dialog_id = DialogId(td_->contacts_manager_->get_my_id());
|
||||
if (as_dialog_id.is_valid()) {
|
||||
// dialog already exists
|
||||
group_call_participant.dialog_id = as_dialog_id;
|
||||
} else {
|
||||
// create dialog with self
|
||||
DialogId my_dialog_id(td_->contacts_manager_->get_my_id());
|
||||
td_->messages_manager_->force_create_dialog(my_dialog_id, "join_group_call");
|
||||
group_call_participant.dialog_id = my_dialog_id;
|
||||
}
|
||||
group_call_participant.audio_source = audio_source;
|
||||
group_call_participant.joined_date = G()->unix_time();
|
||||
// if can_self_unmute has never been inited from self-participant,
|
||||
|
@ -50,8 +50,8 @@ class GroupCallManager : public Actor {
|
||||
void reload_group_call(InputGroupCallId input_group_call_id,
|
||||
Promise<td_api::object_ptr<td_api::groupCall>> &&promise);
|
||||
|
||||
void join_group_call(GroupCallId group_call_id, td_api::object_ptr<td_api::groupCallPayload> &&payload,
|
||||
int32 audio_source, bool is_muted,
|
||||
void join_group_call(GroupCallId group_call_id, DialogId as_dialog_id,
|
||||
td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source, bool is_muted,
|
||||
Promise<td_api::object_ptr<td_api::groupCallJoinResponse>> &&promise);
|
||||
|
||||
void set_group_call_title(GroupCallId group_call_id, string title, Promise<Unit> &&promise);
|
||||
|
@ -5985,8 +5985,9 @@ void Td::on_request(uint64 id, const td_api::getGroupCall &request) {
|
||||
void Td::on_request(uint64 id, td_api::joinGroupCall &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
group_call_manager_->join_group_call(GroupCallId(request.group_call_id_), std::move(request.payload_),
|
||||
request.source_, request.is_muted_, std::move(promise));
|
||||
group_call_manager_->join_group_call(GroupCallId(request.group_call_id_), DialogId(request.as_chat_id_),
|
||||
std::move(request.payload_), request.source_, request.is_muted_,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setGroupCallTitle &request) {
|
||||
|
@ -2670,15 +2670,18 @@ class CliClient final : public Actor {
|
||||
} else if (op == "ggc") {
|
||||
send_request(td_api::make_object<td_api::getGroupCall>(as_group_call_id(args)));
|
||||
} else if (op == "jgc") {
|
||||
string group_call_id;
|
||||
string chat_id;
|
||||
get_args(args, group_call_id, chat_id);
|
||||
vector<td_api::object_ptr<td_api::groupCallPayloadFingerprint>> fingerprints;
|
||||
fingerprints.push_back(td_api::make_object<td_api::groupCallPayloadFingerprint>("hash", "setup", "fingerprint"));
|
||||
fingerprints.push_back(td_api::make_object<td_api::groupCallPayloadFingerprint>("h2", "s2", "fingerprint2"));
|
||||
send_request(td_api::make_object<td_api::joinGroupCall>(
|
||||
as_group_call_id(args),
|
||||
as_group_call_id(group_call_id), as_chat_id(chat_id),
|
||||
td_api::make_object<td_api::groupCallPayload>("ufrag", "pwd", std::move(fingerprints)), group_call_source_,
|
||||
true));
|
||||
} else if (op == "jgcc") {
|
||||
send_request(td_api::make_object<td_api::joinGroupCall>(as_group_call_id(args), nullptr, 0, true));
|
||||
send_request(td_api::make_object<td_api::joinGroupCall>(as_group_call_id(args), 0, nullptr, 0, true));
|
||||
} else if (op == "sgct") {
|
||||
string chat_id;
|
||||
string title;
|
||||
|
Loading…
Reference in New Issue
Block a user