diff --git a/src/pocketdb/helpers/ShortFormHelper.cpp b/src/pocketdb/helpers/ShortFormHelper.cpp index 6d854c074..266499922 100644 --- a/src/pocketdb/helpers/ShortFormHelper.cpp +++ b/src/pocketdb/helpers/ShortFormHelper.cpp @@ -78,6 +78,24 @@ bool PocketHelpers::ShortTxFilterValidator::Activities::IsFilterAllowed(PocketDb return allowed.find(type) != allowed.end(); } +bool PocketHelpers::ShortTxFilterValidator::Events::IsFilterAllowed(PocketDb::ShortTxType type) +{ + static const std::set allowed = { + PocketDb::ShortTxType::Money, + PocketDb::ShortTxType::Referal, + PocketDb::ShortTxType::Answer, + PocketDb::ShortTxType::Comment, + PocketDb::ShortTxType::Subscriber, + PocketDb::ShortTxType::CommentScore, + PocketDb::ShortTxType::ContentScore, + PocketDb::ShortTxType::PrivateContent, + PocketDb::ShortTxType::Boost, + PocketDb::ShortTxType::Repost, + }; + + return allowed.find(type) != allowed.end(); +} + PocketDb::ShortTxType PocketHelpers::ShortTxTypeConvertor::strToType(const std::string& typeStr) { static const auto& typesMap = GetTypesMap(); diff --git a/src/pocketdb/helpers/ShortFormHelper.h b/src/pocketdb/helpers/ShortFormHelper.h index 282479aa7..a00ac3a2f 100644 --- a/src/pocketdb/helpers/ShortFormHelper.h +++ b/src/pocketdb/helpers/ShortFormHelper.h @@ -39,6 +39,12 @@ namespace PocketHelpers public: static bool IsFilterAllowed(PocketDb::ShortTxType type); }; + + class Events + { + public: + static bool IsFilterAllowed(PocketDb::ShortTxType type); + }; }; // STMT here is used to avoid including here any of sqlite3 headers, however diff --git a/src/pocketdb/web/PocketContentRpc.cpp b/src/pocketdb/web/PocketContentRpc.cpp index bea008a12..e67fe4bbf 100644 --- a/src/pocketdb/web/PocketContentRpc.cpp +++ b/src/pocketdb/web/PocketContentRpc.cpp @@ -1359,7 +1359,7 @@ namespace PocketWeb::PocketWebRpc if (rawFilters[i].isStr()) { const auto& rawFilter = rawFilters[i].get_str(); auto filter = ShortTxTypeConvertor::strToType(rawFilter); - if (filter == ShortTxType::NotSet) { + if (!PocketHelpers::ShortTxFilterValidator::Events::IsFilterAllowed(filter)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Unexpected filter: " + rawFilter); } filters.insert(filter);