@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 CHANGED
@@ -2585,7 +2585,9 @@ var InboundEffectsDispatcher = class {
2585
2585
  const sessionRow = await this.params.sessionRepository.getContext(companyId, message.from);
2586
2586
  if (!sessionRow) return;
2587
2587
  if (sessionRow.mode === "human") return;
2588
- const outcome = await this.params.hooks?.onMessageReceived?.(message, toSessionContract(sessionRow));
2588
+ const outcome = await this.params.hooks?.onMessageReceived?.(message, toSessionContract(sessionRow), job.profileName === void 0 ? {} : {
2589
+ profileName: job.profileName
2590
+ });
2589
2591
  if (outcome?.outcome === "handled") return;
2590
2592
  void extractAnswer(message);
2591
2593
  }
@@ -2714,7 +2716,11 @@ var ReceiveWebhookUseCase = class {
2714
2716
  continue;
2715
2717
  }
2716
2718
  for (const message of change.value.messages ?? []) {
2717
- await this.handleMessage(input.companyId, message);
2719
+ const profileName = (0, import_meta_whatsapp_contracts12.resolveContactProfileName)({
2720
+ contacts: change.value.contacts,
2721
+ from: message.from
2722
+ });
2723
+ await this.handleMessage(input.companyId, message, profileName);
2718
2724
  messagesProcessed++;
2719
2725
  }
2720
2726
  for (const status of change.value.statuses ?? []) {
@@ -2773,7 +2779,7 @@ var ReceiveWebhookUseCase = class {
2773
2779
  await this.params.hooks?.onPhoneNumberQualityUpdate?.(quality.data);
2774
2780
  return true;
2775
2781
  }
2776
- async handleMessage(companyId, message) {
2782
+ async handleMessage(companyId, message, profileName) {
2777
2783
  const saved = await this.params.logMessage.execute({
2778
2784
  companyId,
2779
2785
  whatsappNumber: message.from,
@@ -2796,6 +2802,9 @@ var ReceiveWebhookUseCase = class {
2796
2802
  ...media ? {
2797
2803
  media
2798
2804
  } : {},
2805
+ ...profileName ? {
2806
+ profileName
2807
+ } : {},
2799
2808
  receivedAt: Date.now()
2800
2809
  });
2801
2810
  }