diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 1506ba64e7..b235521824 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -839,6 +839,8 @@ bool HistoryItem::awaitingVideoProcessing() const { HistoryServiceDependentData *HistoryItem::GetServiceDependentData() { if (const auto pinned = Get()) { return pinned; + } else if (const auto clear = Get()) { + return clear; } else if (const auto gamescore = Get()) { return gamescore; } else if (const auto payment = Get()) { @@ -2357,14 +2359,23 @@ void HistoryItem::updateForwardedInfo(const MTPMessageFwdHeader *fwd) { } void HistoryItem::applyEditionToHistoryCleared() { + const auto rootId = topicRootId(); + const auto topicPost = (rootId != Data::ForumTopic::kGeneralId); + auto action = Api::SendAction(history()); + action.replyTo = FullReplyTo{ + .messageId = FullMsgId(_history->peer->id, topicPost ? rootId : 0), + .topicRootId = rootId, + }; + using Flag = MTPDmessageService::Flag; applyEdition( MTP_messageService( - MTP_flags(0), + MTP_flags(Flag() + | (topicPost ? Flag::f_reply_to : Flag())), MTP_int(id), peerToMTP(PeerId(0)), // from_id peerToMTP(_history->peer->id), MTPPeer(), // saved_peer_id - MTPMessageReplyHeader(), + NewMessageReplyHeader(action), MTP_int(date()), MTP_messageActionHistoryClear(), MTPMessageReactions(), @@ -4738,6 +4749,8 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) { const auto type = action.type(); if (type == mtpc_messageActionPinMessage) { UpdateComponents(HistoryServicePinned::Bit()); + } else if (type == mtpc_messageActionHistoryClear) { + UpdateComponents(HistoryServiceClearHistory::Bit()); } else if (type == mtpc_messageActionTopicCreate || type == mtpc_messageActionTopicEdit) { UpdateComponents(HistoryServiceTopicInfo::Bit()); diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index 0bf0d3a1ee..f42041c9da 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -673,6 +673,11 @@ struct HistoryServicePinned , HistoryServiceDependentData { }; +struct HistoryServiceClearHistory +: RuntimeComponent +, HistoryServiceDependentData { +}; + struct HistoryServiceTopicInfo : RuntimeComponent , HistoryServiceDependentData { diff --git a/Telegram/SourceFiles/history/history_item_helpers.cpp b/Telegram/SourceFiles/history/history_item_helpers.cpp index a696d85178..f4f170f153 100644 --- a/Telegram/SourceFiles/history/history_item_helpers.cpp +++ b/Telegram/SourceFiles/history/history_item_helpers.cpp @@ -887,6 +887,8 @@ MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) { ? PeerId() : replyTo.messageId.peer; const auto replyToTop = LookupReplyToTop(action.history, replyTo); + const auto topicPost = replyTo.topicRootId + && (replyTo.topicRootId != Data::ForumTopic::kGeneralId); auto quoteEntities = Api::EntitiesToMTP( &action.history->session(), replyTo.quote.entities, @@ -903,7 +905,8 @@ MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) { | (quoteEntities.v.empty() ? Flag() : Flag::f_quote_entities) - | (replyTo.todoItemId ? Flag::f_todo_item_id : Flag())), + | (replyTo.todoItemId ? Flag::f_todo_item_id : Flag()) + | (topicPost ? Flag::f_forum_topic : Flag())), MTP_int(replyTo.messageId.msg), peerToMTP(externalPeerId), MTPMessageFwdHeader(), // reply_from