Skip to content

Commit

Permalink
Merge pull request steemit#2533 from steemit/2520-get-blog-api-compat
Browse files Browse the repository at this point in the history
condenser_api get_feed and get_blog return legacy serializations
  • Loading branch information
Michael Vandeberg authored Jun 11, 2018
2 parents de8860e + 363ee89 commit 1614386
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 4 deletions.
12 changes: 10 additions & 2 deletions libraries/plugins/apis/condenser_api/condenser_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,11 @@ namespace detail
FC_ASSERT( args.size() == 2 || args.size() == 3, "Expected 2-3 arguments, was ${n}", ("n", args.size()) );
FC_ASSERT( _follow_api, "follow_api_plugin not enabled." );
return _follow_api->get_feed( { args[0].as< account_name_type >(), args[1].as< uint32_t >(), args.size() == 3 ? args[2].as< uint32_t >() : 500 } ).feed;
auto feed = _follow_api->get_feed( { args[0].as< account_name_type >(), args[1].as< uint32_t >(), args.size() == 3 ? args[2].as< uint32_t >() : 500 } ).feed;
get_feed_return result;
result.resize( feed.size() );
result.insert( result.end(), feed.begin(), feed.end() );
return result;
}
DEFINE_API_IMPL( condenser_api_impl, get_blog_entries )
Expand All @@ -1772,7 +1776,11 @@ namespace detail
FC_ASSERT( args.size() == 2 || args.size() == 3, "Expected 2-3 arguments, was ${n}", ("n", args.size()) );
FC_ASSERT( _follow_api, "follow_api_plugin not enabled." );
return _follow_api->get_blog( { args[0].as< account_name_type >(), args[1].as< uint32_t >(), args.size() == 3 ? args[2].as< uint32_t >() : 500 } ).blog;
auto blog = _follow_api->get_blog( { args[0].as< account_name_type >(), args[1].as< uint32_t >(), args.size() == 3 ? args[2].as< uint32_t >() : 500 } ).blog;
get_blog_return result;
result.resize( blog.size() );
result.insert( result.end(), blog.begin(), blog.end() );
return result;
}
DEFINE_API_IMPL( condenser_api_impl, get_account_reputations )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,99 @@ struct extended_account : public api_account_object
optional< vector< string > > recommended; /// posts recommened for this user
};

struct api_comment_object
{
api_comment_object( const database_api::api_comment_object& c ):
id( c.id ),
category( c.category ),
parent_author( c.parent_author ),
parent_permlink( c.parent_permlink ),
author( c.author ),
permlink( c.permlink ),
title( c.title ),
body( c.body ),
json_metadata( c.json_metadata ),
last_update( c.last_update ),
created( c.created ),
active( c.active ),
last_payout( c.last_payout ),
depth( c.depth ),
children( c.children ),
net_rshares( c.net_rshares ),
abs_rshares( c.abs_rshares ),
vote_rshares( c.vote_rshares ),
children_abs_rshares( c.children_abs_rshares ),
cashout_time( c.cashout_time ),
max_cashout_time( c.max_cashout_time ),
total_vote_weight( c.total_vote_weight ),
reward_weight( c.reward_weight ),
total_payout_value( legacy_asset::from_asset( c.total_payout_value ) ),
curator_payout_value( legacy_asset::from_asset( c.curator_payout_value ) ),
author_rewards( c.author_rewards ),
net_votes( c.net_votes ),
root_author( c.root_author ),
root_permlink( c.root_permlink ),
max_accepted_payout( legacy_asset::from_asset( c.max_accepted_payout ) ),
percent_steem_dollars( c.percent_steem_dollars ),
allow_replies( c.allow_replies ),
allow_votes( c.allow_votes ),
allow_curation_rewards( c.allow_curation_rewards )
{
for( auto& route : c.beneficiaries )
{
beneficiaries.push_back( route );
}
}

api_comment_object(){}

comment_id_type id;
string category;
string parent_author;
string parent_permlink;
string author;
string permlink;

string title;
string body;
string json_metadata;
time_point_sec last_update;
time_point_sec created;
time_point_sec active;
time_point_sec last_payout;

uint8_t depth = 0;
uint32_t children = 0;

share_type net_rshares;
share_type abs_rshares;
share_type vote_rshares;

share_type children_abs_rshares;
time_point_sec cashout_time;
time_point_sec max_cashout_time;
uint64_t total_vote_weight = 0;

uint16_t reward_weight = 0;

legacy_asset total_payout_value;
legacy_asset curator_payout_value;

share_type author_rewards;

int32_t net_votes = 0;

account_name_type root_author;
string root_permlink;

legacy_asset max_accepted_payout;
uint16_t percent_steem_dollars = 0;
bool allow_replies = false;
bool allow_votes = false;
bool allow_curation_rewards = false;
vector< beneficiary_route_type > beneficiaries;
};

