Rename everything.

This commit is contained in:
23rd
2018-08-25 21:38:14 +03:00
parent 539d8c20d2
commit f4828b7d09
4 changed files with 8 additions and 8 deletions
+39
View File
@@ -0,0 +1,39 @@
#include "providers/LinkResolver.hpp"
#include "common/Common.hpp"
#include "common/NetworkRequest.hpp"
#include <QString>
namespace chatterino {
void LinkResolver::getLinkInfo(const QString url,
std::function<void(QString)> successCallback)
{
QString requestUrl("https://api.betterttv.net/2/link_resolver/" +
QUrl::toPercentEncoding(url, "", "/:"));
NetworkRequest request(requestUrl);
request.setCaller(QThread::currentThread());
request.setTimeout(30000);
request.onSuccess([successCallback](auto result) mutable -> Outcome {
auto root = result.parseJson();
/* When tooltip is not a string, in this case,
onError runs before onSuccess,
so there is no point in doing "if" condition. */
auto tooltip = root.value("tooltip").toString();
successCallback(QUrl::fromPercentEncoding(tooltip.toUtf8()));
return Success;
});
request.onError([successCallback](auto result) {
successCallback("No link info found");
return true;
});
request.execute();
}
} // namespace chatterino