bugfix: Too long posts would sometimes not be shrinked
All checks were successful
the build was successful

This commit is contained in:
tastytea 2018-08-25 23:52:22 +02:00
parent cb31080a57
commit 024a7e0af7
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (mastorss
VERSION 0.7.1
VERSION 0.7.2
LANGUAGES CXX
)

View File

@ -163,10 +163,12 @@ std::vector<Mastodon::Easy::Status> parse_website(const string &xml)
}
// Why is this necessary? Why does ##hashtag happen?
content = std::regex_replace(content, std::regex("##"), "#");
if ((content.size() + link.size()) > static_cast<std::uint16_t>(max_size - 15))
uint16_t appendix_size = config[profile]["append"].asString().length();
if ((content.size() + link.size() + appendix_size)
> static_cast<std::uint16_t>(max_size - 4))
{
content.resize((max_size - link.size() -
config[profile]["append"].asString().length() - 4));
content.resize((max_size - link.size() - appendix_size - 4));
content.resize(content.rfind(' ')); // Cut at word boundary
content += " […]";
}