@@ -731,7 +731,6 @@ botService.syncSingleBotsWithGitHub = function syncSingleBotsWithGitHub(botId, c
731731 } ) ;
732732}
733733
734-
735734botService . syncBotsWithGitHub = function syncBotsWithGitHub ( gitHubId , callback ) {
736735 async . waterfall ( [
737736 function ( next ) {
@@ -1353,7 +1352,6 @@ function removeScriptFile(filePath) {
13531352 } )
13541353}
13551354
1356-
13571355botService . getBotBysource = function ( source , callback ) {
13581356 var query = { } ;
13591357 var fields = { repositoryName : 1 , _id : 1 } ;
@@ -1477,8 +1475,23 @@ botService.getAllBotsList = function getAllBotsList(botsQuery, userName, callbac
14771475 if ( err ) {
14781476 next ( err , null ) ;
14791477 } else if ( orgIds . length > 0 ) {
1480- queryObj . queryObj [ 'orgId' ] = { $in : orgIds } ;
1481- botDao . getBotsList ( queryObj , next ) ;
1478+ var query = {
1479+ "orgId" : { $in : orgIds } ,
1480+ "isDefault" : 'true'
1481+ } ;
1482+ var fields ;
1483+ gitHubModel . getGitRepository ( query , fields , ( err , res ) => {
1484+ if ( ! err && res . length > 0 ) {
1485+ queryObj . queryObj [ 'orgId' ] = { $in : orgIds } ;
1486+ queryObj . queryObj [ 'gitHubId' ] = res [ 0 ] . _id ;
1487+ botDao . getBotsList ( queryObj , next ) ;
1488+ }
1489+ else {
1490+ logger . error ( "Default Github account not found for OrgIDs: " + orgIds ) ;
1491+ queryObj . queryObj [ 'gitHubId' ] = '' ;
1492+ botDao . getBotsList ( queryObj , next ) ;
1493+ }
1494+ } ) ;
14821495 } else {
14831496 botDao . getBotsList ( queryObj , next ) ;
14841497 }
0 commit comments