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)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (mastobotmon
|
project (mastobotmon
|
||||||
VERSION 0.3.2
|
VERSION 0.3.3
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
|
@ -132,14 +132,14 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::string answer;
|
std::string answer;
|
||||||
uint16_t ret = acc.get(Mastodon::API::v1::accounts_verify_credentials, answer);
|
uint16_t ret = acc.get(Mastodon::API::v1::accounts_verify_credentials, answer);
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
if (std::stoi(acc.get_header("X-RateLimit-Remaining")) < 2)
|
if (std::stoi(acc.get_header("X-RateLimit-Remaining")) < 2)
|
||||||
{
|
{
|
||||||
cerr << "ERROR: Reached limit of API calls.\n";
|
cerr << "ERROR: Reached limit of API calls.\n";
|
||||||
cerr << "Counter will reset at " << acc.get_header("X-RateLimit-Reset") << '\n';
|
cerr << "Counter will reset at " << acc.get_header("X-RateLimit-Reset") << '\n';
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (ret == 0)
|
|
||||||
{
|
|
||||||
Json::Value json;
|
Json::Value json;
|
||||||
Json::Reader reader;
|
Json::Reader reader;
|
||||||
reader.parse(answer, json);
|
reader.parse(answer, json);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user