diff --git a/src/cgi.cpp b/src/cgi.cpp index 87b8113..921c1e9 100644 --- a/src/cgi.cpp +++ b/src/cgi.cpp @@ -77,6 +77,7 @@ entry_type parse_formdata() } entry.instance = cgi("instance"); + if (!cgi("tags").empty()) // Old form. { entry.tags = string_to_vector(cgi("tags")); @@ -87,6 +88,8 @@ entry_type parse_formdata() } transform(entry.tags.begin(), entry.tags.end(), entry.tags.begin(), [](const auto &tag) { return tolower(tag); }); + add_tags(entry); + if (!cgi("receipts").empty()) // Old form. { entry.receipts = string_to_vector(cgi("receipts")); @@ -95,6 +98,7 @@ entry_type parse_formdata() { entry.receipts = get_array("receipts[]"); } + entry.description = cgi("description"); entry.report_time = time::to_string(system_clock::now()); @@ -237,6 +241,17 @@ bool is_spam(const entry_type &entry) return false; } +void add_tags(entry_type &entry) +{ + for (const auto &tag : entry.tags) + { + if (tag == "nazism") + { + entry.tags.emplace_back("fascism"); + } + } +} + } // namespace FediBlock::cgi const char *SpamException::what() const noexcept diff --git a/src/cgi.hpp b/src/cgi.hpp index 9929cf3..8c4ce51 100644 --- a/src/cgi.hpp +++ b/src/cgi.hpp @@ -56,6 +56,15 @@ bool captcha_valid(std::uint8_t id, string_view answer); bool is_spam(const entry_type &entry); +/*! + * @brief Add automatic tags. + * + * Example: If tag “nazism” is present, add “fascism”. + * + * @since 0.1.0 + */ +void add_tags(entry_type &entry); + } // namespace FediBlock::cgi class SpamException : public std::exception