Skip to content

Commit ed8009a

Browse files
committed
Populate get_product_list from the secondary network if the primary is
unavailable.
1 parent 23efcba commit ed8009a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pc/user.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,16 @@ void user::parse_get_product_list( uint32_t itok )
298298
{
299299
add_header();
300300
jw_.add_key( "result", json_wtr::e_arr );
301-
for( unsigned i=0; i != sptr_->get_num_product(); ++i ) {
302-
product *prod = sptr_->get_product( i );
301+
302+
// If the primary manager has no products, pull them from the secondary
303+
// manager instead.
304+
pc::manager *mgr = sptr_;
305+
if ( sptr_->get_num_product() == 0 && sptr_->has_secondary() ) {
306+
mgr = sptr_->get_secondary();
307+
}
308+
309+
for( unsigned i=0; i != mgr->get_num_product(); ++i ) {
310+
product *prod = mgr->get_product( i );
303311
jw_.add_val( json_wtr::e_obj );
304312
jw_.add_key( "account", *prod->get_account() );
305313
jw_.add_key( "attr_dict", json_wtr::e_obj );

0 commit comments

Comments
 (0)