mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Rewritten check for incorrect link.
This commit is contained in:
parent
cb500070f2
commit
bf529d5503
1 changed files with 8 additions and 5 deletions
|
@ -18,11 +18,14 @@ void LinkResolver::getLinkInfo(const QString url,
|
||||||
request.setTimeout(30000);
|
request.setTimeout(30000);
|
||||||
request.onSuccess([successCallback](auto result) mutable -> Outcome {
|
request.onSuccess([successCallback](auto result) mutable -> Outcome {
|
||||||
auto root = result.parseJson();
|
auto root = result.parseJson();
|
||||||
/* When tooltip is not a string, in this case,
|
auto statusCode = root.value("status").toInt();
|
||||||
onError runs before onSuccess,
|
QString response = QString();
|
||||||
so there is no point in doing "if" condition. */
|
if (statusCode == 200) {
|
||||||
auto tooltip = root.value("tooltip").toString();
|
response = root.value("tooltip").toString();
|
||||||
successCallback(QUrl::fromPercentEncoding(tooltip.toUtf8()));
|
} else {
|
||||||
|
response = root.value("message").toString();
|
||||||
|
}
|
||||||
|
successCallback(QUrl::fromPercentEncoding(response.toUtf8()));
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue