Skip to content

Commit 96e26ac

Browse files
committed
Populate get_product_list from the secondary network if the primary is
unavailable.
1 parent f353b2d commit 96e26ac

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
@@ -294,8 +294,16 @@ void user::parse_get_product_list( uint32_t itok )
294294
{
295295
add_header();
296296
jw_.add_key( "result", json_wtr::e_arr );
297-
for( unsigned i=0; i != sptr_->get_num_product(); ++i ) {
298-
product *prod = sptr_->get_product( i );
297+
298+
// If the primary manager has no products, pull them from the secondary
299+
// manager instead.
300+
pc::manager *mgr = sptr_;
301+
if ( sptr_->get_num_product() == 0 && sptr_->has_secondary() ) {
302+
mgr = sptr_->get_secondary();
303+
}
304+
305+
for( unsigned i=0; i != mgr->get_num_product(); ++i ) {
306+
product *prod = mgr->get_product( i );
299307
jw_.add_val( json_wtr::e_obj );
300308
jw_.add_key( "account", *prod->get_account() );
301309
jw_.add_key( "attr_dict", json_wtr::e_obj );

0 commit comments

Comments
 (0)