2016-09-27 14:20:49 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-09-27 14:20:49 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
#include "history/history_item.h"
|
|
|
|
|
2020-09-01 06:44:18 +00:00
|
|
|
namespace Api {
|
|
|
|
struct SendAction;
|
2020-11-19 13:23:51 +00:00
|
|
|
struct SendOptions;
|
2020-09-01 06:44:18 +00:00
|
|
|
} // namespace Api
|
|
|
|
|
2021-12-31 12:47:23 +00:00
|
|
|
namespace Data {
|
|
|
|
struct SponsoredFrom;
|
|
|
|
} // namespace Data
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
class Message;
|
|
|
|
} // namespace HistoryView
|
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
struct HistoryMessageEdited;
|
2020-09-01 06:44:18 +00:00
|
|
|
struct HistoryMessageReply;
|
2020-09-03 07:19:02 +00:00
|
|
|
struct HistoryMessageViews;
|
2021-10-02 11:28:21 +00:00
|
|
|
struct HistoryMessageMarkupData;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2021-11-08 08:32:25 +00:00
|
|
|
void RequestDependentMessageData(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
PeerId peerId,
|
|
|
|
MsgId msgId);
|
2021-07-28 11:55:02 +00:00
|
|
|
[[nodiscard]] MessageFlags NewMessageFlags(not_null<PeerData*> peer);
|
2020-11-19 13:23:51 +00:00
|
|
|
[[nodiscard]] bool ShouldSendSilent(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const Api::SendOptions &options);
|
2020-10-06 11:01:19 +00:00
|
|
|
[[nodiscard]] MsgId LookupReplyToTop(
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId replyToId);
|
|
|
|
[[nodiscard]] MTPMessageReplyHeader NewMessageReplyHeader(
|
|
|
|
const Api::SendAction &action);
|
|
|
|
[[nodiscard]] QString GetErrorTextForSending(
|
2017-12-06 10:13:38 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-07-18 16:09:50 +00:00
|
|
|
const HistoryItemsList &items,
|
|
|
|
bool ignoreSlowmodeCountdown = false);
|
2020-10-06 11:01:19 +00:00
|
|
|
[[nodiscard]] QString GetErrorTextForSending(
|
2019-07-18 16:09:50 +00:00
|
|
|
not_null<PeerData*> peer,
|
|
|
|
const HistoryItemsList &items,
|
|
|
|
const TextWithTags &comment,
|
|
|
|
bool ignoreSlowmodeCountdown = false);
|
2022-08-04 17:39:40 +00:00
|
|
|
[[nodiscard]] TextWithEntities DropCustomEmoji(TextWithEntities text);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2020-09-18 11:52:44 +00:00
|
|
|
class HistoryMessage final : public HistoryItem {
|
2016-09-27 14:20:49 +00:00
|
|
|
public:
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2021-09-30 11:30:39 +00:00
|
|
|
MsgId id,
|
2019-08-09 19:19:23 +00:00
|
|
|
const MTPDmessage &data,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags localFlags);
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2021-09-30 11:30:39 +00:00
|
|
|
MsgId id,
|
2019-08-09 19:19:23 +00:00
|
|
|
const MTPDmessageService &data,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags localFlags);
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2017-12-13 18:10:48 +00:00
|
|
|
const QString &postAuthor,
|
2021-11-07 08:06:00 +00:00
|
|
|
not_null<HistoryItem*> original); // local forwarded
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2017-12-13 18:10:48 +00:00
|
|
|
const QString &postAuthor,
|
2021-07-28 11:55:02 +00:00
|
|
|
const TextWithEntities &textWithEntities,
|
|
|
|
const MTPMessageMedia &media,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup,
|
2021-07-28 11:55:02 +00:00
|
|
|
uint64 groupedId); // local message
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2017-12-13 18:10:48 +00:00
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<DocumentData*> document,
|
2018-01-18 13:59:22 +00:00
|
|
|
const TextWithEntities &caption,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup); // local document
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2017-12-13 18:10:48 +00:00
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<PhotoData*> photo,
|
2018-01-18 13:59:22 +00:00
|
|
|
const TextWithEntities &caption,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup); // local photo
|
2017-12-13 18:10:48 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
2018-02-03 19:52:35 +00:00
|
|
|
MsgId id,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2017-12-13 18:10:48 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId date,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId from,
|
2017-12-13 18:10:48 +00:00
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<GameData*> game,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup); // local game
|
2021-12-31 12:47:23 +00:00
|
|
|
HistoryMessage(
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
Data::SponsoredFrom from,
|
|
|
|
const TextWithEntities &textWithEntities); // sponsored
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2018-01-18 20:02:50 +00:00
|
|
|
void refreshMedia(const MTPMessageMedia *media);
|
|
|
|
void refreshSentMedia(const MTPMessageMedia *media);
|
2019-03-29 14:17:46 +00:00
|
|
|
void returnSavedMedia() override;
|
2018-01-18 20:02:50 +00:00
|
|
|
void setMedia(const MTPMessageMedia &media);
|
2021-03-31 18:19:00 +00:00
|
|
|
void checkBuyButton() override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] static std::unique_ptr<Data::Media> CreateMedia(
|
2018-01-18 20:02:50 +00:00
|
|
|
not_null<HistoryMessage*> item,
|
|
|
|
const MTPMessageMedia &media);
|
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] bool allowsForward() const override;
|
2019-08-09 17:58:58 +00:00
|
|
|
[[nodiscard]] bool allowsSendNow() const override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] bool allowsEdit(TimeId now) const override;
|
|
|
|
|
2019-09-12 10:35:04 +00:00
|
|
|
bool changeViewsCount(int count) override;
|
2020-09-01 06:44:18 +00:00
|
|
|
void setForwardsCount(int count) override;
|
2021-10-07 18:52:27 +00:00
|
|
|
void setReplies(HistoryMessageRepliesData &&data) override;
|
2020-10-01 08:34:59 +00:00
|
|
|
void clearReplies() override;
|
2022-10-07 11:46:27 +00:00
|
|
|
void changeRepliesCount(int delta, PeerId replier) override;
|
2022-10-04 15:34:45 +00:00
|
|
|
void setReplyFields(
|
|
|
|
MsgId replyTo,
|
|
|
|
MsgId replyToTop,
|
|
|
|
bool isForumPost) override;
|
2020-10-06 07:23:58 +00:00
|
|
|
void setPostAuthor(const QString &author) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
void setRealId(MsgId newId) override;
|
2020-09-01 06:44:18 +00:00
|
|
|
void incrementReplyToTopCounter() override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
void dependencyItemRemoved(HistoryItem *dependency) override;
|
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] QString notificationHeader() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
2021-07-28 11:55:02 +00:00
|
|
|
// Looks on:
|
|
|
|
// f_edit_hide
|
|
|
|
// f_edit_date
|
|
|
|
// f_entities
|
|
|
|
// f_reply_markup
|
|
|
|
// f_media
|
|
|
|
// f_views
|
|
|
|
// f_forwards
|
|
|
|
// f_replies
|
|
|
|
// f_ttl_period
|
2021-10-07 22:40:10 +00:00
|
|
|
void applyEdition(HistoryMessageEdition &&edition) override;
|
2021-07-28 11:55:02 +00:00
|
|
|
|
2018-01-18 20:02:50 +00:00
|
|
|
void applyEdition(const MTPDmessageService &message) override;
|
2022-09-12 12:10:30 +00:00
|
|
|
void applyEdition(const MTPMessageExtendedMedia &media) override;
|
2019-08-07 14:38:26 +00:00
|
|
|
void updateSentContent(
|
|
|
|
const TextWithEntities &textWithEntities,
|
|
|
|
const MTPMessageMedia *media) override;
|
2021-10-02 11:28:21 +00:00
|
|
|
void updateReplyMarkup(HistoryMessageMarkupData &&markup) override;
|
2019-03-15 15:15:56 +00:00
|
|
|
void updateForwardedInfo(const MTPMessageFwdHeader *fwd) override;
|
2019-08-20 09:42:13 +00:00
|
|
|
void contributeToSlowmode(TimeId realDate = 0) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
2022-01-26 16:01:40 +00:00
|
|
|
void addToUnreadThings(HistoryUnreadThings::AddType type) override;
|
2020-09-01 06:44:18 +00:00
|
|
|
void destroyHistoryEntry() override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
2022-09-27 16:52:35 +00:00
|
|
|
[[nodiscard]] MsgId replyToId() const override;
|
|
|
|
[[nodiscard]] MsgId replyToTop() const override;
|
|
|
|
[[nodiscard]] MsgId topicRootId() const override;
|
|
|
|
|
2018-01-18 20:02:50 +00:00
|
|
|
void setText(const TextWithEntities &textWithEntities) override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] TextWithEntities originalText() const override;
|
2021-12-02 10:42:33 +00:00
|
|
|
[[nodiscard]] auto originalTextWithLocalEntities() const
|
|
|
|
-> TextWithEntities override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] TextForMimeData clipboardText() const override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] int viewsCount() const override;
|
2020-09-01 06:44:18 +00:00
|
|
|
[[nodiscard]] int repliesCount() const override;
|
2020-09-03 07:19:02 +00:00
|
|
|
[[nodiscard]] bool repliesAreComments() const override;
|
2020-09-11 17:55:10 +00:00
|
|
|
[[nodiscard]] bool externalReply() const override;
|
2020-09-22 11:01:49 +00:00
|
|
|
|
2022-10-07 11:46:27 +00:00
|
|
|
void setCommentsInboxReadTill(MsgId readTillId) override;
|
|
|
|
void setCommentsMaxId(MsgId maxId) override;
|
|
|
|
void setCommentsPossibleMaxId(MsgId possibleMaxId) override;
|
|
|
|
[[nodiscard]] bool areCommentsUnread() const override;
|
2020-09-22 11:01:49 +00:00
|
|
|
|
2020-09-03 08:21:31 +00:00
|
|
|
[[nodiscard]] FullMsgId commentsItemId() const override;
|
|
|
|
void setCommentsItemId(FullMsgId id) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
bool updateDependencyItem() override;
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] MsgId dependencyMsgId() const override {
|
2018-01-18 20:02:50 +00:00
|
|
|
return replyToId();
|
|
|
|
}
|
|
|
|
|
2021-02-02 16:38:30 +00:00
|
|
|
void applySentMessage(const MTPDmessage &data) override;
|
|
|
|
void applySentMessage(
|
|
|
|
const QString &text,
|
|
|
|
const MTPDupdateShortSentMessage &data,
|
|
|
|
bool wasAlready) override;
|
|
|
|
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] std::unique_ptr<HistoryView::Element> createView(
|
2020-06-16 16:53:44 +00:00
|
|
|
not_null<HistoryView::ElementDelegate*> delegate,
|
|
|
|
HistoryView::Element *replacing = nullptr) override;
|
2018-01-18 20:02:50 +00:00
|
|
|
|
|
|
|
~HistoryMessage();
|
|
|
|
|
|
|
|
private:
|
2022-09-21 14:55:27 +00:00
|
|
|
void setTextValue(TextWithEntities text);
|
2019-05-24 12:13:16 +00:00
|
|
|
[[nodiscard]] bool isTooOldForEdit(TimeId now) const;
|
|
|
|
[[nodiscard]] bool isLegacyMessage() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::Legacy;
|
2018-12-26 06:18:53 +00:00
|
|
|
}
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2020-09-10 11:56:46 +00:00
|
|
|
[[nodiscard]] bool checkCommentsLinkedChat(ChannelId id) const;
|
|
|
|
|
2017-03-06 15:00:59 +00:00
|
|
|
// For an invoice button we replace the button text with a "Receipt" key.
|
|
|
|
// It should show the receipt for the payed invoice. Still let mobile apps do that.
|
|
|
|
void replaceBuyWithReceiptInMarkup();
|
|
|
|
|
2021-10-02 11:28:21 +00:00
|
|
|
void setReplyMarkup(HistoryMessageMarkupData &&markup);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
struct CreateConfig;
|
2021-07-28 11:55:02 +00:00
|
|
|
void createComponentsHelper(
|
|
|
|
MessageFlags flags,
|
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
|
|
|
const QString &postAuthor,
|
2021-10-02 11:28:21 +00:00
|
|
|
HistoryMessageMarkupData &&markup);
|
|
|
|
void createComponents(CreateConfig &&config);
|
2019-03-15 15:15:56 +00:00
|
|
|
void setupForwardedComponent(const CreateConfig &config);
|
2020-09-03 08:42:25 +00:00
|
|
|
void changeReplyToTopCounter(
|
|
|
|
not_null<HistoryMessageReply*> reply,
|
|
|
|
int delta);
|
2020-09-03 07:19:02 +00:00
|
|
|
void refreshRepliesText(
|
|
|
|
not_null<HistoryMessageViews*> views,
|
|
|
|
bool forceResize = false);
|
2021-12-31 12:47:23 +00:00
|
|
|
void setSponsoredFrom(const Data::SponsoredFrom &from);
|
2019-03-15 15:15:56 +00:00
|
|
|
|
|
|
|
static void FillForwardedInfo(
|
|
|
|
CreateConfig &config,
|
|
|
|
const MTPDmessageFwdHeader &data);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-12-27 10:41:30 +00:00
|
|
|
[[nodiscard]] bool generateLocalEntitiesByReply() const;
|
|
|
|
[[nodiscard]] TextWithEntities withLocalEntities(
|
|
|
|
const TextWithEntities &textWithEntities) const;
|
2019-07-19 15:05:48 +00:00
|
|
|
|
2021-10-07 22:40:10 +00:00
|
|
|
[[nodiscard]] bool checkRepliesPts(
|
|
|
|
const HistoryMessageRepliesData &data) const;
|
2020-11-17 15:05:35 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
friend class HistoryView::Element;
|
|
|
|
friend class HistoryView::Message;
|
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
};
|