Get available message reactions

This commit is contained in:
Sebastian Wolf 2022-04-30 23:51:47 +02:00
parent 4445be3302
commit 6d6b07b9a9
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
5 changed files with 34 additions and 2 deletions

View file

@ -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: {

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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);