From 2fea47af1b20a9587b1bec81b989b6cde274f0c7 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Tue, 7 Dec 2021 20:22:00 +0200 Subject: [PATCH 1/2] Describe emoji with emoji And stickers too --- qml/js/functions.js | 4 +- src/fernschreiberutils.cpp | 67 ++++++++++++++------- translations/harbour-fernschreiber-de.ts | 16 ----- translations/harbour-fernschreiber-en.ts | 16 ----- translations/harbour-fernschreiber-es.ts | 16 ----- translations/harbour-fernschreiber-fi.ts | 16 ----- translations/harbour-fernschreiber-fr.ts | 16 ----- translations/harbour-fernschreiber-hu.ts | 16 ----- translations/harbour-fernschreiber-it.ts | 16 ----- translations/harbour-fernschreiber-pl.ts | 16 ----- translations/harbour-fernschreiber-ru.ts | 16 ----- translations/harbour-fernschreiber-sk.ts | 16 ----- translations/harbour-fernschreiber-sv.ts | 16 ----- translations/harbour-fernschreiber-zh_CN.ts | 16 ----- translations/harbour-fernschreiber.ts | 16 ----- 15 files changed, 48 insertions(+), 231 deletions(-) diff --git a/qml/js/functions.js b/qml/js/functions.js index 77556b8..166bd1e 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -47,9 +47,9 @@ function getMessageText(message, simple, currentUserId, ignoreEntities) { return enhanceMessageText(message.content.text, ignoreEntities); } case 'messageSticker': - return simple ? qsTr("Sticker: %1").arg(message.content.sticker.emoji) : ""; + return simple ? message.content.sticker.emoji : "" case 'messageAnimatedEmoji': - return simple ? qsTr("Animated Emoji: %1").arg(message.content.animated_emoji.sticker.emoji) : ""; + return simple ? message.content.animated_emoji.sticker.emoji : "" case 'messagePhoto': if (message.content.caption.text !== "") { return simple ? qsTr("Picture: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities) diff --git a/src/fernschreiberutils.cpp b/src/fernschreiberutils.cpp index 96ac648..c36aa3e 100644 --- a/src/fernschreiberutils.cpp +++ b/src/fernschreiberutils.cpp @@ -37,6 +37,30 @@ #define DEBUG_MODULE FernschreiberUtils #include "debuglog.h" +namespace { + const QString _TYPE("@type"); + const QString TEXT("text"); + const QString EMOJI("emoji"); + const QString ANIMATED_EMOJI("animated_emoji"); + const QString STICKER("sticker"); + const QString USER_ID("user_id"); + + const QString MESSAGE_SENDER_TYPE_USER("messageSenderUser"); + + const QString MESSAGE_CONTENT_TYPE_TEXT("messageText"); + const QString MESSAGE_CONTENT_TYPE_STICKER("messageSticker"); + const QString MESSAGE_CONTENT_TYPE_ANIMATED_EMOJI("messageAnimatedEmoji"); + const QString MESSAGE_CONTENT_TYPE_PHOTO("messagePhoto"); + const QString MESSAGE_CONTENT_TYPE_VIDEO("messageVideo"); + const QString MESSAGE_CONTENT_TYPE_VIDEO_NOTE("messageVideoNote"); + const QString MESSAGE_CONTENT_TYPE_ANIMATION("messageAnimation"); + const QString MESSAGE_CONTENT_TYPE_AUDIO("messageAudio"); + const QString MESSAGE_CONTENT_TYPE_VOICE_NOTE("messageVoiceNote"); + const QString MESSAGE_CONTENT_TYPE_DOCUMENT("messageDocument"); + const QString MESSAGE_CONTENT_TYPE_LOCATION("messageLocation"); + const QString MESSAGE_CONTENT_TYPE_VENUE("messageVenue"); +} + FernschreiberUtils::FernschreiberUtils(QObject *parent) : QObject(parent) { LOG("Initializing audio recorder..."); @@ -83,44 +107,45 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons return QString(); } - const bool myself = !isChannel && (messageSender.value("@type").toString() == "messageSenderUser" && messageSender.value("user_id").toLongLong() == currentUserId); + const QString contentType(messageContent.value(_TYPE).toString()); + const QString messageSenderType(messageSender.value(_TYPE).toString()); + const qlonglong messageSenderUserId = messageSender.value(USER_ID).toLongLong(); + const bool myself = !isChannel && (messageSenderType == MESSAGE_SENDER_TYPE_USER && messageSenderUserId == currentUserId); - QString contentType = messageContent.value("@type").toString(); - - if (contentType == "messageText") { - return messageContent.value("text").toMap().value("text").toString(); + if (contentType == MESSAGE_CONTENT_TYPE_TEXT) { + return messageContent.value(TEXT).toMap().value(TEXT).toString(); } - if (contentType == "messageSticker") { - return tr("Sticker: %1").arg(messageContent.value("sticker").toMap().value("emoji").toString()); + if (contentType == MESSAGE_CONTENT_TYPE_STICKER) { + return messageContent.value(STICKER).toMap().value(EMOJI).toString(); } - if (contentType == "messageAnimatedEmoji") { - return tr("Animated Emoji: %1").arg(messageContent.value("animated_emoji").toMap().value("sticker").toMap().value("emoji").toString()); + if (contentType == MESSAGE_CONTENT_TYPE_ANIMATED_EMOJI) { + return messageContent.value(ANIMATED_EMOJI).toMap().value(STICKER).toMap().value(EMOJI).toString(); } - if (contentType == "messagePhoto") { + if (contentType == MESSAGE_CONTENT_TYPE_PHOTO) { return myself ? tr("sent a picture", "myself") : tr("sent a picture"); } - if (contentType == "messageVideo") { + if (contentType == MESSAGE_CONTENT_TYPE_VIDEO) { return myself ? tr("sent a video", "myself") : tr("sent a video"); } - if (contentType == "messageVideoNote") { + if (contentType == MESSAGE_CONTENT_TYPE_VIDEO_NOTE) { return myself ? tr("sent a video note", "myself") : tr("sent a video note"); } - if (contentType == "messageAnimation") { + if (contentType == MESSAGE_CONTENT_TYPE_ANIMATION) { return myself ? tr("sent an animation", "myself") : tr("sent an animation"); } - if (contentType == "messageAudio") { + if (contentType == MESSAGE_CONTENT_TYPE_AUDIO) { return myself ? tr("sent an audio", "myself") : tr("sent an audio"); } - if (contentType == "messageVoiceNote") { + if (contentType == MESSAGE_CONTENT_TYPE_VOICE_NOTE) { return myself ? tr("sent a voice note", "myself") : tr("sent a voice note"); } - if (contentType == "messageDocument") { + if (contentType == MESSAGE_CONTENT_TYPE_DOCUMENT) { return myself ? tr("sent a document", "myself") : tr("sent a document"); } - if (contentType == "messageLocation") { + if (contentType == MESSAGE_CONTENT_TYPE_LOCATION) { return myself ? tr("sent a location", "myself") : tr("sent a location"); } - if (contentType == "messageVenue") { + if (contentType == MESSAGE_CONTENT_TYPE_VENUE) { return myself ? tr("sent a venue", "myself") : tr("sent a venue"); } if (contentType == "messageContactRegistered") { @@ -130,7 +155,7 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons return myself ? tr("joined this chat", "myself") : tr("joined this chat"); } if (contentType == "messageChatAddMembers") { - if (messageSender.value("@type").toString() == "messageSenderUser" && messageSender.value("user_id").toLongLong() == messageContent.value("member_user_ids").toList().at(0).toLongLong()) { + if (messageSenderType == MESSAGE_SENDER_TYPE_USER && messageSenderUserId == messageContent.value("member_user_ids").toList().at(0).toLongLong()) { return myself ? tr("were added to this chat", "myself") : tr("was added to this chat"); } else { QVariantList memberUserIds = messageContent.value("member_user_ids").toList(); @@ -145,7 +170,7 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons } } if (contentType == "messageChatDeleteMember") { - if (messageSender.value("@type").toString() == "messageSenderUser" && messageSender.value("user_id").toLongLong() == messageContent.value("user_id").toLongLong()) { + if (messageSenderType == MESSAGE_SENDER_TYPE_USER && messageSenderUserId == messageContent.value("user_id").toLongLong()) { return myself ? tr("left this chat", "myself") : tr("left this chat"); } else { return myself ? tr("have removed %1 from the chat", "myself").arg(getUserName(tdLibWrapper->getUserInformation(messageContent.value("user_id").toString()))) : tr("has removed %1 from the chat").arg(getUserName(tdLibWrapper->getUserInformation(messageContent.value("user_id").toString()))); @@ -176,7 +201,7 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons return myself ? tr("upgraded this group to a supergroup", "myself") : tr("upgraded this group to a supergroup"); } if (contentType == "messageCustomServiceAction") { - return messageContent.value("text").toString(); + return messageContent.value(TEXT).toString(); } if (contentType == "messagePinMessage") { return myself ? tr("changed the pinned message", "myself") : tr("changed the pinned message"); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 1b40f18..83c6ec1 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -730,10 +730,6 @@ left this chat hat diesen Chat verlassen - - Sticker: %1 - Sticker: %1 - sent a voice note myself @@ -934,10 +930,6 @@ sent a video note hat eine Videonachricht geschickt - - Animated Emoji: %1 - Animiertes Emoji: %1 - ImagePage @@ -1893,10 +1885,6 @@ Picture: %1 Bild: %1 - - Sticker: %1 - Sticker: %1 - Audio: %1 Audio: %1 @@ -2290,9 +2278,5 @@ sent a game hat ein Spiel gesendet - - Animated Emoji: %1 - Animiertes Emoji: %1 - diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 8124049..a59539a 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -732,10 +732,6 @@ messages left this chat left this chat - - Sticker: %1 - Sticker: %1 - sent a voice note myself @@ -936,10 +932,6 @@ messages sent a video note sent a video note - - Animated Emoji: %1 - Animated Emoji: %1 - ImagePage @@ -1895,10 +1887,6 @@ messages Picture: %1 Picture: %1 - - Sticker: %1 - Sticker: %1 - Audio: %1 Audio: %1 @@ -2292,9 +2280,5 @@ messages sent a game sent a game - - Animated Emoji: %1 - Animated Emoji: %1 - diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 4f10ac7..149dd05 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -730,10 +730,6 @@ left this chat dejó esta conversación - - Sticker: %1 - Pegatina: %1 - sent a voice note myself @@ -934,10 +930,6 @@ sent a video note envió una nota de video - - Animated Emoji: %1 - Emoji animado: %1 - ImagePage @@ -1893,10 +1885,6 @@ Picture: %1 Imagen: %1 - - Sticker: %1 - Pegatina: %1 - Audio: %1 Audio: %1 @@ -2290,9 +2278,5 @@ sent a game envió un juego - - Animated Emoji: %1 - Emoji animado: %1 - diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index c85025b..88d303e 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -646,10 +646,6 @@ FernschreiberUtils - - Sticker: %1 - Tarra: %1 - sent a picture myself @@ -935,10 +931,6 @@ sent a video note lähetti videoviestin - - Animated Emoji: %1 - - ImagePage @@ -1894,10 +1886,6 @@ Picture: %1 Kuva: %1 - - Sticker: %1 - Tarra: %1 - Audio: %1 Äänite: %1 @@ -2291,9 +2279,5 @@ sent a game lähetti pelin - - Animated Emoji: %1 - - diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index b955826..93e6422 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -730,10 +730,6 @@ left this chat a quitté cette conversation - - Sticker: %1 - Autocollant : %1 - sent a voice note myself @@ -934,10 +930,6 @@ sent a video note a envoyé une note vidéo - - Animated Emoji: %1 - - ImagePage @@ -1893,10 +1885,6 @@ Picture: %1 Image : %1 - - Sticker: %1 - Autocollant : %1 - Audio: %1 Audio : %1 @@ -2290,9 +2278,5 @@ sent a game a envoyé un jeu - - Animated Emoji: %1 - - diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 070c24e..0e245f1 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -718,10 +718,6 @@ left this chat kilépett a csevegésből - - Sticker: %1 - Matrica: %1 - sent a voice note myself @@ -920,10 +916,6 @@ sent a video note - - Animated Emoji: %1 - - ImagePage @@ -1866,10 +1858,6 @@ Picture: %1 Kép: %1 - - Sticker: %1 - Matrica: %1 - Audio: %1 Audió: %1 @@ -2262,9 +2250,5 @@ sent a game - - Animated Emoji: %1 - - diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index fc51c52..1a936fe 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -730,10 +730,6 @@ left this chat ha lasciato questa chat - - Sticker: %1 - Sticker: %1 - sent a voice note myself @@ -934,10 +930,6 @@ sent a video note ha inviato un videomessaggio - - Animated Emoji: %1 - - ImagePage @@ -1893,10 +1885,6 @@ Picture: %1 Foto: %1 - - Sticker: %1 - Sticker: %1 - Audio: %1 Audio: %1 @@ -2290,9 +2278,5 @@ sent a game ha inviato un gioco - - Animated Emoji: %1 - - diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 87c912e..5df100e 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -742,10 +742,6 @@ left this chat opuścił ten czat - - Sticker: %1 - Naklejka: %1 - sent a voice note myself @@ -948,10 +944,6 @@ sent a video note wysłał notatkę video - - Animated Emoji: %1 - Animowane Emoji: %1 - ImagePage @@ -1920,10 +1912,6 @@ Picture: %1 Obraz: %1 - - Sticker: %1 - Naklejka: %1 - Audio: %1 Dźwięk: %1 @@ -2318,9 +2306,5 @@ sent a game wysłał grę - - Animated Emoji: %1 - Animowane Emoji: %1 - diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index ac28f62..dc560ae 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -745,10 +745,6 @@ left this chat покунул(а) чат - - Sticker: %1 - Стикер: %1 - sent a voice note myself @@ -951,10 +947,6 @@ sent a video note отправил(а) видео заметку - - Animated Emoji: %1 - - ImagePage @@ -1923,10 +1915,6 @@ Picture: %1 Картинка: %1 - - Sticker: %1 - Стикер: %1 - Audio: %1 Аудио: %1 @@ -2321,9 +2309,5 @@ sent a game отправил(а) игру - - Animated Emoji: %1 - - diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index fcc0028..db41dc3 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -742,10 +742,6 @@ left this chat opustil tento čet - - Sticker: %1 - Nálepka: %1 - sent a voice note myself @@ -948,10 +944,6 @@ sent a video note poslal video-poznámku - - Animated Emoji: %1 - - ImagePage @@ -1920,10 +1912,6 @@ Picture: %1 Obrázok: %1 - - Sticker: %1 - Nálepka: %1 - Audio: %1 Zvuk: %1 @@ -2318,9 +2306,5 @@ sent a game poslal hru - - Animated Emoji: %1 - - diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 0954d93..2442809 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -730,10 +730,6 @@ left this chat lämnade denna chatt - - Sticker: %1 - Dekal: %1 - sent a voice note myself @@ -934,10 +930,6 @@ sent a video note skickade ett videomeddelande - - Animated Emoji: %1 - Animerad emoji: %1 - ImagePage @@ -1893,10 +1885,6 @@ Picture: %1 Bild: %1 - - Sticker: %1 - Dekal: %1 - Audio: %1 Ljud: %1 @@ -2290,9 +2278,5 @@ sent a game skickade ett spel - - Animated Emoji: %1 - Animerad emoji: %1 - diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index c0e12bf..f9e2c78 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -719,10 +719,6 @@ left this chat 离开此对话 - - Sticker: %1 - 表情贴图: %1 - sent a voice note myself @@ -921,10 +917,6 @@ sent a video note 发送视频消息 - - Animated Emoji: %1 - - ImagePage @@ -1867,10 +1859,6 @@ Picture: %1 图片: %1 - - Sticker: %1 - 表情贴图: %1 - Audio: %1 音频: %1 @@ -2263,9 +2251,5 @@ sent a game 发送游戏 - - Animated Emoji: %1 - - diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 4b5e325..77fb04c 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -730,10 +730,6 @@ left this chat left this chat - - Sticker: %1 - Sticker: %1 - sent a voice note myself @@ -934,10 +930,6 @@ sent a video note sent a video note - - Animated Emoji: %1 - - ImagePage @@ -1893,10 +1885,6 @@ Picture: %1 Picture: %1 - - Sticker: %1 - Sticker: %1 - Audio: %1 Audio: %1 @@ -2290,9 +2278,5 @@ sent a game - - Animated Emoji: %1 - - From 0f4e0eaf58c718bfb0e93e620e87738dd21c06ec Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Wed, 8 Dec 2021 00:33:35 +0100 Subject: [PATCH 2/2] Better support sponsored message types --- .../messageContent/SponsoredMessage.qml | 25 ++++++++++++++++--- src/tdlibreceiver.cpp | 8 ++++++ src/tdlibreceiver.h | 2 ++ src/tdlibwrapper.cpp | 11 ++++++++ src/tdlibwrapper.h | 2 ++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/qml/components/messageContent/SponsoredMessage.qml b/qml/components/messageContent/SponsoredMessage.qml index d0b7cc9..4350c15 100644 --- a/qml/components/messageContent/SponsoredMessage.qml +++ b/qml/components/messageContent/SponsoredMessage.qml @@ -28,6 +28,16 @@ Column { property var sponsoredMessageData; + Connections { + target: tdLibWrapper + onMessageLinkInfoReceived: { + if (sponsoredMessageData.link.url === url) { + messageOverlayLoader.overlayMessage = messageLinkInfo.message; + messageOverlayLoader.active = true; + } + } + } + Component.onCompleted: { if (sponsoredMessageData) { if (typeof sponsoredMessageData.link === "undefined") { @@ -35,10 +45,10 @@ Column { sponsoredMessageButton.advertisesChannel = true; } else if (sponsoredMessageData.link['@type'] === "internalLinkTypeMessage") { sponsoredMessageButton.text = qsTr("Go to Message"); - sponsoredMessageButton.enabled = false; + sponsoredMessageButton.advertisesMessage = true; } else { sponsoredMessageButton.text = qsTr("Start Bot"); - sponsoredMessageButton.enabled = false; + sponsoredMessageButton.advertisesBot = true; } } } @@ -46,12 +56,21 @@ Column { Button { id: sponsoredMessageButton property bool advertisesChannel: false; + property bool advertisesMessage: false; + property bool advertisesBot: false; anchors { horizontalCenter: parent.horizontalCenter } onClicked: { if (advertisesChannel) { - tdLibWrapper.createSupergroupChat(sponsoredMessageData.sponsor_chat_id, "openDirectly"); + tdLibWrapper.createSupergroupChat(tdLibWrapper.getChat(sponsoredMessageData.sponsor_chat_id).type.supergroup_id, "openDirectly"); + } + if (advertisesMessage) { + tdLibWrapper.getMessageLinkInfo(sponsoredMessageData.link.url); + } + if (advertisesBot) { + tdLibWrapper.createPrivateChat(tdLibWrapper.getUserInformationByName(sponsoredMessageData.link.bot_username).id, "openAndSendStartToBot:" + sponsoredMessageData.link.start_parameter); + //tdLibWrapper.sendBotStartMessage(tdLibWrapper.getUserInformationByName(sponsoredMessageData.link.bot_username).id, sponsoredMessageData.sponsor_chat_id, sponsoredMessageData.link.start_parameter, ""); } } } diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index 63b764b..f6d5c23 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -104,6 +104,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("sponsoredMessages", &TDLibReceiver::processSponsoredMessages); handlers.insert("updateNewMessage", &TDLibReceiver::processUpdateNewMessage); handlers.insert("message", &TDLibReceiver::processMessage); + handlers.insert("messageLinkInfo", &TDLibReceiver::processMessageLinkInfo); handlers.insert("updateMessageSendSucceeded", &TDLibReceiver::processMessageSendSucceeded); handlers.insert("updateActiveNotifications", &TDLibReceiver::processUpdateActiveNotifications); handlers.insert("updateNotificationGroup", &TDLibReceiver::processUpdateNotificationGroup); @@ -380,6 +381,13 @@ void TDLibReceiver::processMessage(const QVariantMap &receivedInformation) emit messageInformation(chatId, messageId, receivedInformation); } +void TDLibReceiver::processMessageLinkInfo(const QVariantMap &receivedInformation) +{ + const QString url = receivedInformation.value(EXTRA).toString(); + LOG("Received message link info " << url); + emit messageLinkInfoReceived(url, receivedInformation); +} + void TDLibReceiver::processMessageSendSucceeded(const QVariantMap &receivedInformation) { const qlonglong oldMessageId = receivedInformation.value(OLD_MESSAGE_ID).toLongLong(); diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index d0917ca..910ed3f 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -56,6 +56,7 @@ signals: void superGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation); void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount); void messagesReceived(const QVariantList &messages, int totalCount); + void messageLinkInfoReceived(const QString &url, const QVariantMap &messageLinkInfo); void sponsoredMessagesReceived(qlonglong chatId, const QVariantList &messages); void newMessageReceived(qlonglong chatId, const QVariantMap &message); void messageInformation(qlonglong chatId, qlonglong messageId, const QVariantMap &message); @@ -134,6 +135,7 @@ private: void processSponsoredMessages(const QVariantMap &receivedInformation); void processUpdateNewMessage(const QVariantMap &receivedInformation); void processMessage(const QVariantMap &receivedInformation); + void processMessageLinkInfo(const QVariantMap &receivedInformation); void processMessageSendSucceeded(const QVariantMap &receivedInformation); void processUpdateActiveNotifications(const QVariantMap &receivedInformation); void processUpdateNotificationGroup(const QVariantMap &receivedInformation); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index c1dbe59..02d8c56 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -119,6 +119,7 @@ void TDLibWrapper::initializeTDLibReciever() { connect(this->tdLibReceiver, SIGNAL(chatOnlineMemberCountUpdated(QString, int)), this, SIGNAL(chatOnlineMemberCountUpdated(QString, int))); connect(this->tdLibReceiver, SIGNAL(messagesReceived(QVariantList, int)), this, SIGNAL(messagesReceived(QVariantList, int))); connect(this->tdLibReceiver, SIGNAL(sponsoredMessagesReceived(qlonglong, QVariantList)), this, SLOT(handleSponsoredMess(qlonglong, QVariantList))); + connect(this->tdLibReceiver, SIGNAL(messageLinkInfoReceived(QString, QVariantMap)), this, SIGNAL(messageLinkInfoReceived(QString, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(newMessageReceived(qlonglong, QVariantMap)), this, SIGNAL(newMessageReceived(qlonglong, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(messageInformation(qlonglong, qlonglong, QVariantMap)), this, SLOT(handleMessageInformation(qlonglong, qlonglong, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(messageSendSucceeded(qlonglong, qlonglong, QVariantMap)), this, SIGNAL(messageSendSucceeded(qlonglong, qlonglong, QVariantMap))); @@ -646,6 +647,16 @@ void TDLibWrapper::getMessage(qlonglong chatId, qlonglong messageId) this->sendRequest(requestObject); } +void TDLibWrapper::getMessageLinkInfo(const QString &url) +{ + LOG("Retrieving message link info" << url); + QVariantMap requestObject; + requestObject.insert(_TYPE, "getMessageLinkInfo"); + requestObject.insert("url", url); + requestObject.insert(_EXTRA, url); + this->sendRequest(requestObject); +} + void TDLibWrapper::getCallbackQueryAnswer(const QString &chatId, const QString &messageId, const QVariantMap &payload) { LOG("Getting Callback Query Answer" << chatId << messageId); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 004403b..7ad16df 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -171,6 +171,7 @@ public: Q_INVOKABLE void sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, const QString &replyToMessageId = "0"); Q_INVOKABLE void forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, bool sendCopy, bool removeCaption); Q_INVOKABLE void getMessage(qlonglong chatId, qlonglong messageId); + Q_INVOKABLE void getMessageLinkInfo(const QString &url); Q_INVOKABLE void getCallbackQueryAnswer(const QString &chatId, const QString &messageId, const QVariantMap &payload); Q_INVOKABLE void getChatPinnedMessage(qlonglong chatId); Q_INVOKABLE void getChatSponsoredMessages(qlonglong chatId); @@ -263,6 +264,7 @@ signals: void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount); void messagesReceived(const QVariantList &messages, int totalCount); void sponsoredMessagesReceived(qlonglong chatId, const QVariantList &messages); + void messageLinkInfoReceived(const QString &url, const QVariantMap &messageLinkInfo); void newMessageReceived(qlonglong chatId, const QVariantMap &message); void copyToDownloadsSuccessful(const QString &fileName, const QString &filePath); void copyToDownloadsError(const QString &fileName, const QString &filePath);