From c55d266e9e01ae78247875a11b52726f1e7cb31f Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Mon, 8 May 2017 16:15:09 -0400 Subject: [PATCH 1/2] Restore category in discussion object and comment object #1096 --- libraries/app/database_api.cpp | 23 +------------------ libraries/app/include/steemit/app/state.hpp | 3 ++- .../include/steemit/app/steem_api_objects.hpp | 4 +++- .../include/steemit/chain/comment_object.hpp | 4 ++-- libraries/chain/steem_evaluator.cpp | 2 ++ 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index ebdae1831e..ce1456fb3f 100755 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1170,28 +1170,7 @@ void database_api::set_pending_payout( discussion& d )const void database_api::set_url( discussion& d )const { const comment_api_obj root( my->_db.get< comment_object, by_id >( d.root_comment ) ); - std::vector< std::string > tags; - if( root.json_metadata.size() ) - { - try - { - tags = fc::json::from_string( root.json_metadata )["tags"].as< std::vector< std::string > >(); - if(tags.at(0) != ""){ - d.url = "/" + tags.at(0) + "/@" + root.author + "/" + root.permlink; - } - else { - d.url = "/" + tags.at(1) + "/@" + root.author + "/" + root.permlink; - } - } - catch( const fc::exception& e ) - { - // Do nothing on malformed json_metadata - } - } - if(!tags.size()) { - d.url = "/@" + root.author + "/" + root.permlink; - } - + d.url = "/" + root.category + "/@" + root.author + "/" + root.permlink; d.root_title = root.title; if( root.id != d.id ) d.url += "#@" + d.author + "/" + d.permlink; diff --git a/libraries/app/include/steemit/app/state.hpp b/libraries/app/include/steemit/app/state.hpp index 7313124047..3793f8556e 100644 --- a/libraries/app/include/steemit/app/state.hpp +++ b/libraries/app/include/steemit/app/state.hpp @@ -21,6 +21,7 @@ namespace steemit { namespace app { struct discussion_index { + string category; /// category by which everything is filtered vector< string > trending; /// trending posts over the last 24 hours vector< string > payout; /// pending posts by payout vector< string > payout_comments; /// pending comments by payout @@ -183,7 +184,7 @@ FC_REFLECT_DERIVED( steemit::app::extended_account, FC_REFLECT( steemit::app::vote_state, (voter)(weight)(rshares)(percent)(reputation)(time) ); FC_REFLECT( steemit::app::account_vote, (authorperm)(weight)(rshares)(percent)(time) ); -FC_REFLECT( steemit::app::discussion_index, (trending)(payout)(payout_comments)(trending30)(updated)(created)(responses)(active)(votes)(maturing)(best)(hot)(promoted)(cashout) ) +FC_REFLECT( steemit::app::discussion_index, (category)(trending)(payout)(payout_comments)(trending30)(updated)(created)(responses)(active)(votes)(maturing)(best)(hot)(promoted)(cashout) ) FC_REFLECT( steemit::app::tag_index, (trending) ) FC_REFLECT_DERIVED( steemit::app::discussion, (steemit::app::comment_api_obj), (url)(root_title)(pending_payout_value)(total_pending_payout_value)(active_votes)(replies)(author_reputation)(promoted)(body_length)(reblogged_by)(first_reblogged_by)(first_reblogged_on) ) diff --git a/libraries/app/include/steemit/app/steem_api_objects.hpp b/libraries/app/include/steemit/app/steem_api_objects.hpp index a6670c1837..64fecf38f9 100644 --- a/libraries/app/include/steemit/app/steem_api_objects.hpp +++ b/libraries/app/include/steemit/app/steem_api_objects.hpp @@ -60,6 +60,7 @@ struct comment_api_obj { comment_api_obj( const chain::comment_object& o ): id( o.id ), + category( to_string( o.category ) ), parent_author( o.parent_author ), parent_permlink( to_string( o.parent_permlink ) ), author( o.author ), @@ -101,6 +102,7 @@ struct comment_api_obj comment_api_obj(){} comment_id_type id; + string category; account_name_type parent_author; string parent_permlink; account_name_type author; @@ -480,7 +482,7 @@ struct signed_block_api_obj : public signed_block FC_REFLECT( steemit::app::comment_api_obj, (id)(author)(permlink) - (parent_author)(parent_permlink) + (category)(parent_author)(parent_permlink) (title)(body)(json_metadata)(last_update)(created)(active)(last_payout) (depth)(children) (net_rshares)(abs_rshares)(vote_rshares) diff --git a/libraries/chain/include/steemit/chain/comment_object.hpp b/libraries/chain/include/steemit/chain/comment_object.hpp index c268d2b0f0..5b3f3c9bf3 100644 --- a/libraries/chain/include/steemit/chain/comment_object.hpp +++ b/libraries/chain/include/steemit/chain/comment_object.hpp @@ -244,8 +244,8 @@ namespace steemit { namespace chain { } } // steemit::chain FC_REFLECT( steemit::chain::comment_object, - (id)(category)(author)(permlink) - (parent_author)(parent_permlink) + (id)(author)(permlink) + (category)(parent_author)(parent_permlink) (title)(body)(json_metadata)(last_update)(created)(active)(last_payout) (depth)(children) (net_rshares)(abs_rshares)(vote_rshares) diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index 74dd8b55b5..5b0ea1d6ab 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -562,6 +562,7 @@ void comment_evaluator::do_apply( const comment_operation& o ) { com.parent_author = ""; from_string( com.parent_permlink, o.parent_permlink ); + from_string( com.category, o.parent_permlink ); com.root_comment = com.id; com.cashout_time = _db.has_hardfork( STEEMIT_HARDFORK_0_12__177 ) ? _db.head_block_time() + STEEMIT_CASHOUT_WINDOW_SECONDS_PRE_HF17 : @@ -572,6 +573,7 @@ void comment_evaluator::do_apply( const comment_operation& o ) com.parent_author = parent->author; com.parent_permlink = parent->permlink; com.depth = parent->depth + 1; + com.category = parent->category; com.root_comment = parent->root_comment; com.cashout_time = fc::time_point_sec::maximum(); } From 13b9854f42c604f7c63fbe49e28d016579a41993 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Mon, 8 May 2017 16:16:26 -0400 Subject: [PATCH 2/2] Bump version --- libraries/protocol/include/steemit/protocol/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/protocol/include/steemit/protocol/config.hpp b/libraries/protocol/include/steemit/protocol/config.hpp index 51243b8e97..f487ef2318 100644 --- a/libraries/protocol/include/steemit/protocol/config.hpp +++ b/libraries/protocol/include/steemit/protocol/config.hpp @@ -3,7 +3,7 @@ */ #pragma once -#define STEEMIT_BLOCKCHAIN_VERSION ( version(0, 18, 3) ) +#define STEEMIT_BLOCKCHAIN_VERSION ( version(0, 18, 4) ) #define STEEMIT_BLOCKCHAIN_HARDFORK_VERSION ( hardfork_version( STEEMIT_BLOCKCHAIN_VERSION ) ) #ifdef IS_TEST_NET