Don't parse more items than Config::max_guids.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2020-11-05 14:14:33 +01:00
parent 38f795df26
commit cf78a2e43e
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
4 changed files with 10 additions and 2 deletions

View File

@ -72,6 +72,7 @@ public:
const string profile; const string profile;
ProfileData profiledata; ProfileData profiledata;
constexpr static size_t max_guids{100};
void write(); void write();
[[nodiscard]] fs::path get_config_dir() const; [[nodiscard]] fs::path get_config_dir() const;

View File

@ -165,8 +165,16 @@ void Document::parse()
void Document::parse_rss(const pt::ptree &tree) void Document::parse_rss(const pt::ptree &tree)
{ {
size_t counter{0};
for (const auto &child : tree.get_child("rss.channel")) for (const auto &child : tree.get_child("rss.channel"))
{ {
if (counter == Config::max_guids)
{
BOOST_LOG_TRIVIAL(debug)
<< "Maximum number of items reached. Stopped parsing.";
break;
}
++counter;
if (child.first == "item") if (child.first == "item")
{ {
const auto &rssitem = child.second; const auto &rssitem = child.second;

View File

@ -128,7 +128,7 @@ void MastoAPI::post_item(const Item &item)
BOOST_LOG_TRIVIAL(debug) << "Posted status with GUID: " << item.guid; BOOST_LOG_TRIVIAL(debug) << "Posted status with GUID: " << item.guid;
_profile.guids.push_back(item.guid); _profile.guids.push_back(item.guid);
if (_profile.guids.size() > _max_guids) if (_profile.guids.size() > Config::max_guids)
{ {
_profile.guids.pop_front(); _profile.guids.pop_front();
} }

View File

@ -38,7 +38,6 @@ public:
private: private:
ProfileData &_profile; ProfileData &_profile;
mastodonpp::Instance _instance; mastodonpp::Instance _instance;
constexpr static size_t _max_guids{100};
string replacements_apply(const string &text); string replacements_apply(const string &text);
}; };