From fe24d09009e039927860e94b0e3d3f10bf9d4474 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 5 Sep 2018 15:37:51 +0300 Subject: [PATCH] Replace url of link with new one from json. --- src/providers/LinkResolver.cpp | 3 ++- src/providers/twitch/TwitchMessageBuilder.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/providers/LinkResolver.cpp b/src/providers/LinkResolver.cpp index d6917157d..1c2ac41ec 100644 --- a/src/providers/LinkResolver.cpp +++ b/src/providers/LinkResolver.cpp @@ -22,10 +22,11 @@ void LinkResolver::getLinkInfo(const QString url, QString response = QString(); if (statusCode == 200) { response = root.value("tooltip").toString(); + url = root.value("link").toString(); } else { response = root.value("message").toString(); } - successCallback(QUrl::fromPercentEncoding(response.toUtf8())); + successCallback(QUrl::fromPercentEncoding(response.toUtf8()), url); return Success; }); diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 949b253c5..fdb97e5e8 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -280,10 +280,13 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_) ->setLink(link); LinkResolver::getLinkInfo( - linkString, [linkMELowercase, linkMEOriginal](QString tooltipText) { + linkString, [linkMELowercase, linkMEOriginal](QString tooltipText, + QString originalLink) { if (!tooltipText.isEmpty()) { - linkMELowercase->setTooltip(tooltipText); - linkMEOriginal->setTooltip(tooltipText); + linkMELowercase->setTooltip(tooltipText) + ->setLink(originalLink); + linkMEOriginal->setTooltip(tooltipText) + ->setLink(originalLink); } }); }