Skip to content

Commit b1d08b3

Browse files
committed
Preserve topicRootId() on edition-to-history-clear.
1 parent e86fec4 commit b1d08b3

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

Telegram/SourceFiles/history/history_item.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ bool HistoryItem::awaitingVideoProcessing() const {
839839
HistoryServiceDependentData *HistoryItem::GetServiceDependentData() {
840840
if (const auto pinned = Get<HistoryServicePinned>()) {
841841
return pinned;
842+
} else if (const auto clear = Get<HistoryServiceClearHistory>()) {
843+
return clear;
842844
} else if (const auto gamescore = Get<HistoryServiceGameScore>()) {
843845
return gamescore;
844846
} else if (const auto payment = Get<HistoryServicePayment>()) {
@@ -2357,14 +2359,23 @@ void HistoryItem::updateForwardedInfo(const MTPMessageFwdHeader *fwd) {
23572359
}
23582360

23592361
void HistoryItem::applyEditionToHistoryCleared() {
2362+
const auto rootId = topicRootId();
2363+
const auto topicPost = (rootId != Data::ForumTopic::kGeneralId);
2364+
auto action = Api::SendAction(history());
2365+
action.replyTo = FullReplyTo{
2366+
.messageId = FullMsgId(_history->peer->id, topicPost ? rootId : 0),
2367+
.topicRootId = rootId,
2368+
};
2369+
using Flag = MTPDmessageService::Flag;
23602370
applyEdition(
23612371
MTP_messageService(
2362-
MTP_flags(0),
2372+
MTP_flags(Flag()
2373+
| (topicPost ? Flag::f_reply_to : Flag())),
23632374
MTP_int(id),
23642375
peerToMTP(PeerId(0)), // from_id
23652376
peerToMTP(_history->peer->id),
23662377
MTPPeer(), // saved_peer_id
2367-
MTPMessageReplyHeader(),
2378+
NewMessageReplyHeader(action),
23682379
MTP_int(date()),
23692380
MTP_messageActionHistoryClear(),
23702381
MTPMessageReactions(),
@@ -4738,6 +4749,8 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) {
47384749
const auto type = action.type();
47394750
if (type == mtpc_messageActionPinMessage) {
47404751
UpdateComponents(HistoryServicePinned::Bit());
4752+
} else if (type == mtpc_messageActionHistoryClear) {
4753+
UpdateComponents(HistoryServiceClearHistory::Bit());
47414754
} else if (type == mtpc_messageActionTopicCreate
47424755
|| type == mtpc_messageActionTopicEdit) {
47434756
UpdateComponents(HistoryServiceTopicInfo::Bit());

Telegram/SourceFiles/history/history_item_components.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,11 @@ struct HistoryServicePinned
673673
, HistoryServiceDependentData {
674674
};
675675

676+
struct HistoryServiceClearHistory
677+
: RuntimeComponent<HistoryServiceClearHistory, HistoryItem>
678+
, HistoryServiceDependentData {
679+
};
680+
676681
struct HistoryServiceTopicInfo
677682
: RuntimeComponent<HistoryServiceTopicInfo, HistoryItem>
678683
, HistoryServiceDependentData {

Telegram/SourceFiles/history/history_item_helpers.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,8 @@ MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
887887
? PeerId()
888888
: replyTo.messageId.peer;
889889
const auto replyToTop = LookupReplyToTop(action.history, replyTo);
890+
const auto topicPost = replyTo.topicRootId
891+
&& (replyTo.topicRootId != Data::ForumTopic::kGeneralId);
890892
auto quoteEntities = Api::EntitiesToMTP(
891893
&action.history->session(),
892894
replyTo.quote.entities,
@@ -903,7 +905,8 @@ MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
903905
| (quoteEntities.v.empty()
904906
? Flag()
905907
: Flag::f_quote_entities)
906-
| (replyTo.todoItemId ? Flag::f_todo_item_id : Flag())),
908+
| (replyTo.todoItemId ? Flag::f_todo_item_id : Flag())
909+
| (topicPost ? Flag::f_forum_topic : Flag())),
907910
MTP_int(replyTo.messageId.msg),
908911
peerToMTP(externalPeerId),
909912
MTPMessageFwdHeader(), // reply_from

0 commit comments

Comments
 (0)