Move message client flags to a separate field.

This commit is contained in:
John Preston 2019-08-09 20:19:23 +01:00
parent 4869ce2247
commit 02b65a42f7
25 changed files with 393 additions and 89 deletions

View File

@ -49,6 +49,7 @@ void SendExistingMedia(
const auto randomId = rand_value<uint64>(); const auto randomId = rand_value<uint64>();
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media; auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
auto clientFlags = NewMessageClientFlags();
auto sendFlags = MTPmessages_SendMedia::Flags(0); auto sendFlags = MTPmessages_SendMedia::Flags(0);
if (options.replyTo) { if (options.replyTo) {
flags |= MTPDmessage::Flag::f_reply_to_msg_id; flags |= MTPDmessage::Flag::f_reply_to_msg_id;
@ -89,6 +90,7 @@ void SendExistingMedia(
history->addNewLocalMessage( history->addNewLocalMessage(
newId.msg, newId.msg,
flags, flags,
clientFlags,
0, 0,
replyTo, replyTo,
base::unixtime::now(), base::unixtime::now(),

View File

@ -3103,6 +3103,7 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs
for (const auto &[position, index] : indices) { for (const auto &[position, index] : indices) {
const auto item = _session->data().addNewMessage( const auto item = _session->data().addNewMessage(
v->at(index), v->at(index),
MTPDmessage_ClientFlags(),
NewMessageType::Existing); NewMessageType::Existing);
if (item) { if (item) {
_session->data().requestItemResize(item); _session->data().requestItemResize(item);
@ -3571,6 +3572,7 @@ void ApiWrap::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
MTPint(), MTPint(),
MTPstring(), MTPstring(),
MTPlong()), MTPlong()),
MTPDmessage_ClientFlags(),
NewMessageType::Unread); NewMessageType::Unread);
} break; } break;
@ -3596,6 +3598,7 @@ void ApiWrap::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
MTPint(), MTPint(),
MTPstring(), MTPstring(),
MTPlong()), MTPlong()),
MTPDmessage_ClientFlags(),
NewMessageType::Unread); NewMessageType::Unread);
} break; } break;
@ -3620,7 +3623,10 @@ void ApiWrap::applyUpdateNoPtsCheck(const MTPUpdate &update) {
} }
} }
if (needToAdd) { if (needToAdd) {
_session->data().addNewMessage(d.vmessage(), NewMessageType::Unread); _session->data().addNewMessage(
d.vmessage(),
MTPDmessage_ClientFlags(),
NewMessageType::Unread);
} }
} break; } break;
@ -3709,7 +3715,10 @@ void ApiWrap::applyUpdateNoPtsCheck(const MTPUpdate &update) {
} }
} }
if (needToAdd) { if (needToAdd) {
_session->data().addNewMessage(d.vmessage(), NewMessageType::Unread); _session->data().addNewMessage(
d.vmessage(),
MTPDmessage_ClientFlags(),
NewMessageType::Unread);
} }
} break; } break;
@ -4403,6 +4412,7 @@ void ApiWrap::forwardMessages(
|| (channelPost && _session->data().notifySilentPosts(peer)); || (channelPost && _session->data().notifySilentPosts(peer));
auto flags = MTPDmessage::Flags(0); auto flags = MTPDmessage::Flags(0);
auto clientFlags = MTPDmessage_ClientFlags();
auto sendFlags = MTPmessages_ForwardMessages::Flags(0); auto sendFlags = MTPmessages_ForwardMessages::Flags(0);
if (channelPost) { if (channelPost) {
flags |= MTPDmessage::Flag::f_views; flags |= MTPDmessage::Flag::f_views;
@ -4479,6 +4489,7 @@ void ApiWrap::forwardMessages(
history->addNewLocalMessage( history->addNewLocalMessage(
newId.msg, newId.msg,
flags, flags,
clientFlags,
base::unixtime::now(), base::unixtime::now(),
messageFromId, messageFromId,
messagePostAuthor, messagePostAuthor,
@ -4545,6 +4556,7 @@ void ApiWrap::sendSharedContact(
const auto channelPost = peer->isChannel() && !peer->isMegagroup(); const auto channelPost = peer->isChannel() && !peer->isMegagroup();
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media; auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
auto clientFlags = NewMessageClientFlags();
if (options.replyTo) { if (options.replyTo) {
flags |= MTPDmessage::Flag::f_reply_to_msg_id; flags |= MTPDmessage::Flag::f_reply_to_msg_id;
} }
@ -4586,6 +4598,7 @@ void ApiWrap::sendSharedContact(
MTPint(), MTPint(),
MTP_string(messagePostAuthor), MTP_string(messagePostAuthor),
MTPlong()), MTPlong()),
clientFlags,
NewMessageType::Unread); NewMessageType::Unread);
const auto media = MTP_inputMediaContact( const auto media = MTP_inputMediaContact(
@ -4902,6 +4915,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
MTPstring msgText(MTP_string(sending.text)); MTPstring msgText(MTP_string(sending.text));
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_entities; auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_entities;
auto clientFlags = NewMessageClientFlags();
auto sendFlags = MTPmessages_SendMessage::Flags(0); auto sendFlags = MTPmessages_SendMessage::Flags(0);
if (message.replyTo) { if (message.replyTo) {
flags |= MTPDmessage::Flag::f_reply_to_msg_id; flags |= MTPDmessage::Flag::f_reply_to_msg_id;
@ -4965,6 +4979,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
MTPint(), MTPint(),
MTP_string(messagePostAuthor), MTP_string(messagePostAuthor),
MTPlong()), MTPlong()),
clientFlags,
NewMessageType::Unread); NewMessageType::Unread);
history->sendRequestId = request(MTPmessages_SendMessage( history->sendRequestId = request(MTPmessages_SendMessage(
MTP_flags(sendFlags), MTP_flags(sendFlags),
@ -5037,6 +5052,7 @@ void ApiWrap::sendInlineResult(
const auto randomId = rand_value<uint64>(); const auto randomId = rand_value<uint64>();
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media; auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
auto clientFlags = NewMessageClientFlags();
auto sendFlags = MTPmessages_SendInlineBotResult::Flag::f_clear_draft | 0; auto sendFlags = MTPmessages_SendInlineBotResult::Flag::f_clear_draft | 0;
if (options.replyTo) { if (options.replyTo) {
flags |= MTPDmessage::Flag::f_reply_to_msg_id; flags |= MTPDmessage::Flag::f_reply_to_msg_id;
@ -5074,6 +5090,7 @@ void ApiWrap::sendInlineResult(
data->addToHistory( data->addToHistory(
history, history,
flags, flags,
clientFlags,
messageId, messageId,
messageFromId, messageFromId,
messageDate, messageDate,

View File

@ -284,12 +284,14 @@ 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 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(
history, history,
++id, ++id,
flags, flags,
clientFlags,
replyTo, replyTo,
viaBotId, viaBotId,
base::unixtime::now(), base::unixtime::now(),

View File

@ -324,6 +324,7 @@ void BoxController::receivedCalls(const QVector<MTPMessage> &result) {
if (const auto peer = session().data().peerLoaded(peerId)) { if (const auto peer = session().data().peerLoaded(peerId)) {
const auto item = session().data().addNewMessage( const auto item = session().data().addNewMessage(
message, message,
MTPDmessage_ClientFlags(),
NewMessageType::Existing); NewMessageType::Existing);
insertRow(item, InsertWay::Append); insertRow(item, InsertWay::Append);
} else { } else {

View File

@ -154,8 +154,12 @@ SearchResult ParseSearchResult(
const auto addType = NewMessageType::Existing; const auto addType = NewMessageType::Existing;
result.messageIds.reserve(messages->size()); result.messageIds.reserve(messages->size());
for (const auto &message : *messages) { for (const auto &message : *messages) {
if (auto item = peer->owner().addNewMessage(message, addType)) { const auto item = peer->owner().addNewMessage(
auto itemId = item->id; message,
MTPDmessage_ClientFlags(),
addType);
if (item) {
const auto itemId = item->id;
if ((type == Storage::SharedMediaType::kCount) if ((type == Storage::SharedMediaType::kCount)
|| item->sharedMediaTypes().test(type)) { || item->sharedMediaTypes().test(type)) {
result.messageIds.push_back(itemId); result.messageIds.push_back(itemId);

View File

@ -1732,7 +1732,10 @@ void Session::processMessages(
indices.emplace((uint64(uint32(id)) << 32) | uint64(i), i); indices.emplace((uint64(uint32(id)) << 32) | uint64(i), i);
} }
for (const auto [position, index] : indices) { for (const auto [position, index] : indices) {
addNewMessage(data[index], type); addNewMessage(
data[index],
MTPDmessage_ClientFlags(),
type);
} }
} }
@ -2000,13 +2003,17 @@ void Session::unmuteByFinished() {
HistoryItem *Session::addNewMessage( HistoryItem *Session::addNewMessage(
const MTPMessage &data, const MTPMessage &data,
MTPDmessage_ClientFlags clientFlags,
NewMessageType type) { NewMessageType type) {
const auto peerId = PeerFromMessage(data); const auto peerId = PeerFromMessage(data);
if (!peerId) { if (!peerId) {
return nullptr; return nullptr;
} }
const auto result = history(peerId)->addNewMessage(data, type); const auto result = history(peerId)->addNewMessage(
data,
clientFlags,
type);
if (result && type == NewMessageType::Unread) { if (result && type == NewMessageType::Unread) {
CheckForSwitchInlineButton(result); CheckForSwitchInlineButton(result);
} }
@ -3619,8 +3626,8 @@ void Session::insertCheckedServiceNotification(
const auto history = this->history(PeerData::kServiceNotificationsId); const auto history = this->history(PeerData::kServiceNotificationsId);
const auto flags = MTPDmessage::Flag::f_entities const auto flags = MTPDmessage::Flag::f_entities
| MTPDmessage::Flag::f_from_id | MTPDmessage::Flag::f_from_id
| MTPDmessage_ClientFlag::f_clientside_unread
| MTPDmessage::Flag::f_media; | MTPDmessage::Flag::f_media;
const auto clientFlags = MTPDmessage_ClientFlag::f_clientside_unread;
auto sending = TextWithEntities(), left = message; auto sending = TextWithEntities(), left = message;
while (TextUtilities::CutPart(sending, left, MaxMessageSize)) { while (TextUtilities::CutPart(sending, left, MaxMessageSize)) {
addNewMessage( addNewMessage(
@ -3641,6 +3648,7 @@ void Session::insertCheckedServiceNotification(
MTPint(), MTPint(),
MTPstring(), MTPstring(),
MTPlong()), MTPlong()),
clientFlags,
NewMessageType::Unread); NewMessageType::Unread);
} }
sendHistoryChangeNotifications(); sendHistoryChangeNotifications();

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_notify_settings.h" #include "data/data_notify_settings.h"
#include "history/history_location_manager.h" #include "history/history_location_manager.h"
#include "base/timer.h" #include "base/timer.h"
#include "base/flags.h"
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
class Image; class Image;
@ -415,7 +416,10 @@ public:
FileOrigin origin, FileOrigin origin,
bool forceRemoteLoader = false); bool forceRemoteLoader = false);
HistoryItem *addNewMessage(const MTPMessage &data, NewMessageType type); HistoryItem *addNewMessage(
const MTPMessage &data,
MTPDmessage_ClientFlags flags,
NewMessageType type);
struct SendActionAnimationUpdate { struct SendActionAnimationUpdate {
not_null<History*> history; not_null<History*> history;

View File

@ -2029,6 +2029,7 @@ bool InnerWidget::searchReceived(
if (lastDate) { if (lastDate) {
const auto item = session().data().addNewMessage( const auto item = session().data().addNewMessage(
message, message,
MTPDmessage_ClientFlags(),
NewMessageType::Existing); NewMessageType::Existing);
const auto history = item->history(); const auto history = item->history();
if (!uniquePeers || !hasHistoryInResults(history)) { if (!uniquePeers || !hasHistoryInResults(history)) {

View File

@ -387,7 +387,15 @@ void GenerateItems(
auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr) { auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr) {
auto message = HistoryService::PreparedText { text }; auto message = HistoryService::PreparedText { text };
message.links.push_back(fromLink); message.links.push_back(fromLink);
addPart(history->owner().makeServiceMessage(history, idManager->next(), date, message, MTPDmessage::Flags(0), peerToUser(from->id), photo)); addPart(history->owner().makeServiceMessage(
history,
MTPDmessage_ClientFlags(),
idManager->next(),
date,
message,
MTPDmessage::Flags(0),
peerToUser(from->id),
photo));
}; };
auto createChangeTitle = [&](const MTPDchannelAdminLogEventActionChangeTitle &action) { auto createChangeTitle = [&](const MTPDchannelAdminLogEventActionChangeTitle &action) {
@ -416,10 +424,21 @@ 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 bodyReplyTo = 0; auto bodyReplyTo = 0;
auto bodyViaBotId = 0; auto bodyViaBotId = 0;
auto newDescription = PrepareText(newValue, QString()); auto newDescription = PrepareText(newValue, QString());
auto body = history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), newDescription); auto body = history->owner().makeMessage(
history,
idManager->next(),
bodyFlags,
bodyClientFlags,
bodyReplyTo,
bodyViaBotId,
date,
peerToUser(from->id),
QString(),
newDescription);
if (!oldValue.isEmpty()) { if (!oldValue.isEmpty()) {
auto oldDescription = PrepareText(oldValue, QString()); auto oldDescription = PrepareText(oldValue, QString());
body->addLogEntryOriginal(id, tr::lng_admin_log_previous_description(tr::now), oldDescription); body->addLogEntryOriginal(id, tr::lng_admin_log_previous_description(tr::now), oldDescription);
@ -441,10 +460,21 @@ 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 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());
auto body = history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), newLink); auto body = history->owner().makeMessage(
history,
idManager->next(),
bodyFlags,
bodyClientFlags,
bodyReplyTo,
bodyViaBotId,
date,
peerToUser(from->id),
QString(),
newLink);
if (!oldValue.isEmpty()) { if (!oldValue.isEmpty()) {
auto oldLink = PrepareText(Core::App().createInternalLinkFull(oldValue), QString()); auto oldLink = PrepareText(Core::App().createInternalLinkFull(oldValue), QString());
body->addLogEntryOriginal(id, tr::lng_admin_log_previous_link(tr::now), oldLink); body->addLogEntryOriginal(id, tr::lng_admin_log_previous_link(tr::now), oldLink);
@ -503,6 +533,7 @@ void GenerateItems(
action.vmessage(), action.vmessage(),
idManager->next(), idManager->next(),
date), date),
MTPDmessage_ClientFlags(),
detachExistingItem)); detachExistingItem));
} }
}; };
@ -527,6 +558,7 @@ void GenerateItems(
action.vnew_message(), action.vnew_message(),
idManager->next(), idManager->next(),
date), date),
MTPDmessage_ClientFlags(),
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));
@ -548,6 +580,7 @@ void GenerateItems(
auto detachExistingItem = false; auto detachExistingItem = false;
addPart(history->createItem( addPart(history->createItem(
PrepareLogMessage(action.vmessage(), idManager->next(), date), PrepareLogMessage(action.vmessage(), idManager->next(), date),
MTPDmessage_ClientFlags(),
detachExistingItem)); detachExistingItem));
}; };
@ -567,18 +600,40 @@ 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 bodyReplyTo = 0; auto bodyReplyTo = 0;
auto bodyViaBotId = 0; auto bodyViaBotId = 0;
auto bodyText = GenerateParticipantChangeText(channel, action.vparticipant()); auto bodyText = GenerateParticipantChangeText(channel, action.vparticipant());
addPart(history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), bodyText)); addPart(history->owner().makeMessage(
history,
idManager->next(),
bodyFlags,
bodyClientFlags,
bodyReplyTo,
bodyViaBotId,
date,
peerToUser(from->id),
QString(),
bodyText));
}; };
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 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());
addPart(history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), bodyText)); addPart(history->owner().makeMessage(
history,
idManager->next(),
bodyFlags,
bodyClientFlags,
bodyReplyTo,
bodyViaBotId,
date,
peerToUser(from->id),
QString(),
bodyText));
}; };
auto createParticipantToggleAdmin = [&](const MTPDchannelAdminLogEventActionParticipantToggleAdmin &action) { auto createParticipantToggleAdmin = [&](const MTPDchannelAdminLogEventActionParticipantToggleAdmin &action) {
@ -589,10 +644,21 @@ 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 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());
addPart(history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), bodyText)); addPart(history->owner().makeMessage(
history,
idManager->next(),
bodyFlags,
bodyClientFlags,
bodyReplyTo,
bodyViaBotId,
date,
peerToUser(from->id),
QString(),
bodyText));
}; };
auto createChangeStickerSet = [&](const MTPDchannelAdminLogEventActionChangeStickerSet &action) { auto createChangeStickerSet = [&](const MTPDchannelAdminLogEventActionChangeStickerSet &action) {
@ -616,7 +682,14 @@ void GenerateItems(
auto message = HistoryService::PreparedText { text }; auto message = HistoryService::PreparedText { text };
message.links.push_back(fromLink); message.links.push_back(fromLink);
message.links.push_back(setLink); message.links.push_back(setLink);
addPart(history->owner().makeServiceMessage(history, idManager->next(), date, message, MTPDmessage::Flags(0), peerToUser(from->id))); addPart(history->owner().makeServiceMessage(
history,
MTPDmessage_ClientFlags(),
idManager->next(),
date,
message,
MTPDmessage::Flags(0),
peerToUser(from->id)));
} }
}; };
@ -630,10 +703,21 @@ 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 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());
addPart(history->owner().makeMessage(history, idManager->next(), bodyFlags, bodyReplyTo, bodyViaBotId, date, peerToUser(from->id), QString(), bodyText)); addPart(history->owner().makeMessage(
history,
idManager->next(),
bodyFlags,
bodyClientFlags,
bodyReplyTo,
bodyViaBotId,
date,
peerToUser(from->id),
QString(),
bodyText));
}; };
auto createStopPoll = [&](const MTPDchannelAdminLogEventActionStopPoll &action) { auto createStopPoll = [&](const MTPDchannelAdminLogEventActionStopPoll &action) {
@ -643,6 +727,7 @@ void GenerateItems(
auto detachExistingItem = false; auto detachExistingItem = false;
addPart(history->createItem( addPart(history->createItem(
PrepareLogMessage(action.vmessage(), idManager->next(), date), PrepareLogMessage(action.vmessage(), idManager->next(), date),
MTPDmessage_ClientFlags(),
detachExistingItem)); detachExistingItem));
}; };
@ -673,7 +758,14 @@ void GenerateItems(
auto message = HistoryService::PreparedText{ text }; auto message = HistoryService::PreparedText{ text };
message.links.push_back(fromLink); message.links.push_back(fromLink);
message.links.push_back(chatLink); message.links.push_back(chatLink);
addPart(history->owner().makeServiceMessage(history, idManager->next(), date, message, MTPDmessage::Flags(0), peerToUser(from->id))); addPart(history->owner().makeServiceMessage(
history,
MTPDmessage_ClientFlags(),
idManager->next(),
date,
message,
MTPDmessage::Flags(0),
peerToUser(from->id)));
} }
}; };

