bugfix: only check for ratelimit-header if GET request was successful
This commit is contained in:
parent
676b4d356d
commit
717d49175a
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project (mastobotmon
|
||||
VERSION 0.3.2
|
||||
VERSION 0.3.3
|
||||
LANGUAGES CXX)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue