From 30059ed6481e07c7d22b6449852eba236da9f2b7 Mon Sep 17 00:00:00 2001 From: Max Castro Date: Mon, 29 Jan 2024 11:09:56 -0400 Subject: [PATCH] Update ZohoLeadActivity.php --- .../Zoho/Workflows/ZohoLeadActivity.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Domains/Connectors/Zoho/Workflows/ZohoLeadActivity.php b/src/Domains/Connectors/Zoho/Workflows/ZohoLeadActivity.php index 333f0eb01..f587b1f93 100644 --- a/src/Domains/Connectors/Zoho/Workflows/ZohoLeadActivity.php +++ b/src/Domains/Connectors/Zoho/Workflows/ZohoLeadActivity.php @@ -13,6 +13,7 @@ use Kanvas\Connectors\Zoho\ZohoService; use Kanvas\Guild\Agents\Models\Agent; use Kanvas\Guild\Leads\Models\Lead; +use Kanvas\SystemModules\Repositories\SystemModulesRepository; use Kanvas\Workflow\Contracts\WorkflowActivityInterface; use Throwable; use Webleit\ZohoCrmApi\Modules\Leads as ZohoLeadModule; @@ -27,7 +28,6 @@ class ZohoLeadActivity extends Activity implements WorkflowActivityInterface */ public function execute(Model $lead, AppInterface $app, array $params): array { - $lead = Lead::getById($lead->getId()); $zohoLead = ZohoLead::fromLead($lead); $zohoData = $zohoLead->toArray(); $company = Companies::getById($lead->companies_id); @@ -60,6 +60,7 @@ public function execute(Model $lead, AppInterface $app, array $params): array 'zohoLeadId' => $zohoLeadId, 'zohoRequest' => $zohoData, 'leadId' => $lead->getId(), + 'systemModule' => SystemModulesRepository::getByModelName(get_class($lead))->getId() ]; } @@ -139,15 +140,19 @@ protected function uploadAttachments(ZohoLeadModule $zohoLead, Lead $lead): void continue; } - $fileContent = file_get_contents($file->url); + try { + $fileContent = file_get_contents($file->url); - $zohoLead->uploadAttachment( - (string) $lead->get(CustomFieldEnum::ZOHO_LEAD_ID->value), - $file->name, - $fileContent - ); + $zohoLead->uploadAttachment( + (string) $lead->get(CustomFieldEnum::ZOHO_LEAD_ID->value), + $file->name, + $fileContent + ); - $syncFiles[$file->id] = $file->id; + $syncFiles[$file->id] = $file->id; + } catch(Throwable $e) { + //do nothing + } } $lead->set(