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.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()));
|
||||
auto statusCode = root.value("status").toInt();
|
||||
QString response = QString();
|
||||
if (statusCode == 200) {
|
||||
response = root.value("tooltip").toString();
|
||||
} else {
|
||||
response = root.value("message").toString();
|
||||
}
|
||||
successCallback(QUrl::fromPercentEncoding(response.toUtf8()));
|
||||
|
||||
return Success;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue