From 717d49175a6a2e2ee9df107164da0e06479fbf9c Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 22 Mar 2018 16:36:39 +0100 Subject: [PATCH] bugfix: only check for ratelimit-header if GET request was successful --- CMakeLists.txt | 2 +- src/mastobotmon.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ff2479..b45420e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastobotmon - VERSION 0.3.2 + VERSION 0.3.3 LANGUAGES CXX) include(GNUInstallDirs) diff --git a/src/mastobotmon.cpp b/src/mastobotmon.cpp index fb3c5e3..49c7e9d 100644 --- a/src/mastobotmon.cpp +++ b/src/mastobotmon.cpp @@ -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);