diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 85ae5e5..07f0f5d 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -105,6 +105,7 @@ ListItem { } else if (webPagePreviewLoader.item) { webPagePreviewLoader.item.clicked() } + tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); } } @@ -224,6 +225,11 @@ ListItem { messageInReplyToLoader.inReplyToMessageDeleted = true; } } + onAvailableReactionsReceived: { + if (messageListItem.messageId === messageId) { + Debug.log("Available reactions for this message: " + reactions); + } + } } Component.onCompleted: { diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index 429369b..98a6c22 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -162,6 +162,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateUserPrivacySettingRules", &TDLibReceiver::processUpdateUserPrivacySettingRules); handlers.insert("updateMessageInteractionInfo", &TDLibReceiver::processUpdateMessageInteractionInfo); handlers.insert("sessions", &TDLibReceiver::processSessions); + handlers.insert("availableReactions", &TDLibReceiver::processAvailableReactions); } void TDLibReceiver::setActive(bool active) @@ -688,6 +689,15 @@ void TDLibReceiver::processSessions(const QVariantMap &receivedInformation) emit sessionsReceived(sessions); } +void TDLibReceiver::processAvailableReactions(const QVariantMap &receivedInformation) +{ + const qlonglong messageId = receivedInformation.value(_EXTRA).toLongLong(); + const QStringList reactions = receivedInformation.value("reactions").toStringList(); + if (!reactions.isEmpty()) { + emit availableReactionsReceived(messageId, reactions); + } +} + // Recursively removes (some) unused entries from QVariantMaps to reduce // memory usage. QStrings allocated by QVariantMaps are the top consumers // of memory. The biggest saving is achieved by removing "outline" from diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index 49467e7..0fade9e 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -102,6 +102,7 @@ signals: void messageInteractionInfoUpdated(qlonglong chatId, qlonglong messageId, const QVariantMap &updatedInfo); void okReceived(const QString &request); void sessionsReceived(const QVariantList &sessions); + void availableReactionsReceived(qlonglong messageId, const QStringList &reactions); private: typedef void (TDLibReceiver::*Handler)(const QVariantMap &); @@ -180,6 +181,7 @@ private: void processUpdateUserPrivacySettingRules(const QVariantMap &receivedInformation); void processUpdateMessageInteractionInfo(const QVariantMap &receivedInformation); void processSessions(const QVariantMap &receivedInformation); + void processAvailableReactions(const QVariantMap &receivedInformation); }; #endif // TDLIBRECEIVER_H diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index edfbc4d..07e4bf6 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Sebastian J. Wolf and other contributors + Copyright (C) 2020-22 Sebastian J. Wolf and other contributors This file is part of Fernschreiber. @@ -165,6 +165,7 @@ void TDLibWrapper::initializeTDLibReceiver() { connect(this->tdLibReceiver, SIGNAL(messageInteractionInfoUpdated(qlonglong, qlonglong, QVariantMap)), this, SIGNAL(messageInteractionInfoUpdated(qlonglong, qlonglong, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(okReceived(QString)), this, SIGNAL(okReceived(QString))); connect(this->tdLibReceiver, SIGNAL(sessionsReceived(QVariantList)), this, SIGNAL(sessionsReceived(QVariantList))); + connect(this->tdLibReceiver, SIGNAL(availableReactionsReceived(qlonglong, QStringList)), this, SIGNAL(availableReactionsReceived(qlonglong, QStringList))); this->tdLibReceiver->start(); } @@ -1394,6 +1395,17 @@ void TDLibWrapper::terminateSession(const QString &sessionId) this->sendRequest(requestObject); } +void TDLibWrapper::getMessageAvailableReactions(qlonglong chatId, qlonglong messageId) +{ + LOG("Get available reactions for message" << chatId << messageId); + QVariantMap requestObject; + requestObject.insert(_TYPE, "getMessageAvailableReactions"); + requestObject.insert(_EXTRA, QString::number(messageId)); + requestObject.insert("chat_id", chatId); + requestObject.insert("message_id", messageId); + this->sendRequest(requestObject); +} + void TDLibWrapper::searchEmoji(const QString &queryString) { LOG("Searching emoji" << queryString); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 1174a22..6873fef 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Sebastian J. Wolf and other contributors + Copyright (C) 2020-22 Sebastian J. Wolf and other contributors This file is part of Fernschreiber. @@ -230,6 +230,7 @@ public: Q_INVOKABLE void changeStickerSet(const QString &stickerSetId, bool isInstalled); Q_INVOKABLE void getActiveSessions(); Q_INVOKABLE void terminateSession(const QString &sessionId); + Q_INVOKABLE void getMessageAvailableReactions(qlonglong chatId, qlonglong messageId); // Others (candidates for extraction ;)) Q_INVOKABLE void searchEmoji(const QString &queryString); @@ -312,6 +313,7 @@ signals: void okReceived(const QString &request); void sessionsReceived(const QVariantList &sessions); void openFileExternally(const QString &filePath); + void availableReactionsReceived(qlonglong messageId, const QStringList &reactions); public slots: void handleVersionDetected(const QString &version);