Try fetching the status 2 times

This commit is contained in:
tastytea 2018-05-27 01:24:11 +02:00
parent ed537c850f
commit 1273f72e4b
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 38 additions and 24 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon
VERSION 0.7.0
VERSION 0.7.1
LANGUAGES CXX
)

View File

@ -298,6 +298,9 @@ const std::uint_fast64_t Listener::get_parent_id(const Easy::Notification &notif
string answer;
std::uint_fast16_t ret;
// Retry up to 2 times
for (std::uint_fast8_t retries = 1; retries <= 2; ++retries)
{
// Fetch full status
ret = _masto->get(API::v1::search, {{ "q", { notif.status().url() }}},
answer);
@ -321,9 +324,20 @@ const std::uint_fast64_t Listener::get_parent_id(const Easy::Notification &notif
else
{
_config["last_id"] = std::to_string(notif.id());
Easy::Status s(answer);
const Easy::Status s(answer);
// If parent is found, return ID; else retry
if (s.in_reply_to_id() != 0)
{
return s.in_reply_to_id();
}
else
{
std::this_thread::sleep_for(std::chrono::seconds(2));
}
}
}
return 0;
}