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-04-06 14:38:10 +00:00
|
|
|
#include "base/runtime_composer.h"
|
2017-08-31 16:28:58 +00:00
|
|
|
#include "base/flags.h"
|
2019-03-29 14:17:46 +00:00
|
|
|
#include "data/data_media_types.h"
|
2021-10-07 22:40:10 +00:00
|
|
|
#include "history/history_item_edition.h"
|
2021-10-02 11:28:21 +00:00
|
|
|
#include "history/history_item_reply_markup.h"
|
2016-09-29 11:37:16 +00:00
|
|
|
|
2021-10-01 14:58:41 +00:00
|
|
|
#include <any>
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
class HiddenSenderInfo;
|
|
|
|
class History;
|
|
|
|
struct HistoryMessageReply;
|
|
|
|
struct HistoryMessageViews;
|
|
|
|
struct HistoryMessageMarkupData;
|
2017-12-18 15:44:50 +00:00
|
|
|
struct HistoryMessageReplyMarkup;
|
2023-01-26 15:36:43 +00:00
|
|
|
struct HistoryMessageTranslation;
|
2022-12-14 12:15:46 +00:00
|
|
|
struct HistoryServiceDependentData;
|
|
|
|
enum class HistorySelfDestructType;
|
|
|
|
struct PreparedServiceText;
|
2017-12-18 15:44:50 +00:00
|
|
|
class ReplyKeyboard;
|
2023-01-26 15:36:43 +00:00
|
|
|
struct LanguageId;
|
2017-12-18 15:44:50 +00:00
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
namespace base {
|
|
|
|
template <typename Enum>
|
|
|
|
class enum_mask;
|
|
|
|
} // namespace base
|
|
|
|
|
|
|
|
namespace Storage {
|
2018-03-09 20:48:47 +00:00
|
|
|
enum class SharedMediaType : signed char;
|
2017-09-04 11:40:02 +00:00
|
|
|
using SharedMediaTypesMask = base::enum_mask<SharedMediaType>;
|
|
|
|
} // namespace Storage
|
|
|
|
|
2016-11-16 16:04:25 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RippleAnimation;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2016-11-16 10:44:06 +00:00
|
|
|
namespace style {
|
|
|
|
struct BotKeyboardButton;
|
2016-11-16 16:04:25 +00:00
|
|
|
struct RippleAnimation;
|
2016-11-16 10:44:06 +00:00
|
|
|
} // namespace style
|
|
|
|
|
2018-01-09 17:08:31 +00:00
|
|
|
namespace Data {
|
|
|
|
struct MessagePosition;
|
2022-01-27 12:55:34 +00:00
|
|
|
struct RecentReaction;
|
2022-08-16 11:28:17 +00:00
|
|
|
struct ReactionId;
|
2018-01-14 16:02:25 +00:00
|
|
|
class Media;
|
2022-08-25 20:56:38 +00:00
|
|
|
struct MessageReaction;
|
2019-09-11 09:26:13 +00:00
|
|
|
class MessageReactions;
|
2022-10-07 13:56:07 +00:00
|
|
|
class ForumTopic;
|
2022-10-13 10:32:03 +00:00
|
|
|
class Thread;
|
2022-12-14 12:15:46 +00:00
|
|
|
struct SponsoredFrom;
|
2018-01-09 17:08:31 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2022-08-15 09:20:17 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2018-01-11 19:33:26 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2022-01-26 16:01:40 +00:00
|
|
|
namespace HistoryUnreadThings {
|
|
|
|
enum class AddType;
|
|
|
|
} // namespace HistoryUnreadThings
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
namespace HistoryView {
|
2018-01-27 13:59:24 +00:00
|
|
|
struct TextState;
|
|
|
|
struct StateRequest;
|
|
|
|
enum class CursorState : char;
|
|
|
|
enum class PointState : char;
|
2018-01-11 19:33:26 +00:00
|
|
|
enum class Context : char;
|
2018-01-17 16:21:01 +00:00
|
|
|
class ElementDelegate;
|
2022-12-14 12:15:46 +00:00
|
|
|
class Element;
|
|
|
|
class Message;
|
|
|
|
class Service;
|
|
|
|
class ServiceMessagePainter;
|
2018-01-11 19:33:26 +00:00
|
|
|
} // namespace HistoryView
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
class HistoryItem final : public RuntimeComposer<HistoryItem> {
|
2016-09-27 14:20:49 +00:00
|
|
|
public:
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] static std::unique_ptr<Data::Media> CreateMedia(
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
const MTPMessageMedia &media);
|
|
|
|
|
|
|
|
HistoryItem(
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
const MTPDmessage &data,
|
|
|
|
MessageFlags localFlags);
|
|
|
|
HistoryItem(
|
2018-01-14 16:02:25 +00:00
|
|
|
not_null<History*> history,
|
2021-09-30 11:30:39 +00:00
|
|
|
MsgId id,
|
2022-12-14 12:15:46 +00:00
|
|
|
const MTPDmessageService &data,
|
|
|
|
MessageFlags localFlags);
|
|
|
|
HistoryItem(
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
const MTPDmessageEmpty &data,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags localFlags);
|
2018-01-14 16:02:25 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
HistoryItem( // Sponsored message.
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
Data::SponsoredFrom from,
|
|
|
|
const TextWithEntities &textWithEntities,
|
|
|
|
HistoryItem *injectedAfter);
|
|
|
|
|
|
|
|
HistoryItem( // Local message.
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
MessageFlags flags,
|
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
|
|
|
TimeId date,
|
|
|
|
PeerId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
const TextWithEntities &textWithEntities,
|
|
|
|
const MTPMessageMedia &media,
|
|
|
|
HistoryMessageMarkupData &&markup,
|
|
|
|
uint64 groupedId);
|
|
|
|
HistoryItem( // Local service message.
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
MessageFlags flags,
|
|
|
|
TimeId date,
|
|
|
|
PreparedServiceText &&message,
|
|
|
|
PeerId from = 0,
|
|
|
|
PhotoData *photo = nullptr);
|
|
|
|
HistoryItem( // Local forwarded.
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
MessageFlags flags,
|
|
|
|
TimeId date,
|
|
|
|
PeerId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<HistoryItem*> original,
|
|
|
|
MsgId topicRootId);
|
|
|
|
HistoryItem( // Local photo.
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
MessageFlags flags,
|
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
|
|
|
TimeId date,
|
|
|
|
PeerId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
const TextWithEntities &caption,
|
|
|
|
HistoryMessageMarkupData &&markup);
|
|
|
|
HistoryItem( // Local document.
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
MessageFlags flags,
|
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
|
|
|
TimeId date,
|
|
|
|
PeerId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
const TextWithEntities &caption,
|
|
|
|
HistoryMessageMarkupData &&markup);
|
|
|
|
HistoryItem( // Local game.
|
|
|
|
not_null<History*> history,
|
|
|
|
MsgId id,
|
|
|
|
MessageFlags flags,
|
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
|
|
|
TimeId date,
|
|
|
|
PeerId from,
|
|
|
|
const QString &postAuthor,
|
|
|
|
not_null<GameData*> game,
|
|
|
|
HistoryMessageMarkupData &&markup);
|
|
|
|
~HistoryItem();
|
|
|
|
|
2018-02-05 20:19:51 +00:00
|
|
|
struct Destroyer {
|
|
|
|
void operator()(HistoryItem *value);
|
|
|
|
};
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
void dependencyItemRemoved(not_null<HistoryItem*> dependency);
|
|
|
|
void updateDependencyItem();
|
|
|
|
[[nodiscard]] MsgId dependencyMsgId() const;
|
|
|
|
[[nodiscard]] bool notificationReady() const;
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] PeerData *specialNotificationPeer() const;
|
2022-12-14 12:15:46 +00:00
|
|
|
void checkBuyButton();
|
|
|
|
|
|
|
|
void updateServiceText(PreparedServiceText &&text);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] UserData *viaBot() const;
|
|
|
|
[[nodiscard]] UserData *getMessageBot() const;
|
|
|
|
[[nodiscard]] bool isHistoryEntry() const;
|
2019-09-06 09:20:12 +00:00
|
|
|
[[nodiscard]] bool isAdminLogEntry() const;
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] bool isFromScheduled() const;
|
|
|
|
[[nodiscard]] bool isScheduled() const;
|
2021-09-26 18:24:47 +00:00
|
|
|
[[nodiscard]] bool isSponsored() const;
|
2021-09-23 13:37:29 +00:00
|
|
|
[[nodiscard]] bool skipNotification() const;
|
2022-12-09 17:35:45 +00:00
|
|
|
[[nodiscard]] bool isUserpicSuggestion() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2017-12-18 15:44:50 +00:00
|
|
|
void addLogEntryOriginal(
|
|
|
|
WebPageId localId,
|
|
|
|
const QString &label,
|
|
|
|
const TextWithEntities &content);
|
2017-06-18 13:08:49 +00:00
|
|
|
|
2022-10-13 17:34:04 +00:00
|
|
|
[[nodiscard]] not_null<Data::Thread*> notificationThread() const;
|
2022-10-07 13:56:07 +00:00
|
|
|
[[nodiscard]] not_null<History*> history() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _history;
|
|
|
|
}
|
2022-10-07 13:56:07 +00:00
|
|
|
[[nodiscard]] Data::ForumTopic *topic() const;
|
|
|
|
[[nodiscard]] not_null<PeerData*> from() const {
|
2016-09-27 14:20:49 +00:00
|
|
|
return _from;
|
|
|
|
}
|
2022-10-07 13:56:07 +00:00
|
|
|
[[nodiscard]] HistoryView::Element *mainView() const {
|
2018-01-10 13:13:33 +00:00
|
|
|
return _mainView;
|
|
|
|
}
|
2018-03-10 12:47:19 +00:00
|
|
|
void setMainView(not_null<HistoryView::Element*> view) {
|
2018-01-11 13:07:29 +00:00
|
|
|
_mainView = view;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2018-01-18 13:59:22 +00:00
|
|
|
void refreshMainView();
|
2018-01-11 13:07:29 +00:00
|
|
|
void clearMainView();
|
|
|
|
void removeMainView();
|
2017-05-12 14:05:06 +00:00
|
|
|
|
2022-10-06 15:11:26 +00:00
|
|
|
void invalidateChatListEntry();
|
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
void destroy();
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool out() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::Outgoing;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2020-10-09 12:56:33 +00:00
|
|
|
[[nodiscard]] bool isPinned() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::Pinned;
|
2020-10-09 12:56:33 +00:00
|
|
|
}
|
2022-10-17 16:29:48 +00:00
|
|
|
[[nodiscard]] bool unread(not_null<Data::Thread*> thread) const;
|
2019-08-28 14:24:12 +00:00
|
|
|
[[nodiscard]] bool showNotification() const;
|
2019-04-30 09:48:48 +00:00
|
|
|
void markClientSideAsRead();
|
2019-05-28 14:53:36 +00:00
|
|
|
[[nodiscard]] bool mentionsMe() const;
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool isUnreadMention() const;
|
2022-01-26 16:01:40 +00:00
|
|
|
[[nodiscard]] bool hasUnreadReaction() const;
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool isUnreadMedia() const;
|
2022-01-26 16:01:40 +00:00
|
|
|
[[nodiscard]] bool isIncomingUnreadMedia() const;
|
2019-04-30 09:48:48 +00:00
|
|
|
[[nodiscard]] bool hasUnreadMediaFlag() const;
|
2022-01-26 16:01:40 +00:00
|
|
|
void markReactionsRead();
|
|
|
|
void markMediaAndMentionRead();
|
2022-01-28 11:44:33 +00:00
|
|
|
bool markContentsRead(bool fromThisClient = false);
|
2020-10-09 12:56:33 +00:00
|
|
|
void setIsPinned(bool isPinned);
|
2017-07-17 20:09:55 +00:00
|
|
|
|
2019-03-29 14:17:46 +00:00
|
|
|
// For edit media in history_message.
|
2022-12-14 12:15:46 +00:00
|
|
|
void returnSavedMedia();
|
2021-12-28 22:06:01 +00:00
|
|
|
void savePreviousMedia();
|
|
|
|
[[nodiscard]] bool isEditingMedia() const;
|
|
|
|
void clearSavedMedia();
|
2019-03-29 14:17:46 +00:00
|
|
|
|
2017-07-17 20:09:55 +00:00
|
|
|
// Zero result means this message is not self-destructing right now.
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] crl::time getSelfDestructIn(crl::time now);
|
2017-07-17 20:09:55 +00:00
|
|
|
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool definesReplyKeyboard() const;
|
2021-07-28 07:33:52 +00:00
|
|
|
[[nodiscard]] ReplyMarkupFlags replyKeyboardFlags() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2023-01-26 15:36:43 +00:00
|
|
|
void cacheOnlyEmojiAndSpaces(bool only);
|
|
|
|
[[nodiscard]] bool isOnlyEmojiAndSpaces() const;
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool hasSwitchInlineButton() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::HasSwitchInlineButton;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool hasTextLinks() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::HasTextLinks;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isGroupEssential() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::IsGroupEssential;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isLocalUpdateMedia() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::IsLocalUpdateMedia;
|
2019-04-04 10:22:59 +00:00
|
|
|
}
|
|
|
|
void setIsLocalUpdateMedia(bool flag) {
|
|
|
|
if (flag) {
|
2021-07-28 11:55:02 +00:00
|
|
|
_flags |= MessageFlag::IsLocalUpdateMedia;
|
2019-04-04 10:22:59 +00:00
|
|
|
} else {
|
2021-07-28 11:55:02 +00:00
|
|
|
_flags &= ~MessageFlag::IsLocalUpdateMedia;
|
2019-04-04 10:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isGroupMigrate() const {
|
2019-01-22 07:50:21 +00:00
|
|
|
return isGroupEssential() && isEmpty();
|
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool hasViews() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::HasViews;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isPost() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::Post;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isSilent() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::Silent;
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool isSending() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::BeingSent;
|
2019-07-17 14:34:39 +00:00
|
|
|
}
|
2019-08-01 21:14:19 +00:00
|
|
|
[[nodiscard]] bool hasFailed() const {
|
2021-07-28 11:55:02 +00:00
|
|
|
return _flags & MessageFlag::SendingFailed;
|
2019-07-17 14:34:39 +00:00
|
|
|
}
|
2021-10-08 01:31:08 +00:00
|
|
|
[[nodiscard]] bool hideEditedBadge() const {
|
|
|
|
return (_flags & MessageFlag::HideEdited);
|
|
|
|
}
|
2021-11-07 08:06:00 +00:00
|
|
|
[[nodiscard]] bool isLocal() const {
|
|
|
|
return _flags & MessageFlag::Local;
|
|
|
|
}
|
2023-03-03 16:52:21 +00:00
|
|
|
[[nodiscard]] bool isFakeBotAbout() const {
|
|
|
|
return _flags & MessageFlag::FakeBotAbout;
|
|
|
|
}
|
2021-11-07 08:06:00 +00:00
|
|
|
[[nodiscard]] bool isRegular() const;
|
|
|
|
[[nodiscard]] bool isUploading() const;
|
2019-07-17 14:34:39 +00:00
|
|
|
void sendFailed();
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] int viewsCount() const;
|
|
|
|
[[nodiscard]] int repliesCount() const;
|
|
|
|
[[nodiscard]] bool repliesAreComments() const;
|
|
|
|
[[nodiscard]] bool externalReply() const;
|
2022-09-12 14:18:31 +00:00
|
|
|
[[nodiscard]] bool hasExtendedMediaPreview() const;
|
2020-09-22 11:01:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
void setCommentsInboxReadTill(MsgId readTillId);
|
|
|
|
void setCommentsMaxId(MsgId maxId);
|
|
|
|
void setCommentsPossibleMaxId(MsgId possibleMaxId);
|
|
|
|
[[nodiscard]] bool areCommentsUnread() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] FullMsgId commentsItemId() const;
|
|
|
|
void setCommentsItemId(FullMsgId id);
|
2020-09-22 11:01:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] bool needCheck() const;
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] bool isService() const;
|
|
|
|
void applyEdition(HistoryMessageEdition &&edition);
|
2016-11-18 16:27:47 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
void applyEdition(const MTPDmessageService &message);
|
|
|
|
void applyEdition(const MTPMessageExtendedMedia &media);
|
|
|
|
void updateForwardedInfo(const MTPMessageFwdHeader *fwd);
|
|
|
|
void updateSentContent(
|
|
|
|
const TextWithEntities &textWithEntities,
|
|
|
|
const MTPMessageMedia *media);
|
|
|
|
void applySentMessage(const MTPDmessage &data);
|
|
|
|
void applySentMessage(
|
2021-02-02 16:38:30 +00:00
|
|
|
const QString &text,
|
|
|
|
const MTPDupdateShortSentMessage &data,
|
|
|
|
bool wasAlready);
|
2022-12-14 12:15:46 +00:00
|
|
|
void updateReactions(const MTPMessageReactions *reactions);
|
|
|
|
|
|
|
|
void applyEditionToHistoryCleared();
|
|
|
|
void updateReplyMarkup(HistoryMessageMarkupData &&markup);
|
|
|
|
void contributeToSlowmode(TimeId realDate = 0);
|
|
|
|
|
|
|
|
void addToUnreadThings(HistoryUnreadThings::AddType type);
|
|
|
|
void destroyHistoryEntry();
|
|
|
|
[[nodiscard]] Storage::SharedMediaTypesMask sharedMediaTypes() const;
|
2021-02-02 16:38:30 +00:00
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
void indexAsNewItem();
|
2023-01-09 07:48:33 +00:00
|
|
|
void removeFromSharedMediaIndex();
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] QString notificationHeader() const;
|
|
|
|
[[nodiscard]] TextWithEntities notificationText() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2021-10-01 12:42:44 +00:00
|
|
|
using ToPreviewOptions = HistoryView::ToPreviewOptions;
|
|
|
|
using ItemPreview = HistoryView::ItemPreview;
|
2017-09-05 17:21:56 +00:00
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
// Returns text with link-start and link-end commands for service-color highlighting.
|
|
|
|
// Example: "[link1-start]You:[link1-end] [link1-start]Photo,[link1-end] caption text"
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] ItemPreview toPreview(ToPreviewOptions options) const;
|
|
|
|
[[nodiscard]] TextWithEntities inReplyText() const;
|
2023-01-26 15:36:43 +00:00
|
|
|
[[nodiscard]] const TextWithEntities &originalText() const;
|
|
|
|
[[nodiscard]] const TextWithEntities &translatedText() const;
|
|
|
|
[[nodiscard]] TextWithEntities translatedTextWithLocalEntities() const;
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] const std::vector<ClickHandlerPtr> &customTextLinks() const;
|
|
|
|
[[nodiscard]] TextForMimeData clipboardText() const;
|
|
|
|
|
|
|
|
bool changeViewsCount(int count);
|
|
|
|
void setForwardsCount(int count);
|
|
|
|
void setReplies(HistoryMessageRepliesData &&data);
|
|
|
|
void clearReplies();
|
|
|
|
void changeRepliesCount(int delta, PeerId replier);
|
|
|
|
void setReplyFields(
|
2022-10-04 15:34:45 +00:00
|
|
|
MsgId replyTo,
|
|
|
|
MsgId replyToTop,
|
2022-12-14 12:15:46 +00:00
|
|
|
bool isForumPost);
|
|
|
|
void setPostAuthor(const QString &author);
|
|
|
|
void setRealId(MsgId newId);
|
|
|
|
void incrementReplyToTopCounter();
|
2017-09-05 17:21:56 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool emptyText() const {
|
2022-09-21 14:55:27 +00:00
|
|
|
return _text.empty();
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool canPin() const;
|
2021-11-10 06:10:35 +00:00
|
|
|
[[nodiscard]] bool canBeEdited() const;
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool canStopPoll() const;
|
2021-11-25 14:33:53 +00:00
|
|
|
[[nodiscard]] bool forbidsForward() const;
|
2022-11-01 12:49:37 +00:00
|
|
|
[[nodiscard]] bool forbidsSaving() const;
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] bool allowsSendNow() const;
|
|
|
|
[[nodiscard]] bool allowsForward() const;
|
|
|
|
[[nodiscard]] bool allowsEdit(TimeId now) const;
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool canDelete() const;
|
|
|
|
[[nodiscard]] bool canDeleteForEveryone(TimeId now) const;
|
|
|
|
[[nodiscard]] bool suggestReport() const;
|
|
|
|
[[nodiscard]] bool suggestBanReport() const;
|
|
|
|
[[nodiscard]] bool suggestDeleteAllReport() const;
|
2023-01-10 18:56:20 +00:00
|
|
|
[[nodiscard]] ChatRestriction requiredSendRight() const;
|
|
|
|
[[nodiscard]] bool requiresSendInlineRight() const;
|
|
|
|
[[nodiscard]] std::optional<QString> errorTextForForward(
|
|
|
|
not_null<Data::Thread*> to) const;
|
2023-01-26 15:36:43 +00:00
|
|
|
[[nodiscard]] const HistoryMessageTranslation *translation() const;
|
|
|
|
[[nodiscard]] bool translationShowRequiresCheck(LanguageId to) const;
|
|
|
|
bool translationShowRequiresRequest(LanguageId to);
|
|
|
|
void translationDone(LanguageId to, TextWithEntities result);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-09-11 09:26:13 +00:00
|
|
|
[[nodiscard]] bool canReact() const;
|
2022-08-25 20:56:38 +00:00
|
|
|
enum class ReactionSource {
|
|
|
|
Selector,
|
|
|
|
Quick,
|
|
|
|
Existing,
|
|
|
|
};
|
|
|
|
void toggleReaction(
|
|
|
|
const Data::ReactionId &reaction,
|
|
|
|
ReactionSource source);
|
2021-12-28 22:06:01 +00:00
|
|
|
void updateReactionsUnknown();
|
2022-08-16 11:28:17 +00:00
|
|
|
[[nodiscard]] auto reactions() const
|
2022-08-25 20:56:38 +00:00
|
|
|
-> const std::vector<Data::MessageReaction> &;
|
2022-01-13 10:13:08 +00:00
|
|
|
[[nodiscard]] auto recentReactions() const
|
2022-08-16 11:28:17 +00:00
|
|
|
-> const base::flat_map<
|
|
|
|
Data::ReactionId,
|
|
|
|
std::vector<Data::RecentReaction>> &;
|
2021-12-21 15:29:40 +00:00
|
|
|
[[nodiscard]] bool canViewReactions() const;
|
2022-08-25 20:56:38 +00:00
|
|
|
[[nodiscard]] std::vector<Data::ReactionId> chosenReactions() const;
|
2022-08-16 11:28:17 +00:00
|
|
|
[[nodiscard]] Data::ReactionId lookupUnreadReaction(
|
2022-01-31 13:18:40 +00:00
|
|
|
not_null<UserData*> from) const;
|
2021-12-28 18:20:32 +00:00
|
|
|
[[nodiscard]] crl::time lastReactionsRefreshTime() const;
|
2019-09-11 09:26:13 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool hasDirectLink() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2021-12-09 07:32:54 +00:00
|
|
|
[[nodiscard]] FullMsgId fullId() const;
|
2022-02-24 15:04:24 +00:00
|
|
|
[[nodiscard]] GlobalMsgId globalId() const;
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] Data::MessagePosition position() const;
|
|
|
|
[[nodiscard]] TimeId date() const;
|
|
|
|
|
|
|
|
[[nodiscard]] static TimeId NewMessageDate(TimeId scheduled);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] Data::Media *media() const {
|
2017-03-05 13:39:10 +00:00
|
|
|
return _media.get();
|
2016-09-27 14:20:49 +00:00
|
|
|
}
|
2022-08-04 17:39:40 +00:00
|
|
|
[[nodiscard]] bool computeDropForwardedInfo() const;
|
2022-12-14 12:15:46 +00:00
|
|
|
void setText(const TextWithEntities &textWithEntities);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] MsgId replyToId() const;
|
|
|
|
[[nodiscard]] MsgId replyToTop() const;
|
|
|
|
[[nodiscard]] MsgId topicRootId() const;
|
2022-09-27 16:52:35 +00:00
|
|
|
[[nodiscard]] bool inThread(MsgId rootId) const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] not_null<PeerData*> author() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] TimeId dateOriginal() const;
|
|
|
|
[[nodiscard]] PeerData *senderOriginal() const;
|
2021-12-31 12:47:23 +00:00
|
|
|
[[nodiscard]] const HiddenSenderInfo *hiddenSenderInfo() const;
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] not_null<PeerData*> fromOriginal() const;
|
|
|
|
[[nodiscard]] QString authorOriginal() const;
|
|
|
|
[[nodiscard]] MsgId idOriginal() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] bool isEmpty() const;
|
2017-12-13 18:10:48 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] MessageGroupId groupId() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] const HistoryMessageReplyMarkup *inlineReplyMarkup() const {
|
2019-05-25 14:42:01 +00:00
|
|
|
return const_cast<HistoryItem*>(this)->inlineReplyMarkup();
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] const ReplyKeyboard *inlineReplyKeyboard() const {
|
2019-05-25 14:42:01 +00:00
|
|
|
return const_cast<HistoryItem*>(this)->inlineReplyKeyboard();
|
|
|
|
}
|
2019-08-12 16:33:36 +00:00
|
|
|
[[nodiscard]] HistoryMessageReplyMarkup *inlineReplyMarkup();
|
|
|
|
[[nodiscard]] ReplyKeyboard *inlineReplyKeyboard();
|
2019-05-25 14:42:01 +00:00
|
|
|
|
2019-05-25 15:05:57 +00:00
|
|
|
[[nodiscard]] ChannelData *discussionPostOriginalSender() const;
|
|
|
|
[[nodiscard]] bool isDiscussionPost() const;
|
2020-09-15 08:39:39 +00:00
|
|
|
[[nodiscard]] HistoryItem *lookupDiscussionPostOriginal() const;
|
2019-05-25 15:05:57 +00:00
|
|
|
[[nodiscard]] PeerData *displayFrom() const;
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
[[nodiscard]] std::unique_ptr<HistoryView::Element> createView(
|
2020-06-16 16:53:44 +00:00
|
|
|
not_null<HistoryView::ElementDelegate*> delegate,
|
2022-12-14 12:15:46 +00:00
|
|
|
HistoryView::Element *replacing = nullptr);
|
2018-01-11 19:33:26 +00:00
|
|
|
|
2020-05-09 20:34:57 +00:00
|
|
|
void updateDate(TimeId newDate);
|
|
|
|
[[nodiscard]] bool canUpdateDate() const;
|
2022-07-04 08:49:31 +00:00
|
|
|
void customEmojiRepaint();
|
2020-05-09 20:34:57 +00:00
|
|
|
|
2021-02-12 15:15:17 +00:00
|
|
|
[[nodiscard]] TimeId ttlDestroyAt() const {
|
|
|
|
return _ttlDestroyAt;
|
|
|
|
}
|
|
|
|
|
2019-08-12 16:33:36 +00:00
|
|
|
MsgId id;
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
private:
|
|
|
|
struct CreateConfig;
|
|
|
|
|
|
|
|
struct SavedMediaData {
|
|
|
|
TextWithEntities text;
|
|
|
|
std::unique_ptr<Data::Media> media;
|
|
|
|
};
|
|
|
|
|
2017-08-25 15:17:46 +00:00
|
|
|
HistoryItem(
|
|
|
|
not_null<History*> history,
|
|
|
|
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);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
void createComponentsHelper(
|
|
|
|
MessageFlags flags,
|
|
|
|
MsgId replyTo,
|
|
|
|
UserId viaBotId,
|
|
|
|
const QString &postAuthor,
|
|
|
|
HistoryMessageMarkupData &&markup);
|
|
|
|
void createComponents(CreateConfig &&config);
|
|
|
|
void setupForwardedComponent(const CreateConfig &config);
|
|
|
|
|
|
|
|
[[nodiscard]] bool generateLocalEntitiesByReply() const;
|
|
|
|
[[nodiscard]] TextWithEntities withLocalEntities(
|
|
|
|
const TextWithEntities &textWithEntities) const;
|
|
|
|
void setTextValue(TextWithEntities text);
|
|
|
|
[[nodiscard]] bool isTooOldForEdit(TimeId now) const;
|
|
|
|
[[nodiscard]] bool isLegacyMessage() const {
|
|
|
|
return _flags & MessageFlag::Legacy;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool checkCommentsLinkedChat(ChannelId id) const;
|
|
|
|
|
|
|
|
void setReplyMarkup(HistoryMessageMarkupData &&markup);
|
|
|
|
|
|
|
|
void changeReplyToTopCounter(
|
|
|
|
not_null<HistoryMessageReply*> reply,
|
|
|
|
int delta);
|
|
|
|
void refreshRepliesText(
|
|
|
|
not_null<HistoryMessageViews*> views,
|
|
|
|
bool forceResize = false);
|
|
|
|
|
|
|
|
[[nodiscard]] bool checkRepliesPts(
|
|
|
|
const HistoryMessageRepliesData &data) const;
|
|
|
|
|
|
|
|
[[nodiscard]] HistoryServiceDependentData *GetServiceDependentData();
|
|
|
|
[[nodiscard]] auto GetServiceDependentData() const
|
|
|
|
-> const HistoryServiceDependentData *;
|
|
|
|
void updateDependentServiceText();
|
|
|
|
bool updateServiceDependent(bool force = false);
|
|
|
|
void setServiceText(PreparedServiceText &&prepared);
|
2017-07-17 20:09:55 +00:00
|
|
|
|
2016-09-27 14:20:49 +00:00
|
|
|
void finishEdition(int oldKeyboardTop);
|
|
|
|
void finishEditionToEmpty();
|
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
void clearDependencyMessage();
|
|
|
|
void setupChatThemeChange();
|
|
|
|
void setupTTLChange();
|
2022-01-14 13:41:29 +00:00
|
|
|
|
2023-01-26 15:36:43 +00:00
|
|
|
void translationToggle(
|
|
|
|
not_null<HistoryMessageTranslation*> translation,
|
|
|
|
bool used);
|
2022-12-14 12:15:46 +00:00
|
|
|
void setSelfDestruct(HistorySelfDestructType type, int ttlSeconds);
|
|
|
|
|
|
|
|
TextWithEntities fromLinkText() const;
|
|
|
|
ClickHandlerPtr fromLink() const;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
void setGroupId(MessageGroupId groupId);
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
static void FillForwardedInfo(
|
|
|
|
CreateConfig &config,
|
|
|
|
const MTPDmessageFwdHeader &data);
|
|
|
|
void createComponents(const MTPDmessage &data);
|
|
|
|
void setMedia(const MTPMessageMedia &media);
|
|
|
|
void applyServiceDateEdition(const MTPDmessageService &data);
|
|
|
|
void setReactions(const MTPMessageReactions *reactions);
|
|
|
|
[[nodiscard]] bool changeReactions(const MTPMessageReactions *reactions);
|
|
|
|
void setServiceMessageByAction(const MTPmessageAction &action);
|
|
|
|
void applyAction(const MTPMessageAction &action);
|
|
|
|
void refreshMedia(const MTPMessageMedia *media);
|
|
|
|
void refreshSentMedia(const MTPMessageMedia *media);
|
|
|
|
void createServiceFromMtp(const MTPDmessage &message);
|
|
|
|
void createServiceFromMtp(const MTPDmessageService &message);
|
2021-02-12 15:15:17 +00:00
|
|
|
void applyTTL(const MTPDmessage &data);
|
|
|
|
void applyTTL(const MTPDmessageService &data);
|
2022-12-14 12:15:46 +00:00
|
|
|
|
2021-02-12 15:15:17 +00:00
|
|
|
void applyTTL(TimeId destroyAt);
|
|
|
|
|
2022-12-14 12:15:46 +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();
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
void setSponsoredFrom(const Data::SponsoredFrom &from);
|
|
|
|
|
|
|
|
[[nodiscard]] PreparedServiceText preparePinnedText();
|
|
|
|
[[nodiscard]] PreparedServiceText prepareGameScoreText();
|
|
|
|
[[nodiscard]] PreparedServiceText preparePaymentSentText();
|
|
|
|
[[nodiscard]] PreparedServiceText prepareInvitedToCallText(
|
|
|
|
const std::vector<not_null<UserData*>> &users,
|
|
|
|
CallId linkCallId);
|
|
|
|
[[nodiscard]] PreparedServiceText prepareCallScheduledText(
|
|
|
|
TimeId scheduleDate);
|
|
|
|
|
|
|
|
const not_null<History*> _history;
|
|
|
|
const not_null<PeerData*> _from;
|
|
|
|
MessageFlags _flags = 0;
|
|
|
|
|
|
|
|
TextWithEntities _text;
|
2020-05-30 14:41:39 +00:00
|
|
|
|
2021-12-28 22:06:01 +00:00
|
|
|
std::unique_ptr<SavedMediaData> _savedLocalEditMediaData;
|
2018-01-14 16:02:25 +00:00
|
|
|
std::unique_ptr<Data::Media> _media;
|
2019-09-11 09:26:13 +00:00
|
|
|
std::unique_ptr<Data::MessageReactions> _reactions;
|
2021-12-28 22:06:01 +00:00
|
|
|
crl::time _reactionsLastRefreshed = 0;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId _date = 0;
|
2021-02-12 15:15:17 +00:00
|
|
|
TimeId _ttlDestroyAt = 0;
|
2018-02-03 19:52:35 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *_mainView = nullptr;
|
2019-05-31 21:51:57 +00:00
|
|
|
MessageGroupId _groupId = MessageGroupId();
|
2018-01-14 16:02:25 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
friend class HistoryView::Element;
|
|
|
|
friend class HistoryView::Message;
|
|
|
|
friend class HistoryView::Service;
|
|
|
|
friend class HistoryView::ServiceMessagePainter;
|
2016-09-27 14:20:49 +00:00
|
|
|
|
2022-12-14 12:15:46 +00:00
|
|
|
};
|