mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Preserve topicRootId() on edition-to-history-clear.
This commit is contained in:
@@ -839,6 +839,8 @@ bool HistoryItem::awaitingVideoProcessing() const {
|
||||
HistoryServiceDependentData *HistoryItem::GetServiceDependentData() {
|
||||
if (const auto pinned = Get<HistoryServicePinned>()) {
|
||||
return pinned;
|
||||
} else if (const auto clear = Get<HistoryServiceClearHistory>()) {
|
||||
return clear;
|
||||
} else if (const auto gamescore = Get<HistoryServiceGameScore>()) {
|
||||
return gamescore;
|
||||
} else if (const auto payment = Get<HistoryServicePayment>()) {
|
||||
@@ -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());
|
||||
|
||||
@@ -673,6 +673,11 @@ struct HistoryServicePinned
|
||||
, HistoryServiceDependentData {
|
||||
};
|
||||
|
||||
struct HistoryServiceClearHistory
|
||||
: RuntimeComponent<HistoryServiceClearHistory, HistoryItem>
|
||||
, HistoryServiceDependentData {
|
||||
};
|
||||
|
||||
struct HistoryServiceTopicInfo
|
||||
: RuntimeComponent<HistoryServiceTopicInfo, HistoryItem>
|
||||
, HistoryServiceDependentData {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user