struct extended_dynamic_global_properties
{
extended_dynamic_global_properties() {}
Expand Down Expand Up @@ -780,6 +873,46 @@ struct broadcast_transaction_synchronous_return
bool expired = false;
};

struct comment_feed_entry
{
comment_feed_entry( const follow::comment_feed_entry& c ) :
comment( c.comment ),
reblog_on( c.reblog_on ),
entry_id( c.entry_id )
{
reblog_by.resize( c.reblog_by.size() );

for( auto& a : c.reblog_by )
{
reblog_by.push_back( a );
}
}

comment_feed_entry() {}

api_comment_object comment;
vector< account_name_type > reblog_by;
time_point_sec reblog_on;
uint32_t entry_id = 0;
};

struct comment_blog_entry
{
comment_blog_entry( const follow::comment_blog_entry& c ) :
comment( c.comment ),
blog( c.blog ),
reblog_on( c.reblog_on ),
entry_id( c.entry_id )
{}

comment_blog_entry() {}

api_comment_object comment;
string blog;
time_point_sec reblog_on;
uint32_t entry_id = 0;
};

struct ticker
{
ticker() {}
Expand Down Expand Up @@ -932,9 +1065,9 @@ DEFINE_API_ARGS( get_followers, vector< variant >, ve
DEFINE_API_ARGS( get_following, vector< variant >, vector< follow::api_follow_object > )
DEFINE_API_ARGS( get_follow_count, vector< variant >, follow::get_follow_count_return )
DEFINE_API_ARGS( get_feed_entries, vector< variant >, vector< follow::feed_entry > )
DEFINE_API_ARGS( get_feed, vector< variant >, vector< follow::comment_feed_entry > )
DEFINE_API_ARGS( get_feed, vector< variant >, vector< comment_feed_entry > )
DEFINE_API_ARGS( get_blog_entries, vector< variant >, vector< follow::blog_entry > )
DEFINE_API_ARGS( get_blog, vector< variant >, vector< follow::comment_blog_entry > )
DEFINE_API_ARGS( get_blog, vector< variant >, vector< comment_blog_entry > )
DEFINE_API_ARGS( get_account_reputations, vector< variant >, vector< reputation::account_reputation > )
DEFINE_API_ARGS( get_reblogged_by, vector< variant >, vector< account_name_type > )
DEFINE_API_ARGS( get_blog_authors, vector< variant >, vector< follow::reblog_count > )
Expand Down Expand Up @@ -1087,6 +1220,19 @@ FC_REFLECT_DERIVED( steem::plugins::condenser_api::extended_account, (steem::plu
(average_bandwidth)(lifetime_bandwidth)(last_bandwidth_update)(average_market_bandwidth)(lifetime_market_bandwidth)(last_market_bandwidth_update)
(vesting_balance)(reputation)(transfer_history)(market_history)(post_history)(vote_history)(other_history)(witness_votes)(tags_usage)(guest_bloggers)(open_orders)(comments)(feed)(blog)(recent_replies)(recommended) )

FC_REFLECT( steem::plugins::condenser_api::api_comment_object,
(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)
(children_abs_rshares)(cashout_time)(max_cashout_time)
(total_vote_weight)(reward_weight)(total_payout_value)(curator_payout_value)(author_rewards)(net_votes)
(root_author)(root_permlink)
(max_accepted_payout)(percent_steem_dollars)(allow_replies)(allow_votes)(allow_curation_rewards)
(beneficiaries)
)

FC_REFLECT( steem::plugins::condenser_api::extended_dynamic_global_properties,
(head_block_number)(head_block_id)(time)
(current_witness)(total_pow)(num_pow_witnesses)
Expand Down Expand Up @@ -1204,6 +1350,12 @@ FC_REFLECT( steem::plugins::condenser_api::get_version_return,
FC_REFLECT( steem::plugins::condenser_api::broadcast_transaction_synchronous_return,
(id)(block_num)(trx_num)(expired) )

FC_REFLECT( steem::plugins::condenser_api::comment_feed_entry,
(comment)(reblog_by)(reblog_on)(entry_id) )

FC_REFLECT( steem::plugins::condenser_api::comment_blog_entry,
(comment)(blog)(reblog_on)(entry_id) )

FC_REFLECT( steem::plugins::condenser_api::ticker,
(latest)(lowest_ask)(highest_bid)(percent_change)(steem_volume)(sbd_volume) )

Expand Down

0 comments on commit 1614386

Please sign in to comment.