From 4d35ee1d66473091737a55e7ea3c4fc2e321ee02 Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 1 Jan 2020 12:43:42 +0100 Subject: [PATCH] Record each posted guid. --- src/mastoapi.cpp | 8 +++++++- src/mastoapi.hpp | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mastoapi.cpp b/src/mastoapi.cpp index fd11959..f7ae1ed 100644 --- a/src/mastoapi.cpp +++ b/src/mastoapi.cpp @@ -27,7 +27,7 @@ namespace mastorss using std::string; using std::string_view; -MastoAPI::MastoAPI(const ProfileData &data) +MastoAPI::MastoAPI(ProfileData &data) : _profile{data} , _masto{_profile.instance, _profile.access_token} { @@ -116,5 +116,11 @@ void MastoAPI::post_item(const Item &item) throw MastodonException{ret.error_code}; } BOOST_LOG_TRIVIAL(debug) << "Posted status with GUID: " << item.guid; + + _profile.guids.push_back(item.guid); + if (_profile.guids.size() > _max_guids) + { + _profile.guids.pop_front(); + } } } // namespace mastorss diff --git a/src/mastoapi.hpp b/src/mastoapi.hpp index 6b9a041..d0cde7a 100644 --- a/src/mastoapi.hpp +++ b/src/mastoapi.hpp @@ -27,13 +27,14 @@ namespace mastorss class MastoAPI { public: - explicit MastoAPI(const ProfileData &data); + explicit MastoAPI(ProfileData &data); void post_item(const Item &item); private: - const ProfileData &_profile; + ProfileData &_profile; Mastodon::API _masto; + constexpr static size_t _max_guids{100}; }; } // namespace mastorss