mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Mark all types of local history items.
This commit is contained in:
parent
b0c5a75fb9
commit
7893ad0558
6 changed files with 26 additions and 26 deletions
|
@ -284,7 +284,7 @@ AdminLog::OwnedItem GenerateTextItem(
|
||||||
const auto flags = Flag::f_entities
|
const auto flags = Flag::f_entities
|
||||||
| Flag::f_from_id
|
| Flag::f_from_id
|
||||||
| (out ? Flag::f_out : Flag(0));
|
| (out ? Flag::f_out : Flag(0));
|
||||||
const auto clientFlags = MTPDmessage_ClientFlags();
|
const auto clientFlags = MTPDmessage_ClientFlag::f_fake_history_item;
|
||||||
const auto replyTo = 0;
|
const auto replyTo = 0;
|
||||||
const auto viaBotId = 0;
|
const auto viaBotId = 0;
|
||||||
const auto item = history->owner().makeMessage(
|
const auto item = history->owner().makeMessage(
|
||||||
|
|
|
@ -392,7 +392,7 @@ void GenerateItems(
|
||||||
message.links.push_back(fromLink);
|
message.links.push_back(fromLink);
|
||||||
addPart(history->owner().makeServiceMessage(
|
addPart(history->owner().makeServiceMessage(
|
||||||
history,
|
history,
|
||||||
MTPDmessage_ClientFlags(),
|
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||||
history->nextNonHistoryEntryId(),
|
history->nextNonHistoryEntryId(),
|
||||||
date,
|
date,
|
||||||
message,
|
message,
|
||||||
|
@ -427,7 +427,7 @@ void GenerateItems(
|
||||||
addSimpleServiceMessage(text);
|
addSimpleServiceMessage(text);
|
||||||
|
|
||||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||||
auto bodyClientFlags = MTPDmessage_ClientFlags();
|
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto newDescription = PrepareText(newValue, QString());
|
auto newDescription = PrepareText(newValue, QString());
|
||||||
|
@ -463,7 +463,7 @@ void GenerateItems(
|
||||||
addSimpleServiceMessage(text);
|
addSimpleServiceMessage(text);
|
||||||
|
|
||||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||||
auto bodyClientFlags = MTPDmessage_ClientFlags();
|
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto newLink = newValue.isEmpty() ? TextWithEntities() : PrepareText(Core::App().createInternalLinkFull(newValue), QString());
|
auto newLink = newValue.isEmpty() ? TextWithEntities() : PrepareText(Core::App().createInternalLinkFull(newValue), QString());
|
||||||
|
@ -536,7 +536,7 @@ void GenerateItems(
|
||||||
action.vmessage(),
|
action.vmessage(),
|
||||||
history->nextNonHistoryEntryId(),
|
history->nextNonHistoryEntryId(),
|
||||||
date),
|
date),
|
||||||
MTPDmessage_ClientFlags(),
|
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||||
detachExistingItem));
|
detachExistingItem));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -561,7 +561,7 @@ void GenerateItems(
|
||||||
action.vnew_message(),
|
action.vnew_message(),
|
||||||
history->nextNonHistoryEntryId(),
|
history->nextNonHistoryEntryId(),
|
||||||
date),
|
date),
|
||||||
MTPDmessage_ClientFlags(),
|
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||||
detachExistingItem);
|
detachExistingItem);
|
||||||
if (oldValue.text.isEmpty()) {
|
if (oldValue.text.isEmpty()) {
|
||||||
oldValue = PrepareText(QString(), tr::lng_admin_log_empty_text(tr::now));
|
oldValue = PrepareText(QString(), tr::lng_admin_log_empty_text(tr::now));
|
||||||
|
@ -583,7 +583,7 @@ void GenerateItems(
|
||||||
auto detachExistingItem = false;
|
auto detachExistingItem = false;
|
||||||
addPart(history->createItem(
|
addPart(history->createItem(
|
||||||
PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date),
|
PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date),
|
||||||
MTPDmessage_ClientFlags(),
|
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||||
detachExistingItem));
|
detachExistingItem));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ void GenerateItems(
|
||||||
|
|
||||||
auto createParticipantInvite = [&](const MTPDchannelAdminLogEventActionParticipantInvite &action) {
|
auto createParticipantInvite = [&](const MTPDchannelAdminLogEventActionParticipantInvite &action) {
|
||||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||||
auto bodyClientFlags = MTPDmessage_ClientFlags();
|
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto bodyText = GenerateParticipantChangeText(channel, action.vparticipant());
|
auto bodyText = GenerateParticipantChangeText(channel, action.vparticipant());
|
||||||
|
@ -622,7 +622,7 @@ void GenerateItems(
|
||||||
|
|
||||||
auto createParticipantToggleBan = [&](const MTPDchannelAdminLogEventActionParticipantToggleBan &action) {
|
auto createParticipantToggleBan = [&](const MTPDchannelAdminLogEventActionParticipantToggleBan &action) {
|
||||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||||
auto bodyClientFlags = MTPDmessage_ClientFlags();
|
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant(), &action.vprev_participant());
|
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant(), &action.vprev_participant());
|
||||||
|
@ -647,7 +647,7 @@ void GenerateItems(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||||
auto bodyClientFlags = MTPDmessage_ClientFlags();
|
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant(), &action.vprev_participant());
|
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant(), &action.vprev_participant());
|
||||||
|
@ -687,7 +687,7 @@ void GenerateItems(
|
||||||
message.links.push_back(setLink);
|
message.links.push_back(setLink);
|
||||||
addPart(history->owner().makeServiceMessage(
|
addPart(history->owner().makeServiceMessage(
|
||||||
history,
|
history,
|
||||||
MTPDmessage_ClientFlags(),
|
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||||
history->nextNonHistoryEntryId(),
|
history->nextNonHistoryEntryId(),
|
||||||
date,
|
date,
|
||||||
message,
|
message,
|
||||||
|
@ -706,7 +706,7 @@ void GenerateItems(
|
||||||
|
|
||||||
auto createDefaultBannedRights = [&](const MTPDchannelAdminLogEventActionDefaultBannedRights &action) {
|
auto createDefaultBannedRights = [&](const MTPDchannelAdminLogEventActionDefaultBannedRights &action) {
|
||||||
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
|
||||||
auto bodyClientFlags = MTPDmessage_ClientFlags();
|
auto bodyClientFlags = MTPDmessage_ClientFlag::f_admin_log_entry;
|
||||||
auto bodyReplyTo = 0;
|
auto bodyReplyTo = 0;
|
||||||
auto bodyViaBotId = 0;
|
auto bodyViaBotId = 0;
|
||||||
auto bodyText = GenerateDefaultBannedRightsChangeText(channel, action.vnew_banned_rights(), action.vprev_banned_rights());
|
auto bodyText = GenerateDefaultBannedRightsChangeText(channel, action.vnew_banned_rights(), action.vprev_banned_rights());
|
||||||
|
@ -730,7 +730,7 @@ void GenerateItems(
|
||||||
auto detachExistingItem = false;
|
auto detachExistingItem = false;
|
||||||
addPart(history->createItem(
|
addPart(history->createItem(
|
||||||
PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date),
|
PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date),
|
||||||
MTPDmessage_ClientFlags(),
|
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||||
detachExistingItem));
|
detachExistingItem));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -763,7 +763,7 @@ void GenerateItems(
|
||||||
message.links.push_back(chatLink);
|
message.links.push_back(chatLink);
|
||||||
addPart(history->owner().makeServiceMessage(
|
addPart(history->owner().makeServiceMessage(
|
||||||
history,
|
history,
|
||||||
MTPDmessage_ClientFlags(),
|
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||||
history->nextNonHistoryEntryId(),
|
history->nextNonHistoryEntryId(),
|
||||||
date,
|
date,
|
||||||
message,
|
message,
|
||||||
|
|
|
@ -685,13 +685,6 @@ void History::checkForLoadedAtTop(not_null<HistoryItem*> added) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *History::addToHistory(
|
|
||||||
const MTPMessage &msg,
|
|
||||||
MTPDmessage_ClientFlags clientFlags) {
|
|
||||||
const auto detachExistingItem = false;
|
|
||||||
return createItem(msg, clientFlags, detachExistingItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
not_null<HistoryItem*> History::addNewLocalMessage(
|
not_null<HistoryItem*> History::addNewLocalMessage(
|
||||||
MsgId id,
|
MsgId id,
|
||||||
MTPDmessage::Flags flags,
|
MTPDmessage::Flags flags,
|
||||||
|
@ -880,8 +873,9 @@ void History::addUnreadMentionsSlice(const MTPmessages_Messages &result) {
|
||||||
auto added = false;
|
auto added = false;
|
||||||
if (messages) {
|
if (messages) {
|
||||||
const auto clientFlags = MTPDmessage_ClientFlags();
|
const auto clientFlags = MTPDmessage_ClientFlags();
|
||||||
for (auto &message : *messages) {
|
const auto type = NewMessageType::Existing;
|
||||||
if (auto item = addToHistory(message, clientFlags)) {
|
for (const auto &message : *messages) {
|
||||||
|
if (const auto item = addNewMessage(message, clientFlags, type)) {
|
||||||
if (item->isUnreadMention()) {
|
if (item->isUnreadMention()) {
|
||||||
_unreadMentions.insert(item->id);
|
_unreadMentions.insert(item->id);
|
||||||
added = true;
|
added = true;
|
||||||
|
|
|
@ -68,6 +68,12 @@ enum class MTPDmessage_ClientFlag : uint32 {
|
||||||
|
|
||||||
// message is local message existing in the message history
|
// message is local message existing in the message history
|
||||||
f_local_history_entry = (1U << 20),
|
f_local_history_entry = (1U << 20),
|
||||||
|
|
||||||
|
// message is an admin log entry
|
||||||
|
f_admin_log_entry = (1U << 19),
|
||||||
|
|
||||||
|
// message is a fake message for some ui
|
||||||
|
f_fake_history_item = (1U << 18),
|
||||||
};
|
};
|
||||||
inline constexpr bool is_flag_type(MTPDmessage_ClientFlag) { return true; }
|
inline constexpr bool is_flag_type(MTPDmessage_ClientFlag) { return true; }
|
||||||
using MTPDmessage_ClientFlags = base::flags<MTPDmessage_ClientFlag>;
|
using MTPDmessage_ClientFlags = base::flags<MTPDmessage_ClientFlag>;
|
||||||
|
|
|
@ -166,7 +166,7 @@ AdminLog::OwnedItem GenerateForwardedItem(
|
||||||
return history->owner().makeMessage(
|
return history->owner().makeMessage(
|
||||||
history,
|
history,
|
||||||
data,
|
data,
|
||||||
MTPDmessage_ClientFlags());
|
MTPDmessage_ClientFlag::f_fake_history_item);
|
||||||
}, [](auto &&) -> not_null<HistoryMessage*> {
|
}, [](auto &&) -> not_null<HistoryMessage*> {
|
||||||
Unexpected("Type in GenerateForwardedItem.");
|
Unexpected("Type in GenerateForwardedItem.");
|
||||||
});
|
});
|
||||||
|
|
|
@ -271,7 +271,7 @@ AdminLog::OwnedItem GenerateCommentItem(
|
||||||
using Flag = MTPDmessage::Flag;
|
using Flag = MTPDmessage::Flag;
|
||||||
const auto id = ServerMaxMsgId + (ServerMaxMsgId / 2);
|
const auto id = ServerMaxMsgId + (ServerMaxMsgId / 2);
|
||||||
const auto flags = Flag::f_entities | Flag::f_from_id | Flag::f_out;
|
const auto flags = Flag::f_entities | Flag::f_from_id | Flag::f_out;
|
||||||
const auto clientFlags = MTPDmessage_ClientFlags();
|
const auto clientFlags = MTPDmessage_ClientFlag::f_fake_history_item;
|
||||||
const auto replyTo = 0;
|
const auto replyTo = 0;
|
||||||
const auto viaBotId = 0;
|
const auto viaBotId = 0;
|
||||||
const auto item = history->owner().makeMessage(
|
const auto item = history->owner().makeMessage(
|
||||||
|
@ -324,7 +324,7 @@ AdminLog::OwnedItem GenerateContactItem(
|
||||||
const auto item = history->owner().makeMessage(
|
const auto item = history->owner().makeMessage(
|
||||||
history,
|
history,
|
||||||
message.c_message(),
|
message.c_message(),
|
||||||
MTPDmessage_ClientFlags());
|
MTPDmessage_ClientFlag::f_fake_history_item);
|
||||||
return AdminLog::OwnedItem(delegate, item);
|
return AdminLog::OwnedItem(delegate, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue