From 2d1701cf86d966eb0743a4b0e5b00fc8f7e30bf5 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 6 Sep 2018 13:54:28 +0300 Subject: [PATCH] Fixed build. --- src/providers/LinkResolver.cpp | 14 ++++++++------ src/providers/LinkResolver.hpp | 4 +++- src/providers/twitch/TwitchMessageBuilder.cpp | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/providers/LinkResolver.cpp b/src/providers/LinkResolver.cpp index 1c2ac41ec..c781b5db8 100644 --- a/src/providers/LinkResolver.cpp +++ b/src/providers/LinkResolver.cpp @@ -2,13 +2,14 @@ #include "common/Common.hpp" #include "common/NetworkRequest.hpp" +#include "messages/Link.hpp" #include namespace chatterino { void LinkResolver::getLinkInfo(const QString url, - std::function successCallback) + std::function successCallback) { QString requestUrl("https://braize.pajlada.com/chatterino/link_resolver/" + QUrl::toPercentEncoding(url, "", "/:")); @@ -16,23 +17,24 @@ void LinkResolver::getLinkInfo(const QString url, NetworkRequest request(requestUrl); request.setCaller(QThread::currentThread()); request.setTimeout(30000); - request.onSuccess([successCallback](auto result) mutable -> Outcome { + request.onSuccess([successCallback, url](auto result) mutable -> Outcome { auto root = result.parseJson(); auto statusCode = root.value("status").toInt(); QString response = QString(); + QString linkString = url; if (statusCode == 200) { response = root.value("tooltip").toString(); - url = root.value("link").toString(); + linkString = root.value("link").toString(); } else { response = root.value("message").toString(); } - successCallback(QUrl::fromPercentEncoding(response.toUtf8()), url); + successCallback(QUrl::fromPercentEncoding(response.toUtf8()), Link(Link::Url, linkString)); return Success; }); - request.onError([successCallback](auto result) { - successCallback("No link info found"); + request.onError([successCallback, url](auto result) { + successCallback("No link info found", Link(Link::Url, url)); return true; }); diff --git a/src/providers/LinkResolver.hpp b/src/providers/LinkResolver.hpp index 919109aaf..919f0c3bf 100644 --- a/src/providers/LinkResolver.hpp +++ b/src/providers/LinkResolver.hpp @@ -3,13 +3,15 @@ #include #include +#include "messages/Link.hpp" + namespace chatterino { class LinkResolver { public: static void getLinkInfo(const QString url, - std::function callback); + std::function callback); private: }; diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index fdb97e5e8..ac2194f4c 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -281,7 +281,7 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_) LinkResolver::getLinkInfo( linkString, [linkMELowercase, linkMEOriginal](QString tooltipText, - QString originalLink) { + Link originalLink) { if (!tooltipText.isEmpty()) { linkMELowercase->setTooltip(tooltipText) ->setLink(originalLink);