@adatechnology/meta-whatsapp-module 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -2396,6 +2396,14 @@ type InboundMessageEffectsJob = {
|
|
|
2396
2396
|
message: WhatsAppMessage;
|
|
2397
2397
|
savedMessageId: string;
|
|
2398
2398
|
media?: InboundMediaDescriptor;
|
|
2399
|
+
/**
|
|
2400
|
+
* Nome de perfil de quem mandou. Vai no JOB e não é relido depois porque o job pode passar por
|
|
2401
|
+
* fila: o payload da Meta não existe mais quando o worker roda.
|
|
2402
|
+
*
|
|
2403
|
+
* Opcional, e job antigo sem o campo continua válido — é o que permite subir o módulo sem drenar
|
|
2404
|
+
* a fila antes.
|
|
2405
|
+
*/
|
|
2406
|
+
profileName?: string;
|
|
2399
2407
|
receivedAt: number;
|
|
2400
2408
|
};
|
|
2401
2409
|
type InboundStatusEffectsJob = {
|
package/dist/index.d.ts
CHANGED
|
@@ -2396,6 +2396,14 @@ type InboundMessageEffectsJob = {
|
|
|
2396
2396
|
message: WhatsAppMessage;
|
|
2397
2397
|
savedMessageId: string;
|
|
2398
2398
|
media?: InboundMediaDescriptor;
|
|
2399
|
+
/**
|
|
2400
|
+
* Nome de perfil de quem mandou. Vai no JOB e não é relido depois porque o job pode passar por
|
|
2401
|
+
* fila: o payload da Meta não existe mais quando o worker roda.
|
|
2402
|
+
*
|
|
2403
|
+
* Opcional, e job antigo sem o campo continua válido — é o que permite subir o módulo sem drenar
|
|
2404
|
+
* a fila antes.
|
|
2405
|
+
*/
|
|
2406
|
+
profileName?: string;
|
|
2399
2407
|
receivedAt: number;
|
|
2400
2408
|
};
|
|
2401
2409
|
type InboundStatusEffectsJob = {
|
package/dist/index.js
CHANGED
|
@@ -2085,7 +2085,7 @@ var WhatsAppChannelAdapter = class {
|
|
|
2085
2085
|
};
|
|
2086
2086
|
|
|
2087
2087
|
// src/channel/ReceiveWebhook.use-case.ts
|
|
2088
|
-
import { whatsAppWebhookPayloadSchema, whatsAppTemplateStatusUpdateSchema, whatsAppPhoneNumberQualityUpdateSchema, WHATSAPP_WEBHOOK_FIELDS } from "@adatechnology/meta-whatsapp-contracts";
|
|
2088
|
+
import { whatsAppWebhookPayloadSchema, resolveContactProfileName, whatsAppTemplateStatusUpdateSchema, whatsAppPhoneNumberQualityUpdateSchema, WHATSAPP_WEBHOOK_FIELDS } from "@adatechnology/meta-whatsapp-contracts";
|
|
2089
2089
|
|
|
2090
2090
|
// src/channel/webhookSecurity.ts
|
|
2091
2091
|
import { WEBHOOK_CLAIM_TTL_SECONDS, WEBHOOK_NONCE_TTL_SECONDS, buildWebhookDeliveryKey, isValidWebhookChallenge, isValidWebhookSignature } from "@adatechnology/meta-graph-core";
|
|
@@ -2496,7 +2496,9 @@ var InboundEffectsDispatcher = class {
|
|
|
2496
2496
|
const sessionRow = await this.params.sessionRepository.getContext(companyId, message.from);
|
|
2497
2497
|
if (!sessionRow) return;
|
|
2498
2498
|
if (sessionRow.mode === "human") return;
|
|
2499
|
-
const outcome = await this.params.hooks?.onMessageReceived?.(message, toSessionContract(sessionRow)
|
|
2499
|
+
const outcome = await this.params.hooks?.onMessageReceived?.(message, toSessionContract(sessionRow), job.profileName === void 0 ? {} : {
|
|
2500
|
+
profileName: job.profileName
|
|
2501
|
+
});
|
|
2500
2502
|
if (outcome?.outcome === "handled") return;
|
|
2501
2503
|
void extractAnswer(message);
|
|
2502
2504
|
}
|
|
@@ -2625,7 +2627,11 @@ var ReceiveWebhookUseCase = class {
|
|
|
2625
2627
|
continue;
|
|
2626
2628
|
}
|
|
2627
2629
|
for (const message of change.value.messages ?? []) {
|
|
2628
|
-
|
|
2630
|
+
const profileName = resolveContactProfileName({
|
|
2631
|
+
contacts: change.value.contacts,
|
|
2632
|
+
from: message.from
|
|
2633
|
+
});
|
|
2634
|
+
await this.handleMessage(input.companyId, message, profileName);
|
|
2629
2635
|
messagesProcessed++;
|
|
2630
2636
|
}
|
|
2631
2637
|
for (const status of change.value.statuses ?? []) {
|
|
@@ -2684,7 +2690,7 @@ var ReceiveWebhookUseCase = class {
|
|
|
2684
2690
|
await this.params.hooks?.onPhoneNumberQualityUpdate?.(quality.data);
|
|
2685
2691
|
return true;
|
|
2686
2692
|
}
|
|
2687
|
-
async handleMessage(companyId, message) {
|
|
2693
|
+
async handleMessage(companyId, message, profileName) {
|
|
2688
2694
|
const saved = await this.params.logMessage.execute({
|
|
2689
2695
|
companyId,
|
|
2690
2696
|
whatsappNumber: message.from,
|
|
@@ -2707,6 +2713,9 @@ var ReceiveWebhookUseCase = class {
|
|
|
2707
2713
|
...media ? {
|
|
2708
2714
|
media
|
|
2709
2715
|
} : {},
|
|
2716
|
+
...profileName ? {
|
|
2717
|
+
profileName
|
|
2718
|
+
} : {},
|
|
2710
2719
|
receivedAt: Date.now()
|
|
2711
2720
|
});
|
|
2712
2721
|
}
|