Add message.can_be_saved.

This commit is contained in:
levlam 2021-11-25 13:47:54 +03:00
parent 0ce9391ff1
commit c1a5d4b76b
3 changed files with 26 additions and 8 deletions

View File

@ -781,6 +781,7 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool r
//@is_pinned True, if the message is pinned
//@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 application
//@can_be_forwarded True, if the message can be forwarded
//@can_be_saved True, if content of the message can be saved locally or copied
//@can_be_deleted_only_for_self True, if the message can be deleted only for the current user while other users will continue to see it
//@can_be_deleted_for_all_users True, if the message can be deleted for all users
//@can_get_statistics True, if the message statistics are available
@ -805,7 +806,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_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool has_timestamped_media:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo interaction_info:messageInteractionInfo reply_in_chat_id:int53 reply_to_message_id:int53 message_thread_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int53 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
message id:int53 sender_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_saved:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool has_timestamped_media:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo interaction_info:messageInteractionInfo reply_in_chat_id:int53 reply_to_message_id:int53 message_thread_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int53 author_signature:string 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;

View File

@ -4810,7 +4810,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
bool has_ttl_period = ttl_period != 0;
bool has_max_reply_media_timestamp = max_reply_media_timestamp >= 0;
bool are_message_media_timestamp_entities_found = true;
bool has_flags3 = false;
bool has_flags3 = true;
BEGIN_STORE_FLAGS();
STORE_FLAG(is_channel_post);
STORE_FLAG(is_outgoing);
@ -4877,6 +4877,11 @@ void MessagesManager::Message::store(StorerT &storer) const {
STORE_FLAG(has_flags3);
END_STORE_FLAGS();
}
if (has_flags3) {
BEGIN_STORE_FLAGS();
STORE_FLAG(noforwards);
END_STORE_FLAGS();
}
store(message_id, storer);
if (has_sender) {
@ -5104,6 +5109,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
}
if (has_flags3) {
BEGIN_PARSE_FLAGS();
PARSE_FLAG(noforwards);
END_PARSE_FLAGS();
}
@ -12371,6 +12377,7 @@ void MessagesManager::on_message_ttl_expired_impl(Dialog *d, Message *m) {
remove_message_notification_id(d, m, true, true);
update_message_contains_unread_mention(d, m, false, "on_message_ttl_expired_impl");
unregister_message_reply(d, m);
m->noforwards = false;
m->contains_mention = false;
m->reply_to_message_id = MessageId();
m->max_reply_media_timestamp = -1;
@ -13545,6 +13552,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
bool hide_edit_date = (flags & MESSAGE_FLAG_HIDE_EDIT_DATE) != 0;
bool is_from_scheduled = (flags & MESSAGE_FLAG_IS_FROM_SCHEDULED) != 0;
bool is_pinned = (flags & MESSAGE_FLAG_IS_PINNED) != 0;
bool noforwards = (flags & MESSAGE_FLAG_NOFORWARDS) != 0;
LOG_IF(ERROR, is_channel_message != (dialog_type == DialogType::Channel))
<< "is_channel_message is wrong for " << message_id << " received in the " << dialog_id;
@ -13707,6 +13715,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
message->hide_edit_date = hide_edit_date;
message->is_from_scheduled = is_from_scheduled;
message->is_pinned = is_pinned;
message->noforwards = noforwards;
message->view_count = view_count;
message->forward_count = forward_count;
message->reply_info = std::move(reply_info);
@ -23520,8 +23529,9 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
auto scheduling_state = is_scheduled ? get_message_scheduling_state_object(m->date) : nullptr;
auto forward_info = get_message_forward_info_object(m->forward_info);
auto interaction_info = get_message_interaction_info_object(dialog_id, m);
auto can_be_saved = !m->noforwards && get_dialog_allow_saving_content(dialog_id) && !m->is_content_secret;
auto can_be_edited = for_event_log ? false : can_edit_message(dialog_id, m, false, td_->auth_manager_->is_bot());
auto can_be_forwarded = for_event_log ? false : can_forward_message(dialog_id, m);
auto can_be_forwarded = for_event_log ? false : can_forward_message(dialog_id, m) && can_be_saved;
auto can_get_statistics = for_event_log ? false : can_get_message_statistics(dialog_id, m);
auto can_get_message_thread = for_event_log ? false : get_top_thread_full_message_id(dialog_id, m).is_ok();
auto can_get_viewers = for_event_log ? false : can_get_message_viewers(dialog_id, m).is_ok();
@ -23547,11 +23557,11 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
skip_bot_commands, max_media_timestamp);
return make_tl_object<td_api::message>(
m->message_id.get(), std::move(sender), dialog_id.get(), std::move(sending_state), std::move(scheduling_state),
is_outgoing, is_pinned, can_be_edited, can_be_forwarded, can_delete_for_self, can_delete_for_all_users,
can_get_statistics, can_get_message_thread, can_get_viewers, can_get_media_timestamp_links, has_timestamped_media,
m->is_channel_post, contains_unread_mention, date, edit_date, std::move(forward_info),
std::move(interaction_info), reply_in_dialog_id.get(), reply_to_message_id, top_thread_message_id, ttl,
ttl_expires_in, via_bot_user_id, m->author_signature, media_album_id,
is_outgoing, is_pinned, can_be_edited, can_be_forwarded, can_be_saved, can_delete_for_self,
can_delete_for_all_users, can_get_statistics, can_get_message_thread, can_get_viewers,
can_get_media_timestamp_links, has_timestamped_media, m->is_channel_post, contains_unread_mention, date,
edit_date, std::move(forward_info), std::move(interaction_info), reply_in_dialog_id.get(), reply_to_message_id,
top_thread_message_id, ttl, ttl_expires_in, via_bot_user_id, m->author_signature, media_album_id,
get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup));
}
@ -34178,8 +34188,13 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr
std::move(new_message->reply_info), "update_message")) {
need_send_update = true;
}
if (old_message->noforwards != new_message->noforwards) {
old_message->noforwards = new_message->noforwards;
need_send_update = true;
}
if (old_message->restriction_reasons != new_message->restriction_reasons) {
old_message->restriction_reasons = std::move(new_message->restriction_reasons);
need_send_update = true;
}
if (old_message->legacy_layer != new_message->legacy_layer) {
old_message->legacy_layer = new_message->legacy_layer;

View File

@ -120,6 +120,7 @@ class MessagesManager final : public Actor {
static constexpr int32 MESSAGE_FLAG_HAS_REPLY_INFO = 1 << 23;
static constexpr int32 MESSAGE_FLAG_IS_PINNED = 1 << 24;
static constexpr int32 MESSAGE_FLAG_HAS_TTL_PERIOD = 1 << 25;
static constexpr int32 MESSAGE_FLAG_NOFORWARDS = 1 << 26;
static constexpr int32 SEND_MESSAGE_FLAG_IS_REPLY = 1 << 0;
static constexpr int32 SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW = 1 << 1;
@ -1082,6 +1083,7 @@ class MessagesManager final : public Actor {
bool is_from_scheduled = false;
bool is_pinned = false;
bool are_media_timestamp_entities_found = false;
bool noforwards = false;
bool is_copy = false; // for send_message
bool from_background = false; // for send_message