Add Message.scheduling_state.

GitOrigin-RevId: fd950850b1258f49f8272e99a0b4975ab11a38d6
This commit is contained in:
levlam 2019-12-03 03:12:41 +03:00
parent a7769488ac
commit aa01368b38
4 changed files with 30 additions and 7 deletions

View File

@ -542,6 +542,7 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool r
//@sender_user_id Identifier of the user who sent the message; 0 if unknown. Currently, it is unknown for channel posts and for channel posts automatically forwarded to discussion group
//@chat_id Chat identifier
//@sending_state Information about the sending state of the message; may be null
//@scheduling_state Information about the scheduling state of the message; may be null
//@is_outgoing True, if the message is outgoing
//@can_be_edited True, if the message can be edited. For live location and poll messages this fields shows whether editMessageLiveLocation or stopPoll can be used with this message by the client
//@can_be_forwarded True, if the message can be forwarded
@ -562,7 +563,7 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool r
//@restriction_reason If non-empty, contains a human-readable description of the reason why access to this message must be restricted
//@content Content of the message
//@reply_markup Reply markup for the message; may be null
message id:int53 sender_user_id:int32 chat_id:int53 sending_state:MessageSendingState is_outgoing:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo reply_to_message_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int32 author_signature:string views:int32 media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
message id:int53 sender_user_id:int32 chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo reply_to_message_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int32 author_signature:string views:int32 media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
//@description Contains a list of messages @total_count Approximate total count of messages found @messages List of messages; messages may be null
messages total_count:int32 messages:vector<message> = Messages;
@ -1480,6 +1481,15 @@ textEntityTypeMentionName user_id:int32 = TextEntityType;
inputThumbnail thumbnail:InputFile width:int32 height:int32 = InputThumbnail;
//@class MessageSchedulingState @description Contains information about the time when a scheduled message will be sent
//@description The message will be sent at the specified date @send_date Date the message will be sent
messageSchedulingStateSendAtDate send_date:int32 = MessageSchedulingState;
//@description The message will be sent when the peer will be online. Applicable to private chats only and when the exact online status of the peer is known
messageSchedulingStateSendWhenOnline = MessageSchedulingState;
//@class InputMessageContent @description The content of a message to send
//@description A text message @text Formatted text to be sent; 1-GetOption("message_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Code, Pre, PreCode, TextUrl and MentionName entities are allowed to be specified manually

Binary file not shown.

View File

@ -16771,6 +16771,13 @@ void MessagesManager::load_messages(DialogId dialog_id, MessageId from_message_i
get_history(dialog_id, from_message_id, offset, limit, from_database, only_local, std::move(promise));
}
tl_object_ptr<td_api::MessageSchedulingState> MessagesManager::get_message_scheduling_state_object(int32 send_date) {
if (send_date == SCHEDULE_WHEN_ONLINE_DATE) {
return td_api::make_object<td_api::messageSchedulingStateSendWhenOnline>();
}
return td_api::make_object<td_api::messageSchedulingStateSendAtDate>(send_date);
}
tl_object_ptr<td_api::message> MessagesManager::get_message_object(FullMessageId full_message_id) {
return get_message_object(full_message_id.get_dialog_id(), get_message_force(full_message_id, "get_message_object"));
}
@ -16803,6 +16810,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
can_delete = can_delete_channel_message(dialog_status, m, is_bot);
}
bool is_scheduled = m->message_id.is_scheduled();
DialogId my_dialog_id = get_my_dialog_id();
bool can_delete_for_self = false;
bool can_delete_for_all_users = can_delete && can_revoke_message(dialog_id, m);
@ -16825,7 +16833,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
if (for_event_log) {
can_delete_for_self = false;
can_delete_for_all_users = false;
} else if (m->message_id.is_scheduled()) {
} else if (is_scheduled) {
can_delete_for_self = (dialog_id == my_dialog_id);
can_delete_for_all_users = !can_delete_for_self;
}
@ -16836,7 +16844,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
// a forwarded message is outgoing, only if it doesn't have from_dialog_id and its sender isn't hidden
// i.e. a message is incoming only if it's a forwarded message with known from_dialog_id or with a hidden sender
auto forward_info = m->forward_info.get();
is_outgoing = m->message_id.is_scheduled() || forward_info == nullptr ||
is_outgoing = is_scheduled || forward_info == nullptr ||
(!forward_info->from_dialog_id.is_valid() && !is_forward_info_sender_hidden(forward_info));
}
@ -16851,19 +16859,20 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
} else {
ttl = 0;
}
auto scheduling_state = is_scheduled ? get_message_scheduling_state_object(m->date) : nullptr;
bool can_be_edited = for_event_log ? false : can_edit_message(dialog_id, m, false, is_bot);
bool can_be_forwarded = for_event_log ? false : can_forward_message(dialog_id, m);
auto media_album_id = for_event_log ? static_cast<int64>(0) : m->media_album_id;
auto reply_to_message_id = for_event_log ? static_cast<int64>(0) : m->reply_to_message_id.get();
bool contains_unread_mention = for_event_log ? false : m->contains_unread_mention;
auto live_location_date = m->is_failed_to_send ? 0 : m->date;
auto date = m->message_id.is_scheduled() ? 0 : m->date;
auto date = is_scheduled ? 0 : m->date;
auto edit_date = m->hide_edit_date ? 0 : m->edit_date;
return make_tl_object<td_api::message>(
m->message_id.get(), td_->contacts_manager_->get_user_id_object(m->sender_user_id, "sender_user_id"),
dialog_id.get(), std::move(sending_state), is_outgoing, can_be_edited, can_be_forwarded, can_delete_for_self,
can_delete_for_all_users, m->is_channel_post, contains_unread_mention, date, edit_date,
get_message_forward_info_object(m->forward_info), reply_to_message_id, ttl, ttl_expires_in,
dialog_id.get(), std::move(sending_state), std::move(scheduling_state), is_outgoing, can_be_edited,
can_be_forwarded, can_delete_for_self, can_delete_for_all_users, m->is_channel_post, contains_unread_mention,
date, edit_date, get_message_forward_info_object(m->forward_info), reply_to_message_id, ttl, ttl_expires_in,
td_->contacts_manager_->get_user_id_object(m->via_bot_user_id, "via_bot_user_id"), m->author_signature, m->views,
media_album_id, get_restriction_reason_description(m->restriction_reasons),
get_message_content_object(m->content.get(), td_, live_location_date, m->is_content_secret),

View File

@ -1412,6 +1412,8 @@ class MessagesManager : public Actor {
static constexpr int32 MAX_PRELOADED_DIALOGS = 1000;
static constexpr int32 SCHEDULE_WHEN_ONLINE_DATE = 2147483646;
static constexpr double DIALOG_ACTION_TIMEOUT = 5.5;
static constexpr const char *DELETE_MESSAGE_USER_REQUEST_SOURCE = "user request";
@ -1855,6 +1857,8 @@ class MessagesManager : public Actor {
void hide_dialog_action_bar(Dialog *d);
static tl_object_ptr<td_api::MessageSchedulingState> get_message_scheduling_state_object(int32 send_date);
tl_object_ptr<td_api::message> get_message_object(DialogId dialog_id, const Message *m,
bool for_event_log = false) const;