Skip to content

Commit d892c4b

Browse files
committed
fix: make fetchBusinessProfile non-fatal in catalog/collections
- fetchBusinessProfile failure no longer blocks catalog/collections fetch - Both endpoints now continue even if business profile check fails - Prevents returning isBusiness:false when profile API is temporarily down
1 parent f4eefcb commit d892c4b

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4912,7 +4912,14 @@ export class BaileysStartupService extends ChannelStartupService {
49124912

49134913
try {
49144914
const info = (await this.whatsappNumber({ numbers: [jid] }))?.shift();
4915-
const business = await this.fetchBusinessProfile(info?.jid);
4915+
4916+
let isBusiness = false;
4917+
try {
4918+
const business = await this.fetchBusinessProfile(info?.jid);
4919+
isBusiness = business?.isBusiness || false;
4920+
} catch (profileError) {
4921+
console.log('fetchBusinessProfile failed, continuing catalog fetch:', profileError?.message);
4922+
}
49164923

49174924
let catalog = await this.getCatalog({ jid: info?.jid, limit, cursor });
49184925
let nextPageCursor = catalog.nextPageCursor;
@@ -4939,7 +4946,7 @@ export class BaileysStartupService extends ChannelStartupService {
49394946
return {
49404947
wuid: info?.jid || jid,
49414948
numberExists: info?.exists,
4942-
isBusiness: business.isBusiness,
4949+
isBusiness: isBusiness,
49434950
catalogLength: productsCatalog.length,
49444951
catalog: productsCatalog,
49454952
};
@@ -4981,14 +4988,22 @@ export class BaileysStartupService extends ChannelStartupService {
49814988

49824989
try {
49834990
const info = (await this.whatsappNumber({ numbers: [jid] }))?.shift();
4984-
const business = await this.fetchBusinessProfile(info?.jid);
4991+
4992+
let isBusiness = false;
4993+
try {
4994+
const business = await this.fetchBusinessProfile(info?.jid);
4995+
isBusiness = business?.isBusiness || false;
4996+
} catch (profileError) {
4997+
console.log('fetchBusinessProfile failed, continuing collections fetch:', profileError?.message);
4998+
}
4999+
49855000
const collections = await this.getCollections(info?.jid, limit);
49865001

49875002
return {
49885003
wuid: info?.jid || jid,
49895004
name: info?.name,
49905005
numberExists: info?.exists,
4991-
isBusiness: business.isBusiness,
5006+
isBusiness: isBusiness,
49925007
collectionsLength: collections?.length,
49935008
collections: collections,
49945009
};

0 commit comments

Comments
 (0)