From a2a49eee1985ec13e52e477060a50da2fcbdb894 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 13 Oct 2021 07:57:03 +0200 Subject: Lbry: fix missing search match for channels with no title (but with a name) and reposts --- include/MessageQueue.hpp | 2 +- src/plugins/Lbry.cpp | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/MessageQueue.hpp b/include/MessageQueue.hpp index 30826f4..286739d 100644 --- a/include/MessageQueue.hpp +++ b/include/MessageQueue.hpp @@ -58,7 +58,7 @@ namespace QuickMedia { running = true; } - // Returns true from |callback| to remove the element + // Return true from |callback| to remove the element void erase_if(std::function callback) { std::unique_lock lock(mutex); for(auto it = data_queue.begin(); it != data_queue.end();) { diff --git a/src/plugins/Lbry.cpp b/src/plugins/Lbry.cpp index c35e430..239a269 100644 --- a/src/plugins/Lbry.cpp +++ b/src/plugins/Lbry.cpp @@ -25,7 +25,7 @@ namespace QuickMedia { return true; } - static std::shared_ptr resolve_claim_parse_result(const Json::Value &result_json, time_t time_now) { + static std::shared_ptr resolve_claim(const Json::Value &result_json, time_t time_now) { if(!result_json.isObject()) return nullptr; @@ -39,11 +39,15 @@ namespace QuickMedia { if(!value_json.isObject()) return nullptr; + std::string name; const Json::Value &title_json = value_json["title"]; - if(!title_json.isString()) - return nullptr; + const Json::Value &name_json = result_json["name"]; + if(title_json.isString()) + name = title_json.asString(); + else if(name_json.isString()) + name = name_json.asString(); - auto body_item = BodyItem::create(title_json.asString()); + auto body_item = BodyItem::create(std::move(name)); bool is_channel = false; // TODO: Support other types than stream and channel @@ -88,7 +92,6 @@ namespace QuickMedia { } } - const Json::Value &name_json = result_json["name"]; if(name_json.isString()) { if(!description.empty()) description += '\n'; @@ -128,6 +131,17 @@ namespace QuickMedia { return body_item; } + static std::shared_ptr resolve_claim_parse_result(const Json::Value &result_json, time_t time_now) { + if(!result_json.isObject()) + return nullptr; + + const Json::Value &resposted_claim_json = result_json["reposted_claim"]; + if(resposted_claim_json.isObject()) + return resolve_claim(resposted_claim_json, time_now); + else + return resolve_claim(result_json, time_now); + } + static PluginResult resolve_claims(Page *page, const Json::Value &request_json, BodyItems &result_items) { if(!request_json.isObject()) return PluginResult::ERR; -- cgit v1.2.3