Add support for hiding message edit date via server-side flag.

GitOrigin-RevId: 675035e0b7d087da9ec76c2e104fb8ba23f07c18
This commit is contained in:
levlam 2019-11-22 00:02:09 +03:00
parent 7cdbd20ae0
commit 8b0f0cdaf6
2 changed files with 13 additions and 2 deletions

View File

@ -3824,6 +3824,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
STORE_FLAG(is_bot_start_message);
STORE_FLAG(has_real_forward_from);
STORE_FLAG(has_legacy_layer);
STORE_FLAG(hide_edit_date);
END_STORE_FLAGS();
}
@ -3970,6 +3971,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
PARSE_FLAG(is_bot_start_message);
PARSE_FLAG(has_real_forward_from);
PARSE_FLAG(has_legacy_layer);
PARSE_FLAG(hide_edit_date);
END_PARSE_FLAGS();
}
@ -16462,10 +16464,11 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
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 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, m->date, m->edit_date,
can_delete_for_all_users, m->is_channel_post, contains_unread_mention, m->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_message_content_object(m->content.get(), td_, live_location_date, m->is_content_secret),
@ -21126,8 +21129,9 @@ void MessagesManager::send_update_message_content(DialogId dialog_id, MessageId
void MessagesManager::send_update_message_edited(DialogId dialog_id, const Message *m) {
CHECK(m != nullptr);
cancel_user_dialog_action(dialog_id, m);
auto edit_date = m->hide_edit_date ? 0 : m->edit_date;
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateMessageEdited>(dialog_id.get(), m->message_id.get(), m->edit_date,
make_tl_object<td_api::updateMessageEdited>(dialog_id.get(), m->message_id.get(), edit_date,
get_reply_markup_object(m->reply_markup)));
}
@ -25491,6 +25495,12 @@ bool MessagesManager::update_message(Dialog *d, unique_ptr<Message> &old_message
LOG(DEBUG) << "Update message media_album_id";
need_send_update = true;
}
if (old_message->hide_edit_date != new_message->hide_edit_date) {
old_message->hide_edit_date = new_message->hide_edit_date;
if (old_message->edit_date > 0) {
need_send_update = true;
}
}
if (old_message->edit_date > 0) {
// inline keyboard can be edited

View File

@ -903,6 +903,7 @@ class MessagesManager : public Actor {
bool disable_notification = false;
bool contains_mention = false;
bool contains_unread_mention = false;
bool hide_edit_date = false;
bool had_reply_markup = false; // had non-inline reply markup?
bool had_forward_info = false;
bool is_content_secret = false; // should be shown only while tapped