Skip to content

Commit 55822f9

Browse files
committed
style: improve code formatting for better readability in WhatsApp service files
1 parent 0078015 commit 55822f9

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

src/api/integrations/channel/meta/whatsapp.business.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ export class BusinessStartupService extends ChannelStartupService {
463463
this.logger?.info?.('Video upload attempted but is disabled by configuration.');
464464
return {
465465
success: false,
466-
message: 'Video upload is currently disabled. Please contact support if you need this feature enabled.',
466+
message:
467+
'Video upload is currently disabled. Please contact support if you need this feature enabled.',
467468
};
468469
}
469470

@@ -1213,8 +1214,9 @@ export class BusinessStartupService extends ChannelStartupService {
12131214
const token = this.token;
12141215

12151216
const headers = { Authorization: `Bearer ${token}` };
1216-
const url = `${this.configService.get<WaBusiness>('WA_BUSINESS').URL}/${this.configService.get<WaBusiness>('WA_BUSINESS').VERSION
1217-
}/${this.number}/media`;
1217+
const url = `${this.configService.get<WaBusiness>('WA_BUSINESS').URL}/${
1218+
this.configService.get<WaBusiness>('WA_BUSINESS').VERSION
1219+
}/${this.number}/media`;
12181220

12191221
const res = await axios.post(url, formData, { headers });
12201222
return res.data.id;

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

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export class BaileysStartupService extends ChannelStartupService {
381381
qrcodeTerminal.generate(qr, { small: true }, (qrcode) =>
382382
this.logger.log(
383383
`\n{ instance: ${this.instance.name} pairingCode: ${this.instance.qrcode.pairingCode}, qrcodeCount: ${this.instance.qrcode.count} }\n` +
384-
qrcode,
384+
qrcode,
385385
),
386386
);
387387

@@ -978,16 +978,16 @@ export class BaileysStartupService extends ChannelStartupService {
978978

979979
const messagesRepository: Set<string> = new Set(
980980
chatwootImport.getRepositoryMessagesCache(instance) ??
981-
(
982-
await this.prismaRepository.message.findMany({
983-
select: { key: true },
984-
where: { instanceId: this.instanceId },
985-
})
986-
).map((message) => {
987-
const key = message.key as { id: string };
988-
989-
return key.id;
990-
}),
981+
(
982+
await this.prismaRepository.message.findMany({
983+
select: { key: true },
984+
where: { instanceId: this.instanceId },
985+
})
986+
).map((message) => {
987+
const key = message.key as { id: string };
988+
989+
return key.id;
990+
}),
991991
);
992992

993993
if (chatwootImport.getRepositoryMessagesCache(instance) === null) {
@@ -4726,12 +4726,7 @@ export class BaileysStartupService extends ChannelStartupService {
47264726
}
47274727

47284728
public async fetchMessages(query: Query<Message>) {
4729-
const keyFilters = query?.where?.key as {
4730-
id?: string;
4731-
fromMe?: boolean;
4732-
remoteJid?: string;
4733-
participants?: string;
4734-
};
4729+
const keyFilters = query?.where?.key as ExtendedIMessageKey;
47354730

47364731
const timestampFilter = {};
47374732
if (query?.where?.messageTimestamp) {
@@ -4754,7 +4749,13 @@ export class BaileysStartupService extends ChannelStartupService {
47544749
keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {},
47554750
keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {},
47564751
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
4757-
keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {},
4752+
keyFilters?.participant ? { key: { path: ['participant'], equals: keyFilters?.participant } } : {},
4753+
{
4754+
OR: [
4755+
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
4756+
keyFilters?.senderPn ? { key: { path: ['senderPn'], equals: keyFilters?.senderPn } } : {},
4757+
],
4758+
},
47584759
],
47594760
},
47604761
});
@@ -4778,7 +4779,13 @@ export class BaileysStartupService extends ChannelStartupService {
47784779
keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {},
47794780
keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {},
47804781
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
4781-
keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {},
4782+
keyFilters?.participant ? { key: { path: ['participant'], equals: keyFilters?.participant } } : {},
4783+
{
4784+
OR: [
4785+
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
4786+
keyFilters?.senderPn ? { key: { path: ['senderPn'], equals: keyFilters?.senderPn } } : {},
4787+
],
4788+
},
47824789
],
47834790
},
47844791
orderBy: { messageTimestamp: 'desc' },

src/utils/getConversationMessage.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ const getTypeMessage = (msg: any) => {
3838
? `videoMessage|${mediaId}${msg?.message?.videoMessage?.caption ? `|${msg?.message?.videoMessage?.caption}` : ''}`
3939
: undefined,
4040
documentMessage: msg?.message?.documentMessage
41-
? `documentMessage|${mediaId}${msg?.message?.documentMessage?.caption ? `|${msg?.message?.documentMessage?.caption}` : ''
42-
}`
41+
? `documentMessage|${mediaId}${
42+
msg?.message?.documentMessage?.caption ? `|${msg?.message?.documentMessage?.caption}` : ''
43+
}`
4344
: undefined,
4445
documentWithCaptionMessage: msg?.message?.documentWithCaptionMessage?.message?.documentMessage
45-
? `documentWithCaptionMessage|${mediaId}${msg?.message?.documentWithCaptionMessage?.message?.documentMessage?.caption
46-
? `|${msg?.message?.documentWithCaptionMessage?.message?.documentMessage?.caption}`
47-
: ''
48-
}`
46+
? `documentWithCaptionMessage|${mediaId}${
47+
msg?.message?.documentWithCaptionMessage?.message?.documentMessage?.caption
48+
? `|${msg?.message?.documentWithCaptionMessage?.message?.documentMessage?.caption}`
49+
: ''
50+
}`
4951
: undefined,
5052
externalAdReplyBody: msg?.contextInfo?.externalAdReply?.body
5153
? `externalAdReplyBody|${msg.contextInfo.externalAdReply.body}`

0 commit comments

Comments
 (0)