bugfix: only check for ratelimit-header if GET request was successful

This commit is contained in:
tastytea 2018-03-22 16:36:39 +01:00
parent 676b4d356d
commit 717d49175a
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (mastobotmon
VERSION 0.3.2
VERSION 0.3.3
LANGUAGES CXX)
include(GNUInstallDirs)

View File

@ -132,14 +132,14 @@ int main(int argc, char *argv[])
{
std::string answer;
uint16_t ret = acc.get(Mastodon::API::v1::accounts_verify_credentials, answer);
if (std::stoi(acc.get_header("X-RateLimit-Remaining")) < 2)
{
cerr << "ERROR: Reached limit of API calls.\n";
cerr << "Counter will reset at " << acc.get_header("X-RateLimit-Reset") << '\n';
return 2;
}
if (ret == 0)
{
if (std::stoi(acc.get_header("X-RateLimit-Remaining")) < 2)
{
cerr << "ERROR: Reached limit of API calls.\n";
cerr << "Counter will reset at " << acc.get_header("X-RateLimit-Reset") << '\n';
return 2;
}
Json::Value json;
Json::Reader reader;
reader.parse(answer, json);