View File

@ -583,6 +583,7 @@ bool History::updateSendActionNeedsAnimating(crl::time now, bool force) {
HistoryItem *History::createItem( HistoryItem *History::createItem(
const MTPMessage &message, const MTPMessage &message,
MTPDmessage_ClientFlags clientFlags,
bool detachExistingItem) { bool detachExistingItem) {
const auto messageId = IdFromMessage(message); const auto messageId = IdFromMessage(message);
if (!messageId) { if (!messageId) {
@ -600,16 +601,18 @@ HistoryItem *History::createItem(
} }
return result; return result;
} }
return HistoryItem::Create(this, message); return HistoryItem::Create(this, message, clientFlags);
} }
std::vector<not_null<HistoryItem*>> History::createItems( std::vector<not_null<HistoryItem*>> History::createItems(
const QVector<MTPMessage> &data) { const QVector<MTPMessage> &data) {
auto result = std::vector<not_null<HistoryItem*>>(); auto result = std::vector<not_null<HistoryItem*>>();
result.reserve(data.size()); result.reserve(data.size());
const auto clientFlags = MTPDmessage_ClientFlags();
for (auto i = data.cend(), e = data.cbegin(); i != e;) { for (auto i = data.cend(), e = data.cbegin(); i != e;) {
const auto detachExistingItem = true; const auto detachExistingItem = true;
if (const auto item = createItem(*--i, detachExistingItem)) { const auto item = createItem(*--i, clientFlags, detachExistingItem);
if (item) {
result.emplace_back(item); result.emplace_back(item);
} }
} }
@ -618,12 +621,13 @@ std::vector<not_null<HistoryItem*>> History::createItems(
HistoryItem *History::addNewMessage( HistoryItem *History::addNewMessage(
const MTPMessage &msg, const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags,
NewMessageType type) { NewMessageType type) {
if (type == NewMessageType::Existing) { if (type == NewMessageType::Existing) {
return addToHistory(msg); return addToHistory(msg, clientFlags);
} }
if (!loadedAtBottom() || peer->migrateTo()) { if (!loadedAtBottom() || peer->migrateTo()) {
if (const auto item = addToHistory(msg)) { if (const auto item = addToHistory(msg, clientFlags)) {
setLastMessage(item); setLastMessage(item);
if (type == NewMessageType::Unread) { if (type == NewMessageType::Unread) {
newItemAdded(item); newItemAdded(item);
@ -633,16 +637,17 @@ HistoryItem *History::addNewMessage(
return nullptr; return nullptr;
} }
return addNewToLastBlock(msg, type); return addNewToLastBlock(msg, clientFlags, type);
} }
HistoryItem *History::addNewToLastBlock( HistoryItem *History::addNewToLastBlock(
const MTPMessage &msg, const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags,
NewMessageType type) { NewMessageType type) {
Expects(type != NewMessageType::Existing); Expects(type != NewMessageType::Existing);
const auto detachExistingItem = (type != NewMessageType::Last); const auto detachExistingItem = (type != NewMessageType::Last);
const auto item = createItem(msg, detachExistingItem); const auto item = createItem(msg, clientFlags, detachExistingItem);
if (!item || item->mainView()) { if (!item || item->mainView()) {
return item; return item;
} }
@ -681,14 +686,17 @@ void History::checkForLoadedAtTop(not_null<HistoryItem*> added) {
} }
} }
HistoryItem *History::addToHistory(const MTPMessage &msg) { HistoryItem *History::addToHistory(
const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags) {
const auto detachExistingItem = false; const auto detachExistingItem = false;
return createItem(msg, detachExistingItem); 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,
MTPDmessage_ClientFlags clientFlags,
TimeId date, TimeId date,
UserId from, UserId from,
const QString &postAuthor, const QString &postAuthor,
@ -698,6 +706,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this, this,
id, id,
flags, flags,
clientFlags,
date, date,
from, from,
postAuthor, postAuthor,
@ -708,6 +717,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
not_null<HistoryItem*> History::addNewLocalMessage( not_null<HistoryItem*> History::addNewLocalMessage(
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId, UserId viaBotId,
MsgId replyTo, MsgId replyTo,
TimeId date, TimeId date,
@ -721,6 +731,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this, this,
id, id,
flags, flags,
clientFlags,
replyTo, replyTo,
viaBotId, viaBotId,
date, date,
@ -735,6 +746,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
not_null<HistoryItem*> History::addNewLocalMessage( not_null<HistoryItem*> History::addNewLocalMessage(
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId, UserId viaBotId,
MsgId replyTo, MsgId replyTo,
TimeId date, TimeId date,
@ -748,6 +760,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this, this,
id, id,
flags, flags,
clientFlags,
replyTo, replyTo,
viaBotId, viaBotId,
date, date,
@ -762,6 +775,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
not_null<HistoryItem*> History::addNewLocalMessage( not_null<HistoryItem*> History::addNewLocalMessage(
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId, UserId viaBotId,
MsgId replyTo, MsgId replyTo,
TimeId date, TimeId date,
@ -774,6 +788,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this, this,
id, id,
flags, flags,
clientFlags,
replyTo, replyTo,
viaBotId, viaBotId,
date, date,
@ -865,8 +880,9 @@ void History::addUnreadMentionsSlice(const MTPmessages_Messages &result) {
auto added = false; auto added = false;
if (messages) { if (messages) {
const auto clientFlags = MTPDmessage_ClientFlags();
for (auto &message : *messages) { for (auto &message : *messages) {
if (auto item = addToHistory(message)) { if (auto item = addToHistory(message, clientFlags)) {
if (item->isUnreadMention()) { if (item->isUnreadMention()) {
_unreadMentions.insert(item->id); _unreadMentions.insert(item->id);
added = true; added = true;
@ -2450,6 +2466,7 @@ void History::setFakeChatListMessageFrom(const MTPmessages_Messages &data) {
} }
const auto item = owner().addNewMessage( const auto item = owner().addNewMessage(
*other, *other,
MTPDmessage_ClientFlags(),
NewMessageType::Existing); NewMessageType::Existing);
if (!item || item->isGroupMigrate()) { if (!item || item->isGroupMigrate()) {
// Not better than the last one. // Not better than the last one.

View File

@ -94,11 +94,17 @@ public:
void applyGroupAdminChanges(const base::flat_set<UserId> &changes); void applyGroupAdminChanges(const base::flat_set<UserId> &changes);
HistoryItem *addNewMessage(const MTPMessage &msg, NewMessageType type); HistoryItem *addNewMessage(
HistoryItem *addToHistory(const MTPMessage &msg); const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags,
NewMessageType type);
HistoryItem *addToHistory(
const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags);
not_null<HistoryItem*> addNewLocalMessage( not_null<HistoryItem*> addNewLocalMessage(
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date, TimeId date,
UserId from, UserId from,
const QString &postAuthor, const QString &postAuthor,
@ -106,6 +112,7 @@ public:
not_null<HistoryItem*> addNewLocalMessage( not_null<HistoryItem*> addNewLocalMessage(
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId, UserId viaBotId,
MsgId replyTo, MsgId replyTo,
TimeId date, TimeId date,
@ -117,6 +124,7 @@ public:
not_null<HistoryItem*> addNewLocalMessage( not_null<HistoryItem*> addNewLocalMessage(
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId, UserId viaBotId,
MsgId replyTo, MsgId replyTo,
TimeId date, TimeId date,
@ -128,6 +136,7 @@ public:
not_null<HistoryItem*> addNewLocalMessage( not_null<HistoryItem*> addNewLocalMessage(
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId, UserId viaBotId,
MsgId replyTo, MsgId replyTo,
TimeId date, TimeId date,
@ -139,6 +148,7 @@ public:
// Used only internally and for channel admin log. // Used only internally and for channel admin log.
HistoryItem *createItem( HistoryItem *createItem(
const MTPMessage &message, const MTPMessage &message,
MTPDmessage_ClientFlags clientFlags,
bool detachExistingItem); bool detachExistingItem);
std::vector<not_null<HistoryItem*>> createItems( std::vector<not_null<HistoryItem*>> createItems(
const QVector<MTPMessage> &data); const QVector<MTPMessage> &data);
@ -381,7 +391,10 @@ private:
// helper method for countScrollState(int top) // helper method for countScrollState(int top)
void countScrollTopItem(int top); void countScrollTopItem(int top);
HistoryItem *addNewToLastBlock(const MTPMessage &msg, NewMessageType type); HistoryItem *addNewToLastBlock(
const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags,
NewMessageType type);
// this method just removes a block from the blocks list // this method just removes a block from the blocks list
// when the last item from this block was detached and // when the last item from this block was detached and

View File

@ -59,6 +59,7 @@ not_null<HistoryItem*> CreateUnsupportedMessage(
not_null<History*> history, not_null<History*> history,
MsgId msgId, MsgId msgId,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
@ -76,6 +77,7 @@ not_null<HistoryItem*> CreateUnsupportedMessage(
history, history,
msgId, msgId,
flags, flags,
clientFlags,
replyTo, replyTo,
viaBotId, viaBotId,
date, date,
@ -167,12 +169,14 @@ HistoryItem::HistoryItem(
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date, TimeId date,
UserId from) UserId from)
: id(id) : id(id)
, _history(history) , _history(history)
, _from(from ? history->owner().user(from) : history->peer) , _from(from ? history->owner().user(from) : history->peer)
, _flags(flags) , _flags(flags)
, _clientFlags(clientFlags)
, _date(date) { , _date(date) {
if (IsClientMsgId(id)) { if (IsClientMsgId(id)) {
_history->registerLocalMessage(this); _history->registerLocalMessage(this);
@ -437,11 +441,11 @@ void HistoryItem::indexAsNewItem() {
} }
void HistoryItem::setRealId(MsgId newId) { void HistoryItem::setRealId(MsgId newId) {
Expects(_flags & MTPDmessage_ClientFlag::f_sending); Expects(_clientFlags & MTPDmessage_ClientFlag::f_sending);
Expects(IsClientMsgId(id)); Expects(IsClientMsgId(id));
const auto oldId = std::exchange(id, newId); const auto oldId = std::exchange(id, newId);
_flags &= ~MTPDmessage_ClientFlag::f_sending; _clientFlags &= ~MTPDmessage_ClientFlag::f_sending;
if (IsServerMsgId(id)) { if (IsServerMsgId(id)) {
_history->unregisterLocalMessage(this); _history->unregisterLocalMessage(this);
} }
@ -667,10 +671,10 @@ MsgId HistoryItem::idOriginal() const {
} }
void HistoryItem::sendFailed() { void HistoryItem::sendFailed() {
Expects(_flags & MTPDmessage_ClientFlag::f_sending); Expects(_clientFlags & MTPDmessage_ClientFlag::f_sending);
Expects(!(_flags & MTPDmessage_ClientFlag::f_failed)); Expects(!(_clientFlags & MTPDmessage_ClientFlag::f_failed));
_flags = (_flags | MTPDmessage_ClientFlag::f_failed) _clientFlags = (_clientFlags | MTPDmessage_ClientFlag::f_failed)
& ~MTPDmessage_ClientFlag::f_sending; & ~MTPDmessage_ClientFlag::f_sending;
if (history()->peer->isChannel()) { if (history()->peer->isChannel()) {
Notify::peerUpdatedDelayed( Notify::peerUpdatedDelayed(
@ -718,11 +722,11 @@ bool HistoryItem::unread() const {
} }
return true; return true;
} }
return (_flags & MTPDmessage_ClientFlag::f_clientside_unread); return (_clientFlags & MTPDmessage_ClientFlag::f_clientside_unread);
} }
void HistoryItem::markClientSideAsRead() { void HistoryItem::markClientSideAsRead() {
_flags &= ~MTPDmessage_ClientFlag::f_clientside_unread; _clientFlags &= ~MTPDmessage_ClientFlag::f_clientside_unread;
} }
MessageGroupId HistoryItem::groupId() const { MessageGroupId HistoryItem::groupId() const {
@ -842,7 +846,8 @@ ClickHandlerPtr goToMessageClickHandler(
not_null<HistoryItem*> HistoryItem::Create( not_null<HistoryItem*> HistoryItem::Create(
not_null<History*> history, not_null<History*> history,
const MTPMessage &message) { const MTPMessage &message,
MTPDmessage_ClientFlags clientFlags) {
return message.match([&](const MTPDmessage &data) -> HistoryItem* { return message.match([&](const MTPDmessage &data) -> HistoryItem* {
const auto media = data.vmedia(); const auto media = data.vmedia();
const auto checked = media const auto checked = media
@ -853,6 +858,7 @@ not_null<HistoryItem*> HistoryItem::Create(
history, history,
data.vid().v, data.vid().v,
data.vflags().v, data.vflags().v,
clientFlags,
data.vreply_to_msg_id().value_or_empty(), data.vreply_to_msg_id().value_or_empty(),
data.vvia_bot_id().value_or_empty(), data.vvia_bot_id().value_or_empty(),
data.vdate().v, data.vdate().v,
@ -863,24 +869,36 @@ not_null<HistoryItem*> HistoryItem::Create(
}; };
return history->owner().makeServiceMessage( return history->owner().makeServiceMessage(
history, history,
clientFlags,
data.vid().v, data.vid().v,
data.vdate().v, data.vdate().v,
text, text,
data.vflags().v, data.vflags().v,
data.vfrom_id().value_or_empty()); data.vfrom_id().value_or_empty());
} else if (checked == MediaCheckResult::HasTimeToLive) { } else if (checked == MediaCheckResult::HasTimeToLive) {
return history->owner().makeServiceMessage(history, data); return history->owner().makeServiceMessage(
history,
data,
clientFlags);
} }
return history->owner().makeMessage(history, data); return history->owner().makeMessage(history, data, clientFlags);
}, [&](const MTPDmessageService &data) -> HistoryItem* { }, [&](const MTPDmessageService &data) -> HistoryItem* {
if (data.vaction().type() == mtpc_messageActionPhoneCall) { if (data.vaction().type() == mtpc_messageActionPhoneCall) {
return history->owner().makeMessage(history, data); return history->owner().makeMessage(history, data, clientFlags);
} }
return history->owner().makeServiceMessage(history, data); return history->owner().makeServiceMessage(
history,
data,
clientFlags);
}, [&](const MTPDmessageEmpty &data) -> HistoryItem* { }, [&](const MTPDmessageEmpty &data) -> HistoryItem* {
const auto text = HistoryService::PreparedText{ const auto text = HistoryService::PreparedText{
tr::lng_message_empty(tr::now) tr::lng_message_empty(tr::now)
}; };
return history->owner().makeServiceMessage(history, data.vid().v, TimeId(0), text); return history->owner().makeServiceMessage(
history,
clientFlags,
data.vid().v,
TimeId(0),
text);
}); });
} }

View File

@ -60,11 +60,11 @@ class HistoryItem : public RuntimeComposer<HistoryItem> {
public: public:
static not_null<HistoryItem*> Create( static not_null<HistoryItem*> Create(
not_null<History*> history, not_null<History*> history,
const MTPMessage &message); const MTPMessage &message,
MTPDmessage_ClientFlags clientFlags);
struct Destroyer { struct Destroyer {
void operator()(HistoryItem *value); void operator()(HistoryItem *value);
}; };
virtual void dependencyItemRemoved(HistoryItem *dependency) { virtual void dependencyItemRemoved(HistoryItem *dependency) {
@ -142,29 +142,29 @@ public:
[[nodiscard]] MTPDreplyKeyboardMarkup::Flags replyKeyboardFlags() const; [[nodiscard]] MTPDreplyKeyboardMarkup::Flags replyKeyboardFlags() const;
[[nodiscard]] bool hasSwitchInlineButton() const { [[nodiscard]] bool hasSwitchInlineButton() const {
return _flags & MTPDmessage_ClientFlag::f_has_switch_inline_button; return _clientFlags & MTPDmessage_ClientFlag::f_has_switch_inline_button;
} }
[[nodiscard]] bool hasTextLinks() const { [[nodiscard]] bool hasTextLinks() const {
return _flags & MTPDmessage_ClientFlag::f_has_text_links; return _clientFlags & MTPDmessage_ClientFlag::f_has_text_links;
} }
[[nodiscard]] bool isGroupEssential() const { [[nodiscard]] bool isGroupEssential() const {
return _flags & MTPDmessage_ClientFlag::f_is_group_essential; return _clientFlags & MTPDmessage_ClientFlag::f_is_group_essential;
} }
[[nodiscard]] bool isLocalUpdateMedia() const { [[nodiscard]] bool isLocalUpdateMedia() const {
return _flags & MTPDmessage_ClientFlag::f_is_local_update_media; return _clientFlags & MTPDmessage_ClientFlag::f_is_local_update_media;
} }
void setIsLocalUpdateMedia(bool flag) { void setIsLocalUpdateMedia(bool flag) {
if (flag) { if (flag) {
_flags |= MTPDmessage_ClientFlag::f_is_local_update_media; _clientFlags |= MTPDmessage_ClientFlag::f_is_local_update_media;
} else { } else {
_flags &= ~MTPDmessage_ClientFlag::f_is_local_update_media; _clientFlags &= ~MTPDmessage_ClientFlag::f_is_local_update_media;
} }
} }
[[nodiscard]] bool isGroupMigrate() const { [[nodiscard]] bool isGroupMigrate() const {
return isGroupEssential() && isEmpty(); return isGroupEssential() && isEmpty();
} }
[[nodiscard]] bool isIsolatedEmoji() const { [[nodiscard]] bool isIsolatedEmoji() const {
return _flags & MTPDmessage_ClientFlag::f_isolated_emoji; return _clientFlags & MTPDmessage_ClientFlag::f_isolated_emoji;
} }
[[nodiscard]] bool hasViews() const { [[nodiscard]] bool hasViews() const {
return _flags & MTPDmessage::Flag::f_views; return _flags & MTPDmessage::Flag::f_views;
@ -176,10 +176,10 @@ public:
return _flags & MTPDmessage::Flag::f_silent; return _flags & MTPDmessage::Flag::f_silent;
} }
[[nodiscard]] bool isSending() const { [[nodiscard]] bool isSending() const {
return _flags & MTPDmessage_ClientFlag::f_sending; return _clientFlags & MTPDmessage_ClientFlag::f_sending;
} }
[[nodiscard]] bool hasFailed() const { [[nodiscard]] bool hasFailed() const {
return _flags & MTPDmessage_ClientFlag::f_failed; return _clientFlags & MTPDmessage_ClientFlag::f_failed;
} }
void sendFailed(); void sendFailed();
virtual int viewsCount() const { virtual int viewsCount() const {
@ -328,6 +328,7 @@ protected:
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date, TimeId date,
UserId from); UserId from);
@ -340,6 +341,7 @@ protected:
const not_null<History*> _history; const not_null<History*> _history;
not_null<PeerData*> _from; not_null<PeerData*> _from;
MTPDmessage::Flags _flags = 0; MTPDmessage::Flags _flags = 0;
MTPDmessage_ClientFlags _clientFlags = 0;
void invalidateChatListEntry(); void invalidateChatListEntry();

View File

@ -74,6 +74,10 @@ MTPDmessage::Flags NewForwardedFlags(
return result; return result;
} }
MTPDmessage_ClientFlags NewForwardedClientFlags() {
return NewMessageClientFlags();
}
bool CopyMarkupToForward(not_null<const HistoryItem*> item) { bool CopyMarkupToForward(not_null<const HistoryItem*> item) {
auto mediaOriginal = item->media(); auto mediaOriginal = item->media();
if (mediaOriginal && mediaOriginal->game()) { if (mediaOriginal && mediaOriginal->game()) {
@ -336,7 +340,7 @@ Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
} }
MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer) { MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer) {
MTPDmessage::Flags result = MTPDmessage_ClientFlag::f_sending | 0; MTPDmessage::Flags result = 0;
if (!peer->isSelf()) { if (!peer->isSelf()) {
result |= MTPDmessage::Flag::f_out; result |= MTPDmessage::Flag::f_out;
//if (p->isChat() || (p->isUser() && !p->asUser()->isBot())) { //if (p->isChat() || (p->isUser() && !p->asUser()->isBot())) {
@ -346,6 +350,10 @@ MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer) {
return result; return result;
} }
MTPDmessage_ClientFlags NewMessageClientFlags() {
return MTPDmessage_ClientFlag::f_sending;
}
QString GetErrorTextForForward( QString GetErrorTextForForward(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const HistoryItemsList &items, const HistoryItemsList &items,
@ -396,11 +404,13 @@ void HistoryMessage::FillForwardedInfo(
HistoryMessage::HistoryMessage( HistoryMessage::HistoryMessage(
not_null<History*> history, not_null<History*> history,
const MTPDmessage &data) const MTPDmessage &data,
MTPDmessage_ClientFlags clientFlags)
: HistoryItem( : HistoryItem(
history, history,
data.vid().v, data.vid().v,
data.vflags().v, data.vflags().v,
clientFlags,
data.vdate().v, data.vdate().v,
data.vfrom_id().value_or_empty()) { data.vfrom_id().value_or_empty()) {
auto config = CreateConfig(); auto config = CreateConfig();
@ -435,11 +445,13 @@ HistoryMessage::HistoryMessage(
HistoryMessage::HistoryMessage( HistoryMessage::HistoryMessage(
not_null<History*> history, not_null<History*> history,
const MTPDmessageService &data) const MTPDmessageService &data,
MTPDmessage_ClientFlags clientFlags)
: HistoryItem( : HistoryItem(
history, history,
data.vid().v, data.vid().v,
mtpCastFlags(data.vflags().v), mtpCastFlags(data.vflags().v),
clientFlags,
data.vdate().v, data.vdate().v,
data.vfrom_id().value_or_empty()) { data.vfrom_id().value_or_empty()) {
auto config = CreateConfig(); auto config = CreateConfig();
@ -465,6 +477,7 @@ HistoryMessage::HistoryMessage(
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date, TimeId date,
UserId from, UserId from,
const QString &postAuthor, const QString &postAuthor,
@ -473,6 +486,7 @@ HistoryMessage::HistoryMessage(
history, history,
id, id,
NewForwardedFlags(history->peer, from, original) | flags, NewForwardedFlags(history->peer, from, original) | flags,
NewForwardedClientFlags() | clientFlags,
date, date,
from) { from) {
const auto peer = history->peer; const auto peer = history->peer;
@ -547,14 +561,26 @@ HistoryMessage::HistoryMessage(
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
UserId from, UserId from,
const QString &postAuthor, const QString &postAuthor,
const TextWithEntities &textWithEntities) const TextWithEntities &textWithEntities)
: HistoryItem(history, id, flags & ~MTPDmessage::Flag::f_reply_markup, date, (flags & MTPDmessage::Flag::f_from_id) ? from : 0) { : HistoryItem(
createComponentsHelper(flags & ~MTPDmessage::Flag::f_reply_markup, replyTo, viaBotId, postAuthor, MTPReplyMarkup()); history,
id,
flags & ~MTPDmessage::Flag::f_reply_markup,
clientFlags,
date,
(flags & MTPDmessage::Flag::f_from_id) ? from : 0) {
createComponentsHelper(
flags & ~MTPDmessage::Flag::f_reply_markup,
replyTo,
viaBotId,
postAuthor,
MTPReplyMarkup());
setText(textWithEntities); setText(textWithEntities);
} }
@ -563,6 +589,7 @@ HistoryMessage::HistoryMessage(
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
@ -571,7 +598,13 @@ HistoryMessage::HistoryMessage(
not_null<DocumentData*> document, not_null<DocumentData*> document,
const TextWithEntities &caption, const TextWithEntities &caption,
const MTPReplyMarkup &markup) const MTPReplyMarkup &markup)
: HistoryItem(history, id, flags, date, (flags & MTPDmessage::Flag::f_from_id) ? from : 0) { : HistoryItem(
history,
id,
flags,
clientFlags,
date,
(flags & MTPDmessage::Flag::f_from_id) ? from : 0) {
createComponentsHelper(flags, replyTo, viaBotId, postAuthor, markup); createComponentsHelper(flags, replyTo, viaBotId, postAuthor, markup);
_media = std::make_unique<Data::MediaFile>(this, document); _media = std::make_unique<Data::MediaFile>(this, document);
@ -582,6 +615,7 @@ HistoryMessage::HistoryMessage(
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
@ -590,7 +624,13 @@ HistoryMessage::HistoryMessage(
not_null<PhotoData*> photo, not_null<PhotoData*> photo,
const TextWithEntities &caption, const TextWithEntities &caption,
const MTPReplyMarkup &markup) const MTPReplyMarkup &markup)
: HistoryItem(history, id, flags, date, (flags & MTPDmessage::Flag::f_from_id) ? from : 0) { : HistoryItem(
history,
id,
flags,
clientFlags,
date,
(flags & MTPDmessage::Flag::f_from_id) ? from : 0) {
createComponentsHelper(flags, replyTo, viaBotId, postAuthor, markup); createComponentsHelper(flags, replyTo, viaBotId, postAuthor, markup);
_media = std::make_unique<Data::MediaPhoto>(this, photo); _media = std::make_unique<Data::MediaPhoto>(this, photo);
@ -601,6 +641,7 @@ HistoryMessage::HistoryMessage(
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
@ -608,7 +649,13 @@ HistoryMessage::HistoryMessage(
const QString &postAuthor, const QString &postAuthor,
not_null<GameData*> game, not_null<GameData*> game,
const MTPReplyMarkup &markup) const MTPReplyMarkup &markup)
: HistoryItem(history, id, flags, date, (flags & MTPDmessage::Flag::f_from_id) ? from : 0) { : HistoryItem(
history,
id,
flags,
clientFlags,
date,
(flags & MTPDmessage::Flag::f_from_id) ? from : 0) {
createComponentsHelper(flags, replyTo, viaBotId, postAuthor, markup); createComponentsHelper(flags, replyTo, viaBotId, postAuthor, markup);
_media = std::make_unique<Data::MediaGame>(this, game); _media = std::make_unique<Data::MediaGame>(this, game);
@ -780,7 +827,7 @@ void HistoryMessage::createComponents(const CreateConfig &config) {
markup->create(*config.inlineMarkup); markup->create(*config.inlineMarkup);
} }
if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_has_switch_inline_button) { if (markup->flags & MTPDreplyKeyboardMarkup_ClientFlag::f_has_switch_inline_button) {
_flags |= MTPDmessage_ClientFlag::f_has_switch_inline_button; _clientFlags |= MTPDmessage_ClientFlag::f_has_switch_inline_button;
} }
} }
const auto from = displayFrom(); const auto from = displayFrom();
@ -1019,11 +1066,11 @@ void HistoryMessage::updateSentContent(
const MTPMessageMedia *media) { const MTPMessageMedia *media) {
const auto isolated = isolatedEmoji(); const auto isolated = isolatedEmoji();
setText(textWithEntities); setText(textWithEntities);
if (_flags & MTPDmessage_ClientFlag::f_from_inline_bot) { if (_clientFlags & MTPDmessage_ClientFlag::f_from_inline_bot) {
if (!media || !_media || !_media->updateInlineResultMedia(*media)) { if (!media || !_media || !_media->updateInlineResultMedia(*media)) {
refreshSentMedia(media); refreshSentMedia(media);
} }
_flags &= ~MTPDmessage_ClientFlag::f_from_inline_bot; _clientFlags &= ~MTPDmessage_ClientFlag::f_from_inline_bot;
} else if (media || _media || !isolated || isolated != isolatedEmoji()) { } else if (media || _media || !isolated || isolated != isolatedEmoji()) {
if (!media || !_media || !_media->updateSentMedia(*media)) { if (!media || !_media || !_media->updateSentMedia(*media)) {
refreshSentMedia(media); refreshSentMedia(media);
@ -1084,7 +1131,7 @@ void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
if (type == EntityType::Url if (type == EntityType::Url
|| type == EntityType::CustomUrl || type == EntityType::CustomUrl
|| type == EntityType::Email) { || type == EntityType::Email) {
_flags |= MTPDmessage_ClientFlag::f_has_text_links; _clientFlags |= MTPDmessage_ClientFlag::f_has_text_links;
break; break;
} }
} }
@ -1123,16 +1170,16 @@ void HistoryMessage::setEmptyText() {
} }
void HistoryMessage::clearIsolatedEmoji() { void HistoryMessage::clearIsolatedEmoji() {
if (!(_flags & MTPDmessage_ClientFlag::f_isolated_emoji)) { if (!(_clientFlags & MTPDmessage_ClientFlag::f_isolated_emoji)) {
return; return;
} }
history()->session().emojiStickersPack().remove(this); history()->session().emojiStickersPack().remove(this);
_flags &= ~MTPDmessage_ClientFlag::f_isolated_emoji; _clientFlags &= ~MTPDmessage_ClientFlag::f_isolated_emoji;
} }
void HistoryMessage::checkIsolatedEmoji() { void HistoryMessage::checkIsolatedEmoji() {
if (history()->session().emojiStickersPack().add(this)) { if (history()->session().emojiStickersPack().add(this)) {
_flags |= MTPDmessage_ClientFlag::f_isolated_emoji; _clientFlags |= MTPDmessage_ClientFlag::f_isolated_emoji;
} }
} }

View File

@ -18,6 +18,7 @@ struct HistoryMessageEdited;
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback( Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
const FullMsgId &msgId); const FullMsgId &msgId);
MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer); MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
MTPDmessage_ClientFlags NewMessageClientFlags();
QString GetErrorTextForForward( QString GetErrorTextForForward(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const HistoryItemsList &items, const HistoryItemsList &items,
@ -33,14 +34,17 @@ class HistoryMessage : public HistoryItem {
public: public:
HistoryMessage( HistoryMessage(
not_null<History*> history, not_null<History*> history,
const MTPDmessage &data); const MTPDmessage &data,
MTPDmessage_ClientFlags clientFlags);
HistoryMessage( HistoryMessage(
not_null<History*> history, not_null<History*> history,
const MTPDmessageService &data); const MTPDmessageService &data,
MTPDmessage_ClientFlags clientFlags);
HistoryMessage( HistoryMessage(
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date, TimeId date,
UserId from, UserId from,
const QString &postAuthor, const QString &postAuthor,
@ -49,6 +53,7 @@ public:
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
@ -59,6 +64,7 @@ public:
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
@ -71,6 +77,7 @@ public:
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,
@ -83,6 +90,7 @@ public:
not_null<History*> history, not_null<History*> history,
MsgId id, MsgId id,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo, MsgId replyTo,
UserId viaBotId, UserId viaBotId,
TimeId date, TimeId date,

View File

@ -299,13 +299,13 @@ void HistoryService::applyAction(const MTPMessageAction &action) {
}, [](const MTPDphotoEmpty &) { }, [](const MTPDphotoEmpty &) {
}); });
}, [&](const MTPDmessageActionChatCreate &) { }, [&](const MTPDmessageActionChatCreate &) {
_flags |= MTPDmessage_ClientFlag::f_is_group_essential; _clientFlags |= MTPDmessage_ClientFlag::f_is_group_essential;
}, [&](const MTPDmessageActionChannelCreate &) { }, [&](const MTPDmessageActionChannelCreate &) {
_flags |= MTPDmessage_ClientFlag::f_is_group_essential; _clientFlags |= MTPDmessage_ClientFlag::f_is_group_essential;
}, [&](const MTPDmessageActionChatMigrateTo &) { }, [&](const MTPDmessageActionChatMigrateTo &) {
_flags |= MTPDmessage_ClientFlag::f_is_group_essential; _clientFlags |= MTPDmessage_ClientFlag::f_is_group_essential;
}, [&](const MTPDmessageActionChannelMigrateFrom &) { }, [&](const MTPDmessageActionChannelMigrateFrom &) {
_flags |= MTPDmessage_ClientFlag::f_is_group_essential; _clientFlags |= MTPDmessage_ClientFlag::f_is_group_essential;
}, [](const auto &) { }, [](const auto &) {
}); });
} }
@ -497,11 +497,13 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() {
HistoryService::HistoryService( HistoryService::HistoryService(
not_null<History*> history, not_null<History*> history,
const MTPDmessage &data) const MTPDmessage &data,
: HistoryItem( MTPDmessage_ClientFlags clientFlags)
: HistoryItem(
history, history,
data.vid().v, data.vid().v,
data.vflags().v, data.vflags().v,
clientFlags,
data.vdate().v, data.vdate().v,
data.vfrom_id().value_or_empty()) { data.vfrom_id().value_or_empty()) {
createFromMtp(data); createFromMtp(data);
@ -509,11 +511,13 @@ HistoryService::HistoryService(
HistoryService::HistoryService( HistoryService::HistoryService(
not_null<History*> history, not_null<History*> history,
const MTPDmessageService &data) const MTPDmessageService &data,
MTPDmessage_ClientFlags clientFlags)
: HistoryItem( : HistoryItem(
history, history,
data.vid().v, data.vid().v,
mtpCastFlags(data.vflags().v), mtpCastFlags(data.vflags().v),
clientFlags,
data.vdate().v, data.vdate().v,
data.vfrom_id().value_or_empty()) { data.vfrom_id().value_or_empty()) {
createFromMtp(data); createFromMtp(data);
@ -521,13 +525,14 @@ HistoryService::HistoryService(
HistoryService::HistoryService( HistoryService::HistoryService(
not_null<History*> history, not_null<History*> history,
MTPDmessage_ClientFlags clientFlags,
MsgId id, MsgId id,
TimeId date, TimeId date,
const PreparedText &message, const PreparedText &message,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
UserId from, UserId from,
PhotoData *photo) PhotoData *photo)
: HistoryItem(history, id, flags, date, from) { : HistoryItem(history, id, flags, clientFlags, date, from) {
setServiceText(message); setServiceText(message);
if (photo) { if (photo) {
_media = std::make_unique<Data::MediaPhoto>( _media = std::make_unique<Data::MediaPhoto>(
@ -794,6 +799,7 @@ not_null<HistoryService*> GenerateJoinedMessage(
MTPDmessage::Flags flags) { MTPDmessage::Flags flags) {
return new HistoryService( return new HistoryService(
history, history,
MTPDmessage_ClientFlags(),
clientMsgId(), clientMsgId(),
inviteDate, inviteDate,
GenerateJoinedText(history, inviter), GenerateJoinedText(history, inviter),

View File

@ -58,12 +58,17 @@ public:
QList<ClickHandlerPtr> links; QList<ClickHandlerPtr> links;
}; };
HistoryService(not_null<History*> history, const MTPDmessage &data);
HistoryService( HistoryService(
not_null<History*> history, not_null<History*> history,
const MTPDmessageService &data); const MTPDmessage &data,
MTPDmessage_ClientFlags clientFlags);
HistoryService( HistoryService(
not_null<History*> history, not_null<History*> history,
const MTPDmessageService &data,
MTPDmessage_ClientFlags clientFlags);
HistoryService(
not_null<History*> history,
MTPDmessage_ClientFlags clientFlags,
MsgId id, MsgId id,
TimeId date, TimeId date,
const PreparedText &message, const PreparedText &message,

View File

@ -4363,6 +4363,7 @@ void HistoryWidget::sendFileConfirmed(
auto flags = (isEditing ? MTPDmessage::Flags() : NewMessageFlags(peer)) auto flags = (isEditing ? MTPDmessage::Flags() : NewMessageFlags(peer))
| MTPDmessage::Flag::f_entities | MTPDmessage::Flag::f_entities
| MTPDmessage::Flag::f_media; | MTPDmessage::Flag::f_media;
auto clientFlags = NewMessageClientFlags();
if (file->to.replyTo) { if (file->to.replyTo) {
flags |= MTPDmessage::Flag::f_reply_to_msg_id; flags |= MTPDmessage::Flag::f_reply_to_msg_id;
} }
@ -4417,7 +4418,10 @@ void HistoryWidget::sendFileConfirmed(
itemToEdit->savePreviousMedia(); itemToEdit->savePreviousMedia();
itemToEdit->applyEdition(mtpMessage.c_message()); itemToEdit->applyEdition(mtpMessage.c_message());
} else { } else {
history->addNewMessage(mtpMessage, NewMessageType::Unread); history->addNewMessage(
mtpMessage,
clientFlags,
NewMessageType::Unread);
} }
} else if (file->type == SendMediaType::File) { } else if (file->type == SendMediaType::File) {
const auto documentFlags = MTPDmessageMediaDocument::Flag::f_document | 0; const auto documentFlags = MTPDmessageMediaDocument::Flag::f_document | 0;
@ -4448,7 +4452,10 @@ void HistoryWidget::sendFileConfirmed(
itemToEdit->savePreviousMedia(); itemToEdit->savePreviousMedia();
itemToEdit->applyEdition(mtpMessage.c_message()); itemToEdit->applyEdition(mtpMessage.c_message());
} else { } else {
history->addNewMessage(mtpMessage, NewMessageType::Unread); history->addNewMessage(
mtpMessage,
clientFlags,
NewMessageType::Unread);
} }
} else if (file->type == SendMediaType::Audio) { } else if (file->type == SendMediaType::Audio) {
if (!peer->isChannel() || peer->isMegagroup()) { if (!peer->isChannel() || peer->isMegagroup()) {
@ -4477,6 +4484,7 @@ void HistoryWidget::sendFileConfirmed(
MTPint(), MTPint(),
MTP_string(messagePostAuthor), MTP_string(messagePostAuthor),
MTP_long(groupId)), MTP_long(groupId)),
clientFlags,
NewMessageType::Unread); NewMessageType::Unread);
// Voices can't be edited. // Voices can't be edited.
} else { } else {

View File

@ -320,15 +320,35 @@ bool Result::hasThumbDisplay() const {
return false; return false;
}; };
void Result::addToHistory(History *history, MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate, UserId viaBotId, MsgId replyToId, const QString &postAuthor) const { void Result::addToHistory(
flags |= MTPDmessage_ClientFlag::f_from_inline_bot; History *history,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId,
UserId fromId,
MTPint mtpDate,
UserId viaBotId,
MsgId replyToId,
const QString &postAuthor) const {
clientFlags |= MTPDmessage_ClientFlag::f_from_inline_bot;
auto markup = MTPReplyMarkup(); auto markup = MTPReplyMarkup();
if (_mtpKeyboard) { if (_mtpKeyboard) {
flags |= MTPDmessage::Flag::f_reply_markup; flags |= MTPDmessage::Flag::f_reply_markup;
markup = *_mtpKeyboard; markup = *_mtpKeyboard;
} }
sendData->addToHistory(this, history, flags, msgId, fromId, mtpDate, viaBotId, replyToId, postAuthor, markup); sendData->addToHistory(
this,
history,
flags,
clientFlags,
msgId,
fromId,
mtpDate,
viaBotId,
replyToId,
postAuthor,
markup);
} }
QString Result::getErrorOnSend(History *history) const { QString Result::getErrorOnSend(History *history) const {

View File

@ -54,7 +54,16 @@ public:
bool hasThumbDisplay() const; bool hasThumbDisplay() const;
void addToHistory(History *history, MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate, UserId viaBotId, MsgId replyToId, const QString &postAuthor) const; void addToHistory(
History *history,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId,
UserId fromId,
MTPint mtpDate,
UserId viaBotId,
MsgId replyToId,
const QString &postAuthor) const;
QString getErrorOnSend(History *history) const; QString getErrorOnSend(History *history) const;
// interface for Layout:: usage // interface for Layout:: usage

View File

@ -29,6 +29,7 @@ void SendDataCommon::addToHistory(
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -58,6 +59,7 @@ void SendDataCommon::addToHistory(
MTPint(), MTPint(),
MTP_string(postAuthor), MTP_string(postAuthor),
MTPlong()), MTPlong()),
clientFlags,
NewMessageType::Unread); NewMessageType::Unread);
} }
@ -121,6 +123,7 @@ void SendPhoto::addToHistory(
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -131,6 +134,7 @@ void SendPhoto::addToHistory(
history->addNewLocalMessage( history->addNewLocalMessage(
msgId, msgId,
flags, flags,
clientFlags,
viaBotId, viaBotId,
replyToId, replyToId,
mtpDate.v, mtpDate.v,
@ -154,6 +158,7 @@ void SendFile::addToHistory(
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -164,6 +169,7 @@ void SendFile::addToHistory(
history->addNewLocalMessage( history->addNewLocalMessage(
msgId, msgId,
flags, flags,
clientFlags,
viaBotId, viaBotId,
replyToId, replyToId,
mtpDate.v, mtpDate.v,
@ -201,6 +207,7 @@ void SendGame::addToHistory(
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -211,6 +218,7 @@ void SendGame::addToHistory(
history->addNewLocalMessage( history->addNewLocalMessage(
msgId, msgId,
flags, flags,
clientFlags,
viaBotId, viaBotId,
replyToId, replyToId,
mtpDate.v, mtpDate.v,

View File

@ -31,6 +31,7 @@ public:
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -69,6 +70,7 @@ public:
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -203,6 +205,7 @@ public:
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -242,6 +245,7 @@ public:
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,
@ -276,6 +280,7 @@ public:
const Result *owner, const Result *owner,
not_null<History*> history, not_null<History*> history,
MTPDmessage::Flags flags, MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId msgId, MsgId msgId,
UserId fromId, UserId fromId,
MTPint mtpDate, MTPint mtpDate,

View File

@ -69,7 +69,8 @@ enum class MTPDmessage_ClientFlag : uint32 {
// update this when adding new client side flags // update this when adding new client side flags
MIN_FIELD = (1U << 21), MIN_FIELD = (1U << 21),
}; };
DEFINE_MTP_CLIENT_FLAGS(MTPDmessage) inline constexpr bool is_flag_type(MTPDmessage_ClientFlag) { return true; }
using MTPDmessage_ClientFlags = base::flags<MTPDmessage_ClientFlag>;
enum class MTPDreplyKeyboardMarkup_ClientFlag : uint32 { enum class MTPDreplyKeyboardMarkup_ClientFlag : uint32 {
// none (zero) markup // none (zero) markup

View File

@ -160,7 +160,10 @@ AdminLog::OwnedItem GenerateForwardedItem(
MTPstring(), // post_author MTPstring(), // post_author
MTPlong() // grouped_id MTPlong() // grouped_id
).match([&](const MTPDmessage &data) { ).match([&](const MTPDmessage &data) {
return history->owner().makeMessage(history, data); return history->owner().makeMessage(
history,
data,
MTPDmessage_ClientFlags());
}, [](auto &&) -> not_null<HistoryMessage*> { }, [](auto &&) -> not_null<HistoryMessage*> {
Unexpected("Type in GenerateForwardedItem."); Unexpected("Type in GenerateForwardedItem.");
}); });

View File

@ -271,12 +271,14 @@ 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 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(
history, history,
id, id,
flags, flags,
clientFlags,
replyTo, replyTo,
viaBotId, viaBotId,
base::unixtime::now(), base::unixtime::now(),
@ -319,7 +321,8 @@ AdminLog::OwnedItem GenerateContactItem(
MTP_long(0)); MTP_long(0));
const auto item = history->owner().makeMessage( const auto item = history->owner().makeMessage(
history, history,
message.c_message()); message.c_message(),
MTPDmessage_ClientFlags());
return AdminLog::OwnedItem(delegate, item); return AdminLog::OwnedItem(delegate, item);
} }