Add groupCall.scheduled_start_date.

This commit is contained in:
levlam 2021-04-06 12:08:47 +03:00
parent 2241058f85
commit 49fecf40e6
2 changed files with 25 additions and 4 deletions

View File

@ -1702,7 +1702,7 @@ messageInvoice title:string description:string photo:photo currency:string total
//@description A message with information about an ended call @is_video True, if the call was a video call @discard_reason Reason why the call was discarded @duration Call duration, in seconds //@description A message with information about an ended call @is_video True, if the call was a video call @discard_reason Reason why the call was discarded @duration Call duration, in seconds
messageCall is_video:Bool discard_reason:CallDiscardReason duration:int32 = MessageContent; messageCall is_video:Bool discard_reason:CallDiscardReason duration:int32 = MessageContent;
//@description A new voice chat was scheduled @group_call_id Identifier of the voice chat. The voice chat can be received through the method getGroupCall @start_date Point in time (Unix timestamp) when the group call will be started //@description A new voice chat was scheduled @group_call_id Identifier of the voice chat. The voice chat can be received through the method getGroupCall @start_date Point in time (Unix timestamp) when the group call is supposed to be started by an administrator
messageVoiceChatScheduled group_call_id:int32 start_date:int32 = MessageContent; messageVoiceChatScheduled group_call_id:int32 start_date:int32 = MessageContent;
//@description A newly created voice chat @group_call_id Identifier of the voice chat. The voice chat can be received through the method getGroupCall //@description A newly created voice chat @group_call_id Identifier of the voice chat. The voice chat can be received through the method getGroupCall
@ -2144,6 +2144,7 @@ groupCallRecentSpeaker speaker:MessageSender is_speaking:Bool = GroupCallRecentS
//@description Describes a group call //@description Describes a group call
//@id Group call identifier //@id Group call identifier
//@title Group call title //@title Group call title
//@scheduled_start_date Point in time (Unix timestamp) when the group call is supposed to be started by an administrator; 0 if it is already active or was ended
//@is_active True, if the call is active //@is_active True, if the call is active
//@is_joined True, if the call is joined //@is_joined True, if the call is joined
//@need_rejoin True, if user was kicked from the call because of network loss and the call needs to be rejoined //@need_rejoin True, if user was kicked from the call because of network loss and the call needs to be rejoined
@ -2156,7 +2157,7 @@ groupCallRecentSpeaker speaker:MessageSender is_speaking:Bool = GroupCallRecentS
//@can_change_mute_new_participants True, if the current user can enable or disable mute_new_participants setting //@can_change_mute_new_participants True, if the current user can enable or disable mute_new_participants setting
//@record_duration Duration of the ongoing group call recording, in seconds; 0 if none. An updateGroupCall update is not triggered when value of this field changes, but the same recording goes on //@record_duration Duration of the ongoing group call recording, in seconds; 0 if none. An updateGroupCall update is not triggered when value of this field changes, but the same recording goes on
//@duration Call duration; for ended calls only //@duration Call duration; for ended calls only
groupCall id:int32 title:string is_active:Bool is_joined:Bool need_rejoin:Bool can_unmute_self:Bool can_be_managed:Bool participant_count:int32 loaded_all_participants:Bool recent_speakers:vector<groupCallRecentSpeaker> mute_new_participants:Bool can_change_mute_new_participants:Bool record_duration:int32 duration:int32 = GroupCall; groupCall id:int32 title:string scheduled_start_date:int32 is_active:Bool is_joined:Bool need_rejoin:Bool can_unmute_self:Bool can_be_managed:Bool participant_count:int32 loaded_all_participants:Bool recent_speakers:vector<groupCallRecentSpeaker> mute_new_participants:Bool can_change_mute_new_participants:Bool record_duration:int32 duration:int32 = GroupCall;
//@description Describes a payload fingerprint for interaction with tgcalls @hash Value of the field hash @setup Value of the field setup @fingerprint Value of the field fingerprint //@description Describes a payload fingerprint for interaction with tgcalls @hash Value of the field hash @setup Value of the field setup @fingerprint Value of the field fingerprint
groupCallPayloadFingerprint hash:string setup:string fingerprint:string = GroupCallPayloadFingerprint; groupCallPayloadFingerprint hash:string setup:string fingerprint:string = GroupCallPayloadFingerprint;
@ -4603,7 +4604,7 @@ 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 //@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, in which the voice chat will be created //@chat_id Chat identifier, in which the voice chat will be created
//@title Group call title; if empty, chat title will be used //@title Group call title; if empty, chat title will be used
//@start_date Point in time (Unix timestamp) when the group call will be started. Pass 0 to start the voice chat immediately //@start_date Point in time (Unix timestamp) when the group call is supposed to be started by an administrator. Pass 0 to start the voice chat immediately
createVoiceChat chat_id:int53 title:string start_date:int32 = GroupCallId; createVoiceChat chat_id:int53 title:string start_date:int32 = GroupCallId;
//@description Returns information about a group call @group_call_id Group call identifier //@description Returns information about a group call @group_call_id Group call identifier

