diff --git a/manager.cpp b/manager.cpp index 4d0ba96..91f728c 100644 --- a/manager.cpp +++ b/manager.cpp @@ -470,7 +470,8 @@ bool RepostManager::drop_posts_older_than(std::vector &posts, long } std::optional RepostManager::to_abstract_post(const vk::Post &post, int sourceIndex) { - return { AbstractPost(posts::SRC_VK, sourceIndex, post.id, post.date, post.text) }; + if (post.text.empty()) return {}; + else return { AbstractPost(posts::SRC_VK, sourceIndex, post.id, post.date, post.text) }; } std::optional RepostManager::to_abstract_post(const td_api::message &post, int sourceIndex) { @@ -486,6 +487,7 @@ std::vector RepostManager::to_abstract_posts(std::vector std::vector result; result.reserve(posts.size()); for (auto &post : posts) { + if (post.text.empty()) continue; result.emplace_back(posts::SRC_VK, sourceIndex, post.id, post.date, post.text); } return result; @@ -555,6 +557,10 @@ bool RepostManager::recheck_vk_posts(std::function onDone) { } void RepostManager::repost(AbstractPost &post) { + if (post.text.length() == 0) { + spdlog::error("repost(): zero post length (post id {} date {})", post.id, post.date); + return; + } spdlog::debug("reposting (post length {})", post.text.length()); std::string_view signature = posts::add_signature(post, m_appConfig); int signatureStart = post.text.length() - signature.length();