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

View File

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

View File

@ -284,12 +284,14 @@ 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 replyTo = 0;
const auto viaBotId = 0;
const auto item = history->owner().makeMessage(
history,
++id,
flags,
clientFlags,
replyTo,
viaBotId,
base::unixtime::now(),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -387,7 +387,15 @@ void GenerateItems(
auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr) {
auto message = HistoryService::PreparedText { text };
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) {
@ -416,10 +424,21 @@ void GenerateItems(
addSimpleServiceMessage(text);
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
auto bodyClientFlags = MTPDmessage_ClientFlags();
auto bodyReplyTo = 0;
auto bodyViaBotId = 0;
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()) {
auto oldDescription = PrepareText(oldValue, QString());
body->addLogEntryOriginal(id, tr::lng_admin_log_previous_description(tr::now), oldDescription);
@ -441,10 +460,21 @@ void GenerateItems(
addSimpleServiceMessage(text);
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
auto bodyClientFlags = MTPDmessage_ClientFlags();
auto bodyReplyTo = 0;
auto bodyViaBotId = 0;
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()) {
auto oldLink = PrepareText(Core::App().createInternalLinkFull(oldValue), QString());
body->addLogEntryOriginal(id, tr::lng_admin_log_previous_link(tr::now), oldLink);
@ -503,6 +533,7 @@ void GenerateItems(
action.vmessage(),
idManager->next(),
date),
MTPDmessage_ClientFlags(),
detachExistingItem));
}
};
@ -527,6 +558,7 @@ void GenerateItems(
action.vnew_message(),
idManager->next(),
date),
MTPDmessage_ClientFlags(),
detachExistingItem);
if (oldValue.text.isEmpty()) {
oldValue = PrepareText(QString(), tr::lng_admin_log_empty_text(tr::now));
@ -548,6 +580,7 @@ void GenerateItems(
auto detachExistingItem = false;
addPart(history->createItem(
PrepareLogMessage(action.vmessage(), idManager->next(), date),
MTPDmessage_ClientFlags(),
detachExistingItem));
};
@ -567,18 +600,40 @@ void GenerateItems(
auto createParticipantInvite = [&](const MTPDchannelAdminLogEventActionParticipantInvite &action) {
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
auto bodyClientFlags = MTPDmessage_ClientFlags();
auto bodyReplyTo = 0;
auto bodyViaBotId = 0;
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 bodyFlags = Flag::f_entities | Flag::f_from_id;
auto bodyClientFlags = MTPDmessage_ClientFlags();
auto bodyReplyTo = 0;
auto bodyViaBotId = 0;
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) {
@ -589,10 +644,21 @@ void GenerateItems(
return;
}
auto bodyFlags = Flag::f_entities | Flag::f_from_id;
auto bodyClientFlags = MTPDmessage_ClientFlags();
auto bodyReplyTo = 0;
auto bodyViaBotId = 0;
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) {
@ -616,7 +682,14 @@ void GenerateItems(
auto message = HistoryService::PreparedText { text };
message.links.push_back(fromLink);
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 bodyFlags = Flag::f_entities | Flag::f_from_id;
auto bodyClientFlags = MTPDmessage_ClientFlags();
auto bodyReplyTo = 0;
auto bodyViaBotId = 0;
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) {
@ -643,6 +727,7 @@ void GenerateItems(
auto detachExistingItem = false;
addPart(history->createItem(
PrepareLogMessage(action.vmessage(), idManager->next(), date),
MTPDmessage_ClientFlags(),
detachExistingItem));
};
@ -673,7 +758,14 @@ void GenerateItems(
auto message = HistoryService::PreparedText{ text };
message.links.push_back(fromLink);
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(
const MTPMessage &message,
MTPDmessage_ClientFlags clientFlags,
bool detachExistingItem) {
const auto messageId = IdFromMessage(message);
if (!messageId) {
@ -600,16 +601,18 @@ HistoryItem *History::createItem(
}
return result;
}
return HistoryItem::Create(this, message);
return HistoryItem::Create(this, message, clientFlags);
}
std::vector<not_null<HistoryItem*>> History::createItems(
const QVector<MTPMessage> &data) {
auto result = std::vector<not_null<HistoryItem*>>();
result.reserve(data.size());
const auto clientFlags = MTPDmessage_ClientFlags();
for (auto i = data.cend(), e = data.cbegin(); i != e;) {
const auto detachExistingItem = true;
if (const auto item = createItem(*--i, detachExistingItem)) {
const auto item = createItem(*--i, clientFlags, detachExistingItem);
if (item) {
result.emplace_back(item);
}
}
@ -618,12 +621,13 @@ std::vector<not_null<HistoryItem*>> History::createItems(
HistoryItem *History::addNewMessage(
const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags,
NewMessageType type) {
if (type == NewMessageType::Existing) {
return addToHistory(msg);
return addToHistory(msg, clientFlags);
}
if (!loadedAtBottom() || peer->migrateTo()) {
if (const auto item = addToHistory(msg)) {
if (const auto item = addToHistory(msg, clientFlags)) {
setLastMessage(item);
if (type == NewMessageType::Unread) {
newItemAdded(item);
@ -633,16 +637,17 @@ HistoryItem *History::addNewMessage(
return nullptr;
}
return addNewToLastBlock(msg, type);
return addNewToLastBlock(msg, clientFlags, type);
}
HistoryItem *History::addNewToLastBlock(
const MTPMessage &msg,
MTPDmessage_ClientFlags clientFlags,
NewMessageType type) {
Expects(type != NewMessageType::Existing);
const auto detachExistingItem = (type != NewMessageType::Last);
const auto item = createItem(msg, detachExistingItem);
const auto item = createItem(msg, clientFlags, detachExistingItem);
if (!item || item->mainView()) {
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;
return createItem(msg, detachExistingItem);
return createItem(msg, clientFlags, detachExistingItem);
}
not_null<HistoryItem*> History::addNewLocalMessage(
MsgId id,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date,
UserId from,
const QString &postAuthor,
@ -698,6 +706,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this,
id,
flags,
clientFlags,
date,
from,
postAuthor,
@ -708,6 +717,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
not_null<HistoryItem*> History::addNewLocalMessage(
MsgId id,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId,
MsgId replyTo,
TimeId date,
@ -721,6 +731,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this,
id,
flags,
clientFlags,
replyTo,
viaBotId,
date,
@ -735,6 +746,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
not_null<HistoryItem*> History::addNewLocalMessage(
MsgId id,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId,
MsgId replyTo,
TimeId date,
@ -748,6 +760,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this,
id,
flags,
clientFlags,
replyTo,
viaBotId,
date,
@ -762,6 +775,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
not_null<HistoryItem*> History::addNewLocalMessage(
MsgId id,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
UserId viaBotId,
MsgId replyTo,
TimeId date,
@ -774,6 +788,7 @@ not_null<HistoryItem*> History::addNewLocalMessage(
this,
id,
flags,
clientFlags,
replyTo,
viaBotId,
date,
@ -865,8 +880,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)) {
if (auto item = addToHistory(message, clientFlags)) {
if (item->isUnreadMention()) {
_unreadMentions.insert(item->id);
added = true;
@ -2450,6 +2466,7 @@ void History::setFakeChatListMessageFrom(const MTPmessages_Messages &data) {
}
const auto item = owner().addNewMessage(
*other,
MTPDmessage_ClientFlags(),
NewMessageType::Existing);
if (!item || item->isGroupMigrate()) {
// Not better than the last one.

View File

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

View File

@ -59,6 +59,7 @@ not_null<HistoryItem*> CreateUnsupportedMessage(
not_null<History*> history,
MsgId msgId,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
MsgId replyTo,
UserId viaBotId,
TimeId date,
@ -76,6 +77,7 @@ not_null<HistoryItem*> CreateUnsupportedMessage(
history,
msgId,
flags,
clientFlags,
replyTo,
viaBotId,
date,
@ -167,12 +169,14 @@ HistoryItem::HistoryItem(
not_null<History*> history,
MsgId id,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date,
UserId from)
: id(id)
, _history(history)
, _from(from ? history->owner().user(from) : history->peer)
, _flags(flags)
, _clientFlags(clientFlags)
, _date(date) {
if (IsClientMsgId(id)) {
_history->registerLocalMessage(this);
@ -437,11 +441,11 @@ void HistoryItem::indexAsNewItem() {
}
void HistoryItem::setRealId(MsgId newId) {
Expects(_flags & MTPDmessage_ClientFlag::f_sending);
Expects(_clientFlags & MTPDmessage_ClientFlag::f_sending);
Expects(IsClientMsgId(id));
const auto oldId = std::exchange(id, newId);
_flags &= ~MTPDmessage_ClientFlag::f_sending;
_clientFlags &= ~MTPDmessage_ClientFlag::f_sending;
if (IsServerMsgId(id)) {
_history->unregisterLocalMessage(this);
}
@ -667,10 +671,10 @@ MsgId HistoryItem::idOriginal() const {
}
void HistoryItem::sendFailed() {
Expects(_flags & MTPDmessage_ClientFlag::f_sending);
Expects(!(_flags & MTPDmessage_ClientFlag::f_failed));
Expects(_clientFlags & MTPDmessage_ClientFlag::f_sending);
Expects(!(_clientFlags & MTPDmessage_ClientFlag::f_failed));
_flags = (_flags | MTPDmessage_ClientFlag::f_failed)
_clientFlags = (_clientFlags | MTPDmessage_ClientFlag::f_failed)
& ~MTPDmessage_ClientFlag::f_sending;
if (history()->peer->isChannel()) {
Notify::peerUpdatedDelayed(
@ -718,11 +722,11 @@ bool HistoryItem::unread() const {
}
return true;
}
return (_flags & MTPDmessage_ClientFlag::f_clientside_unread);
return (_clientFlags & MTPDmessage_ClientFlag::f_clientside_unread);
}
void HistoryItem::markClientSideAsRead() {
_flags &= ~MTPDmessage_ClientFlag::f_clientside_unread;
_clientFlags &= ~MTPDmessage_ClientFlag::f_clientside_unread;
}
MessageGroupId HistoryItem::groupId() const {
@ -842,7 +846,8 @@ ClickHandlerPtr goToMessageClickHandler(
not_null<HistoryItem*> HistoryItem::Create(
not_null<History*> history,
const MTPMessage &message) {
const MTPMessage &message,
MTPDmessage_ClientFlags clientFlags) {
return message.match([&](const MTPDmessage &data) -> HistoryItem* {
const auto media = data.vmedia();
const auto checked = media
@ -853,6 +858,7 @@ not_null<HistoryItem*> HistoryItem::Create(
history,
data.vid().v,
data.vflags().v,
clientFlags,
data.vreply_to_msg_id().value_or_empty(),
data.vvia_bot_id().value_or_empty(),
data.vdate().v,
@ -863,24 +869,36 @@ not_null<HistoryItem*> HistoryItem::Create(
};
return history->owner().makeServiceMessage(
history,
clientFlags,
data.vid().v,
data.vdate().v,
text,
data.vflags().v,
data.vfrom_id().value_or_empty());
} 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* {
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 auto text = HistoryService::PreparedText{
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:
static not_null<HistoryItem*> Create(
not_null<History*> history,
const MTPMessage &message);
const MTPMessage &message,
MTPDmessage_ClientFlags clientFlags);
struct Destroyer {
void operator()(HistoryItem *value);
};
virtual void dependencyItemRemoved(HistoryItem *dependency) {
@ -142,29 +142,29 @@ public:
[[nodiscard]] MTPDreplyKeyboardMarkup::Flags replyKeyboardFlags() 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 {
return _flags & MTPDmessage_ClientFlag::f_has_text_links;
return _clientFlags & MTPDmessage_ClientFlag::f_has_text_links;
}
[[nodiscard]] bool isGroupEssential() const {
return _flags & MTPDmessage_ClientFlag::f_is_group_essential;
return _clientFlags & MTPDmessage_ClientFlag::f_is_group_essential;
}
[[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) {
if (flag) {
_flags |= MTPDmessage_ClientFlag::f_is_local_update_media;
_clientFlags |= MTPDmessage_ClientFlag::f_is_local_update_media;
} else {
_flags &= ~MTPDmessage_ClientFlag::f_is_local_update_media;
_clientFlags &= ~MTPDmessage_ClientFlag::f_is_local_update_media;
}
}
[[nodiscard]] bool isGroupMigrate() const {
return isGroupEssential() && isEmpty();
}
[[nodiscard]] bool isIsolatedEmoji() const {
return _flags & MTPDmessage_ClientFlag::f_isolated_emoji;
return _clientFlags & MTPDmessage_ClientFlag::f_isolated_emoji;
}
[[nodiscard]] bool hasViews() const {
return _flags & MTPDmessage::Flag::f_views;
@ -176,10 +176,10 @@ public:
return _flags & MTPDmessage::Flag::f_silent;
}
[[nodiscard]] bool isSending() const {
return _flags & MTPDmessage_ClientFlag::f_sending;
return _clientFlags & MTPDmessage_ClientFlag::f_sending;
}
[[nodiscard]] bool hasFailed() const {
return _flags & MTPDmessage_ClientFlag::f_failed;
return _clientFlags & MTPDmessage_ClientFlag::f_failed;
}
void sendFailed();
virtual int viewsCount() const {
@ -328,6 +328,7 @@ protected:
not_null<History*> history,
MsgId id,
MTPDmessage::Flags flags,
MTPDmessage_ClientFlags clientFlags,
TimeId date,
UserId from);
@ -340,6 +341,7 @@ protected:
const not_null<History*> _history;
not_null<PeerData*> _from;
MTPDmessage::Flags _flags = 0;
MTPDmessage_ClientFlags _clientFlags = 0;
void invalidateChatListEntry();

View File

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

View File

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

View File

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

View File

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

View File

@ -320,15 +320,35 @@ bool Result::hasThumbDisplay() const {
return false;
};
void Result::addToHistory(History *history, MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate, UserId viaBotId, MsgId replyToId, const QString &postAuthor) const {
flags |= MTPDmessage_ClientFlag::f_from_inline_bot;
void Result::addToHistory(
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();
if (_mtpKeyboard) {
flags |= MTPDmessage::Flag::f_reply_markup;
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 {

View File

@ -54,7 +54,16 @@ public:
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;
// interface for Layout:: usage

View File

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

View File

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

View File

@ -69,7 +69,8 @@ enum class MTPDmessage_ClientFlag : uint32 {
// update this when adding new client side flags
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 {
// none (zero) markup

View File

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

View File

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