View File

@ -650,6 +650,7 @@ struct GroupCallManager::GroupCall {
bool mute_new_participants = false; bool mute_new_participants = false;
bool allowed_change_mute_new_participants = false; bool allowed_change_mute_new_participants = false;
bool joined_date_asc = false; bool joined_date_asc = false;
int32 scheduled_start_date = 0;
int32 participant_count = 0; int32 participant_count = 0;
int32 duration = 0; int32 duration = 0;
int32 audio_source = 0; int32 audio_source = 0;
@ -664,6 +665,7 @@ struct GroupCallManager::GroupCall {
int32 mute_version = -1; int32 mute_version = -1;
int32 stream_dc_id_version = -1; int32 stream_dc_id_version = -1;
int32 record_start_date_version = -1; int32 record_start_date_version = -1;
int32 scheduled_start_date_version = -1;
vector<Promise<Unit>> after_join; vector<Promise<Unit>> after_join;
bool have_pending_mute_new_participants = false; bool have_pending_mute_new_participants = false;
@ -3358,11 +3360,20 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
call.record_start_date = 0; call.record_start_date = 0;
} }
} }
if ((group_call->flags_ & telegram_api::groupCall::SCHEDULE_DATE_MASK) != 0) {
call.scheduled_start_date = group_call->schedule_date_;
if (call.scheduled_start_date <= 0) {
LOG(ERROR) << "Receive invalid scheduled start date " << group_call->schedule_date_ << " in "
<< input_group_call_id;
call.scheduled_start_date = 0;
}
}
call.version = group_call->version_; call.version = group_call->version_;
call.title_version = group_call->version_; call.title_version = group_call->version_;
call.mute_version = group_call->version_; call.mute_version = group_call->version_;
call.stream_dc_id_version = group_call->version_; call.stream_dc_id_version = group_call->version_;
call.record_start_date_version = group_call->version_; call.record_start_date_version = group_call->version_;
call.scheduled_start_date_version = group_call->version_;
if (group_call->params_ != nullptr) { if (group_call->params_ != nullptr) {
join_params = std::move(group_call->params_->data_); join_params = std::move(group_call->params_->data_);
} }
@ -3471,6 +3482,13 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
need_update = true; need_update = true;
} }
} }
if (call.scheduled_start_date != group_call->scheduled_start_date &&
call.scheduled_start_date_version >= group_call->scheduled_start_date_version) {
LOG_IF(ERROR, group_call->scheduled_start_date == 0) << call.group_call_id << " became scheduled";
group_call->scheduled_start_date = call.scheduled_start_date;
group_call->scheduled_start_date_version = call.scheduled_start_date_version;
need_update = true;
}
if (call.version > group_call->version) { if (call.version > group_call->version) {
if (group_call->version != -1) { if (group_call->version != -1) {
// if we know group call version, then update participants only by corresponding updates // if we know group call version, then update participants only by corresponding updates
@ -3811,6 +3829,8 @@ tl_object_ptr<td_api::groupCall> GroupCallManager::get_group_call_object(
CHECK(group_call != nullptr); CHECK(group_call != nullptr);
CHECK(group_call->is_inited); CHECK(group_call->is_inited);
int32 scheduled_start_date = group_call->scheduled_start_date;
bool is_active = scheduled_start_date == 0 ? group_call->is_active : 0;
bool is_joined = group_call->is_joined && !group_call->is_being_left; bool is_joined = group_call->is_joined && !group_call->is_being_left;
bool can_self_unmute = is_joined && group_call->can_self_unmute; bool can_self_unmute = is_joined && group_call->can_self_unmute;
bool mute_new_participants = get_group_call_mute_new_participants(group_call); bool mute_new_participants = get_group_call_mute_new_participants(group_call);
@ -3819,7 +3839,7 @@ tl_object_ptr<td_api::groupCall> GroupCallManager::get_group_call_object(
int32 record_start_date = get_group_call_record_start_date(group_call); int32 record_start_date = get_group_call_record_start_date(group_call);
int32 record_duration = record_start_date == 0 ? 0 : max(G()->unix_time() - record_start_date + 1, 1); int32 record_duration = record_start_date == 0 ? 0 : max(G()->unix_time() - record_start_date + 1, 1);
return td_api::make_object<td_api::groupCall>( return td_api::make_object<td_api::groupCall>(
group_call->group_call_id.get(), get_group_call_title(group_call), group_call->is_active, is_joined, group_call->group_call_id.get(), get_group_call_title(group_call), scheduled_start_date, is_active, is_joined,
group_call->need_rejoin, can_self_unmute, group_call->can_be_managed, group_call->participant_count, group_call->need_rejoin, can_self_unmute, group_call->can_be_managed, group_call->participant_count,
group_call->loaded_all_participants, std::move(recent_speakers), mute_new_participants, group_call->loaded_all_participants, std::move(recent_speakers), mute_new_participants,
can_change_mute_new_participants, record_duration, group_call->duration); can_change_mute_new_participants, record_duration, group_call->duration);