mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -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
|
||||
| Flag::f_from_id
|
||||
| (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 viaBotId = 0;
|
||||
const auto item = history->owner().makeMessage(
|
||||
|
|
|
@ -392,7 +392,7 @@ void GenerateItems(
|
|||
message.links.push_back(fromLink);
|
||||
addPart(history->owner().makeServiceMessage(
|
||||
history,
|
||||
MTPDmessage_ClientFlags(),
|
||||
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||
history->nextNonHistoryEntryId(),
|
||||
date,
|
||||
message,
|
||||
|
@ -427,7 +427,7 @@ void GenerateItems(
|
|||
addSimpleServiceMessage(text);
|
||||
|
||||
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 bodyViaBotId = 0;
|
||||
auto newDescription = PrepareText(newValue, QString());
|
||||
|
@ -463,7 +463,7 @@ void GenerateItems(
|
|||
addSimpleServiceMessage(text);
|
||||
|
||||
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 bodyViaBotId = 0;
|
||||
auto newLink = newValue.isEmpty() ? TextWithEntities() : PrepareText(Core::App().createInternalLinkFull(newValue), QString());
|
||||
|
@ -536,7 +536,7 @@ void GenerateItems(
|
|||
action.vmessage(),
|
||||
history->nextNonHistoryEntryId(),
|
||||
date),
|
||||
MTPDmessage_ClientFlags(),
|
||||
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||
detachExistingItem));
|
||||
}
|
||||
};
|
||||
|
@ -561,7 +561,7 @@ void GenerateItems(
|
|||
action.vnew_message(),
|
||||
history->nextNonHistoryEntryId(),
|
||||
date),
|
||||
MTPDmessage_ClientFlags(),
|
||||
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||
detachExistingItem);
|
||||
if (oldValue.text.isEmpty()) {
|
||||
oldValue = PrepareText(QString(), tr::lng_admin_log_empty_text(tr::now));
|
||||
|
@ -583,7 +583,7 @@ void GenerateItems(
|
|||
auto detachExistingItem = false;
|
||||
addPart(history->createItem(
|
||||
PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date),
|
||||
MTPDmessage_ClientFlags(),
|
||||
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||
detachExistingItem));
|
||||
};
|
||||
|
||||
|
@ -603,7 +603,7 @@ void GenerateItems(
|
|||
|
||||
auto createParticipantInvite = [&](const MTPDchannelAdminLogEventActionParticipantInvite &action) {
|
||||
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 bodyViaBotId = 0;
|
||||
auto bodyText = GenerateParticipantChangeText(channel, action.vparticipant());
|
||||
|
@ -622,7 +622,7 @@ void GenerateItems(
|
|||
|
||||
auto createParticipantToggleBan = [&](const MTPDchannelAdminLogEventActionParticipantToggleBan &action) {
|
||||
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 bodyViaBotId = 0;
|
||||
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant(), &action.vprev_participant());
|
||||
|
@ -647,7 +647,7 @@ void GenerateItems(
|
|||
return;
|
||||
}
|
||||
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 bodyViaBotId = 0;
|
||||
auto bodyText = GenerateParticipantChangeText(channel, action.vnew_participant(), &action.vprev_participant());
|
||||
|
@ -687,7 +687,7 @@ void GenerateItems(
|
|||
message.links.push_back(setLink);
|
||||
addPart(history->owner().makeServiceMessage(
|
||||
history,
|
||||
MTPDmessage_ClientFlags(),
|
||||
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||
history->nextNonHistoryEntryId(),
|
||||
date,
|
||||
message,
|
||||
|
@ -706,7 +706,7 @@ void GenerateItems(
|
|||
|
||||
auto createDefaultBannedRights = [&](const MTPDchannelAdminLogEventActionDefaultBannedRights &action) {
|
||||
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 bodyViaBotId = 0;
|
||||
auto bodyText = GenerateDefaultBannedRightsChangeText(channel, action.vnew_banned_rights(), action.vprev_banned_rights());
|
||||
|
@ -730,7 +730,7 @@ void GenerateItems(
|
|||
auto detachExistingItem = false;
|
||||
addPart(history->createItem(
|
||||
PrepareLogMessage(action.vmessage(), history->nextNonHistoryEntryId(), date),
|
||||
MTPDmessage_ClientFlags(),
|
||||
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||
detachExistingItem));
|
||||
};
|
||||
|
||||
|
@ -763,7 +763,7 @@ void GenerateItems(
|
|||
message.links.push_back(chatLink);
|
||||
addPart(history->owner().makeServiceMessage(
|
||||
history,
|
||||
MTPDmessage_ClientFlags(),
|
||||
MTPDmessage_ClientFlag::f_admin_log_entry,
|
||||
history->nextNonHistoryEntryId(),
|
||||
date,
|
||||
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(
|
||||
MsgId id,
|
||||
MTPDmessage::Flags flags,
|
||||
|
@ -880,8 +873,9 @@ void History::addUnreadMentionsSlice(const MTPmessages_Messages &result) {
|
|||
auto added = false;
|
||||
if (messages) {
|
||||
const auto clientFlags = MTPDmessage_ClientFlags();
|
||||
for (auto &message : *messages) {
|
||||
if (auto item = addToHistory(message, clientFlags)) {
|
||||
const auto type = NewMessageType::Existing;
|
||||
for (const auto &message : *messages) {
|
||||
if (const auto item = addNewMessage(message, clientFlags, type)) {
|
||||
if (item->isUnreadMention()) {
|
||||
_unreadMentions.insert(item->id);
|
||||
added = true;
|
||||
|
|
|
@ -68,6 +68,12 @@ enum class MTPDmessage_ClientFlag : uint32 {
|
|||
|
||||
// message is local message existing in the message history
|
||||
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; }
|
||||
using MTPDmessage_ClientFlags = base::flags<MTPDmessage_ClientFlag>;
|
||||
|
|
|
@ -166,7 +166,7 @@ AdminLog::OwnedItem GenerateForwardedItem(
|
|||
return history->owner().makeMessage(
|
||||
history,
|
||||
data,
|
||||
MTPDmessage_ClientFlags());
|
||||
MTPDmessage_ClientFlag::f_fake_history_item);
|
||||
}, [](auto &&) -> not_null<HistoryMessage*> {
|
||||
Unexpected("Type in GenerateForwardedItem.");
|
||||
});
|
||||
|
|
|
@ -271,7 +271,7 @@ AdminLog::OwnedItem GenerateCommentItem(
|
|||
using Flag = MTPDmessage::Flag;
|
||||
const auto id = ServerMaxMsgId + (ServerMaxMsgId / 2);
|
||||
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 viaBotId = 0;
|
||||
const auto item = history->owner().makeMessage(
|
||||
|
@ -324,7 +324,7 @@ AdminLog::OwnedItem GenerateContactItem(
|
|||
const auto item = history->owner().makeMessage(
|
||||
history,
|
||||
message.c_message(),
|
||||
MTPDmessage_ClientFlags());
|
||||
MTPDmessage_ClientFlag::f_fake_history_item);
|
||||
return AdminLog::OwnedItem(delegate, item);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue