|
45441
|
1626
|
41
|
2026-05-14T14:36:45.665681+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769405665_m2.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterday at 13.3Yesterday at 13:36Yesterday at 13:36Yesterday at 13.30Yesterdav at 13:35Yesterday at 13:34Yesterday at 13:34Yesterdav at 13:3kYesterday at 13:33Yesterday at 13.32Yesterdav at 13:31resterday at 15:30Yesterdav at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28Yecterdav at 12:28resterday at 13-21Yesterdav at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13:25Voctorday at 12:01Yesterday at 13.23Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:19Yesterdav at 13:18Yesterday at 13-1/Yesterdav at 13:17Yesterday at 13:16Yesterday at 13:15Yecterdav at 12:15Yesterday at 13.14Yecterdav at 13:10Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:11Yesterday at 13.10Yecterdav at 12:10Yesterdav at 13:09Yesterdav at 13:08v Size23 KB9 KB13 Kb16 KE17 KB29 KB16 K:12 KB9 KEIKBn8 KBI37 KB10 KB7 KE8 KB9 KB8 KB172 KR14 KB13 KB9 KE18 KB12 KB10 KBI16 KB6 KB6KB12 KE23 KB8 KB16 K:11 KB20 KP34 KB10 KB7 K:5 KB11 KB26 KBMPEG-4 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMPE0"4 movieMDSG-A movieMP2G-4 movieMPEG-4 movieMPEG"4 movieMPEG-4 movieMoEeh movioMPEG-4 movieMPEG-1 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMDEG.A movicMPEG-4 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMDEC A movidMPEG-4 movieMDEG-A movieMPEG-4 movieMPEG-4 movieMDEC.A moviaMPEG-4 movie111 KC102 KB88 KBMDEG-A moviaMPEG-4 movie59 KB1MPEG-A movie98 KB MPEG-4 movie97 KB66 K3MPEG-4 movieMDEG.A movioAAKP93 KB/8 KBMPEG-4 movie50 KгMDEG-A movid58 KBMPEG-4 movie27 KB7KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc tolde0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.46 GB availabld• Inu 14 Mау 1/•30.42Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 г+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
2098038158965143539
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterday at 13.3Yesterday at 13:36Yesterday at 13:36Yesterday at 13.30Yesterdav at 13:35Yesterday at 13:34Yesterday at 13:34Yesterdav at 13:3kYesterday at 13:33Yesterday at 13.32Yesterdav at 13:31resterday at 15:30Yesterdav at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28Yecterdav at 12:28resterday at 13-21Yesterdav at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13:25Voctorday at 12:01Yesterday at 13.23Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:19Yesterdav at 13:18Yesterday at 13-1/Yesterdav at 13:17Yesterday at 13:16Yesterday at 13:15Yecterdav at 12:15Yesterday at 13.14Yecterdav at 13:10Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:11Yesterday at 13.10Yecterdav at 12:10Yesterdav at 13:09Yesterdav at 13:08v Size23 KB9 KB13 Kb16 KE17 KB29 KB16 K:12 KB9 KEIKBn8 KBI37 KB10 KB7 KE8 KB9 KB8 KB172 KR14 KB13 KB9 KE18 KB12 KB10 KBI16 KB6 KB6KB12 KE23 KB8 KB16 K:11 KB20 KP34 KB10 KB7 K:5 KB11 KB26 KBMPEG-4 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMPE0"4 movieMDSG-A movieMP2G-4 movieMPEG-4 movieMPEG"4 movieMPEG-4 movieMoEeh movioMPEG-4 movieMPEG-1 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMDEG.A movicMPEG-4 movieMPEG-4 movieMPEG-4 movieMPEG-4 movieMDEC A movidMPEG-4 movieMDEG-A movieMPEG-4 movieMPEG-4 movieMDEC.A moviaMPEG-4 movie111 KC102 KB88 KBMDEG-A moviaMPEG-4 movie59 KB1MPEG-A movie98 KB MPEG-4 movie97 KB66 K3MPEG-4 movieMDEG.A movioAAKP93 KB/8 KBMPEG-4 movie50 KгMDEG-A movid58 KBMPEG-4 movie27 KB7KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc tolde0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.46 GB availabld• Inu 14 Mау 1/•30.42Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 г+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45442
|
NULL
|
0
|
2026-05-14T14:36:49.442879+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769409442_m1.jpg...
|
iTerm2
|
NULL
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest100% С8• Thu 14 May 17:36:49* :QProject v© UserAutomatedReportsController.php:= custom.logAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php→ JobsPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.logProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php XSF [jiminny@localhost]© DataClient.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:W© DecorateActivity.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.php© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] X18© LocalSearch.php• LocalSearchlnterface.phpE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php4 console [PROD]C RemoteSearch.php© Service.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpA console (EU]15.04.26 Vasilev24trait LogActivityTraitv C ListenersA6 м1 лDGojiminny v23.04.26 Vasilev85© ConvertLeadActivities.phpprivate function buildSubjectPayload(Activity $activity, Playbook Splaybook): array084143 ×4 л© PurgeLookupCache.php21.04.26Vasilev89* If the activity playbook category name (i.e. activity type)matches a knownac 215•m_layout_id =› D Metadata21.04.26Vasilev90* in the CRM,then we set the activity type in the payload.2162,1661, 66799,66> C Migration21.04.26 Vasilev91* Some activity types may be locally created. They shouldn't be sent to Salesfor 217v 0 Pipedrive21.04.26 Vasilev92*218> D OpportunitySyncStrategy21.04.26 Vasilev93* The resulting payload attribute will look like:219.id = 33;> D ProspectSearchStrategy21.04.26 Vasilev94'Type' => 'Cold Call'220© ApiFields.php21.04.26 Vasilev95*/221© Client.php23.04.26 Vasilev96return [222© FieldDefinitions.php23.04.26 Vasilev97/** ActivityFieldID => ActivityType */223© PipedriveApiClient.php15.04.26 Vasilev98$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()224id THEN '(own• PipedriveApiException.php20.04.26 Vasilev99'Subject' => $this->getActivityDecorator()->generateTitle(Sactivity),225© Service.php15.04.26 Vasilev1001:226© TokenStorage.php23.04.26 Vasilev101227v D Salesforce15.04.26 Vasilev102228• Fields23.04.26 Vasilev103/**229• OpportunityMatcher23.04.26 Vasilev104* Building of the title seems very inconsistent230hubspot':-• OpportunitySyncStrategy23.04.26 Vasilev105* Subject here will be something like:231D ProspectSearchStrategy23.04.26 Vasilev106"Local activity type: Activity Title"232v • ServiceTraits23.04.26 Vasilev107*/7233 v= 11512582;T BatchSyncTrait.php23.04.26 Vasilev108$subject = Sactivity->getCategory()->getName():234+ FollowupActivityTrait.php23.04.26 Vasilev109if ($activity->getTitle() !== null) {T LogActivityTrait.php23.04.26 Vasilev110$supject .= ': ' . $activity->getTitle();+ RecordManipulationsTrait.f15.04.26 Vasilev111}T SyncFieldsTrait.php15.04.26 Vasilev112@ Client nhn23.04.26 Vasilev113return ['Subiect'=> Ssubiect]:Workspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams110:16UTF-8Ca 4 spaces...
|
NULL
|
2190842645994009865
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest100% С8• Thu 14 May 17:36:49* :QProject v© UserAutomatedReportsController.php:= custom.logAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php→ JobsPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.logProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php XSF [jiminny@localhost]© DataClient.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:W© DecorateActivity.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.php© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] X18© LocalSearch.php• LocalSearchlnterface.phpE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php4 console [PROD]C RemoteSearch.php© Service.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpA console (EU]15.04.26 Vasilev24trait LogActivityTraitv C ListenersA6 м1 лDGojiminny v23.04.26 Vasilev85© ConvertLeadActivities.phpprivate function buildSubjectPayload(Activity $activity, Playbook Splaybook): array084143 ×4 л© PurgeLookupCache.php21.04.26Vasilev89* If the activity playbook category name (i.e. activity type)matches a knownac 215•m_layout_id =› D Metadata21.04.26Vasilev90* in the CRM,then we set the activity type in the payload.2162,1661, 66799,66> C Migration21.04.26 Vasilev91* Some activity types may be locally created. They shouldn't be sent to Salesfor 217v 0 Pipedrive21.04.26 Vasilev92*218> D OpportunitySyncStrategy21.04.26 Vasilev93* The resulting payload attribute will look like:219.id = 33;> D ProspectSearchStrategy21.04.26 Vasilev94'Type' => 'Cold Call'220© ApiFields.php21.04.26 Vasilev95*/221© Client.php23.04.26 Vasilev96return [222© FieldDefinitions.php23.04.26 Vasilev97/** ActivityFieldID => ActivityType */223© PipedriveApiClient.php15.04.26 Vasilev98$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()224id THEN '(own• PipedriveApiException.php20.04.26 Vasilev99'Subject' => $this->getActivityDecorator()->generateTitle(Sactivity),225© Service.php15.04.26 Vasilev1001:226© TokenStorage.php23.04.26 Vasilev101227v D Salesforce15.04.26 Vasilev102228• Fields23.04.26 Vasilev103/**229• OpportunityMatcher23.04.26 Vasilev104* Building of the title seems very inconsistent230hubspot':-• OpportunitySyncStrategy23.04.26 Vasilev105* Subject here will be something like:231D ProspectSearchStrategy23.04.26 Vasilev106"Local activity type: Activity Title"232v • ServiceTraits23.04.26 Vasilev107*/7233 v= 11512582;T BatchSyncTrait.php23.04.26 Vasilev108$subject = Sactivity->getCategory()->getName():234+ FollowupActivityTrait.php23.04.26 Vasilev109if ($activity->getTitle() !== null) {T LogActivityTrait.php23.04.26 Vasilev110$supject .= ': ' . $activity->getTitle();+ RecordManipulationsTrait.f15.04.26 Vasilev111}T SyncFieldsTrait.php15.04.26 Vasilev112@ Client nhn23.04.26 Vasilev113return ['Subiect'=> Ssubiect]:Workspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams110:16UTF-8Ca 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45443
|
NULL
|
0
|
2026-05-14T14:36:49.452652+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769409452_m2.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.46 GB availabld• Inu 14 Mау 1/•30.44Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
771622661116508809
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.46 GB availabld• Inu 14 Mау 1/•30.44Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
45441
|
NULL
|
NULL
|
NULL
|
|
45445
|
1628
|
0
|
2026-05-14T14:37:08.052513+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769428052_m2.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}
Execute
Explain Plan
Browse Query History
View Parameters...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","depth":4,"bounds":{"left":0.43783244,"top":0.12210695,"width":0.31848404,"height":0.87789303},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
3525368579526985675
|
7758231530128816516
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}
Execute
Explain Plan
Browse Query History
View Parameters...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45444
|
1627
|
0
|
2026-05-14T14:37:08.071469+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769428071_m1.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.78194445,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.80277777,"top":0.3122222,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8078283887967787415
|
7759357430035650948
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny...
|
45442
|
NULL
|
NULL
|
NULL
|
|
45447
|
1628
|
1
|
2026-05-14T14:37:09.426822+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769429426_m2.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.47 GB availabld• Inu 14 May 1/•3/•00Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
-8335772991236113394
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.47 GB availabld• Inu 14 May 1/•3/•00Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
45445
|
NULL
|
NULL
|
NULL
|
|
45446
|
1627
|
1
|
2026-05-14T14:37:09.443270+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769429443_m1.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit K vHandleHubspotRateLimitTest100% <8• Thu 14 May 17:37:09* :QProject v© UserAutomatedReportsController.php:=custom.logAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.phpD JobsPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.logProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php xSF [jiminny@localhost]© DataClient.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:W© DecorateActivity.php18© LocalSearch.php• LocalSearchlnterface.phpC RemoteSearch.php© Service.phpv D Listeners© PlainTextDecorateActivity.phpE.env© HubspotPaginationService.php15.04.26 Vasilev15.04.26 VasilevT ActivityPlaybookTrait.php© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] XDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php4 console [PROD]A console (EU]© ConvertLeadActivities.php© PurgeLookupCache.php› D Metadata> C Migrationv 0 Pipedrive> D OpportunitySyncStrategy> D ProspectSearchStrategy© ApiFields.php27.04.26 Vasilev27.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev244878798081828384© HandleHubspotRateLimit.phptrait LogActivityTraitpublic function saveActivity(Activity $activity): Activity1);A6 X1A$this->saveCrm0bject(ScrmObjectType, Sactivity, Spayload);return Sactivity:id = 33;© Client.php1 usage© FieldDefinitions.php23.04.26 Vasilev© PipedriveApiClient.php23.04.26 Vasilev• PipedriveApiException.php15.04.26 Vasilev© Service.php21.04.26 Vasilev© TokenStorage.php21.04.26 Vasilevv D Salesforce21.04.26 Vasilev• Fields21.04.26 Vasilev• OpportunityMatcher21.04.26Vasilev• OpportunitySyncStrategy21.04.26 VasilevD ProspectSearchStrategy21.04.26 Vasilevv • ServiceTraits21.04.26 Vasilev23.04.26 Vasilev private function buildSubjectPayload(Activity $activity, Playbook $playbook): arrayif ($this->matchesCrmType($activity->getCategory))) {/***DGo jiminny084143 ×4 ^— 215•m_layout_id =2162,1661,66799,66- 217— 218219220221222223224225226* If the activity playbook category name (i.e. activity type) matches a knownac 227* in the CRM, then we set the activity type in the payload.228* Some activity types may be locally created. They shouldn't besent to Salesfor229230231232233 V234id THEN(ownhubspot":* The resulting payload attribute will look like:'Type"=> 'Cold Call'BatchSyncTrait.php*/return [= 11512582;+ FollowupActivityTrait.php23.04.26 VasilevT LogActivityTrait.php15.04.26 Vasilev+ RecordManipulationsTrait.f20.04.26 Vasilev/** ActivityFieldID => ActivityType */$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory€'Subject' => $this->getActivityDecorator()->generateTitle(Sactivity),T SyncFieldsTrait.php15.04.26 Vasilev]:@ Client nhn23.04.26 VasilevWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams87:34 (14 chars)UTF-8Co 4 spaces...
|
NULL
|
9062883269134786823
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit K vHandleHubspotRateLimitTest100% <8• Thu 14 May 17:37:09* :QProject v© UserAutomatedReportsController.php:=custom.logAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.phpD JobsPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.logProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php xSF [jiminny@localhost]© DataClient.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:W© DecorateActivity.php18© LocalSearch.php• LocalSearchlnterface.phpC RemoteSearch.php© Service.phpv D Listeners© PlainTextDecorateActivity.phpE.env© HubspotPaginationService.php15.04.26 Vasilev15.04.26 VasilevT ActivityPlaybookTrait.php© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] XDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php4 console [PROD]A console (EU]© ConvertLeadActivities.php© PurgeLookupCache.php› D Metadata> C Migrationv 0 Pipedrive> D OpportunitySyncStrategy> D ProspectSearchStrategy© ApiFields.php27.04.26 Vasilev27.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev244878798081828384© HandleHubspotRateLimit.phptrait LogActivityTraitpublic function saveActivity(Activity $activity): Activity1);A6 X1A$this->saveCrm0bject(ScrmObjectType, Sactivity, Spayload);return Sactivity:id = 33;© Client.php1 usage© FieldDefinitions.php23.04.26 Vasilev© PipedriveApiClient.php23.04.26 Vasilev• PipedriveApiException.php15.04.26 Vasilev© Service.php21.04.26 Vasilev© TokenStorage.php21.04.26 Vasilevv D Salesforce21.04.26 Vasilev• Fields21.04.26 Vasilev• OpportunityMatcher21.04.26Vasilev• OpportunitySyncStrategy21.04.26 VasilevD ProspectSearchStrategy21.04.26 Vasilevv • ServiceTraits21.04.26 Vasilev23.04.26 Vasilev private function buildSubjectPayload(Activity $activity, Playbook $playbook): arrayif ($this->matchesCrmType($activity->getCategory))) {/***DGo jiminny084143 ×4 ^— 215•m_layout_id =2162,1661,66799,66- 217— 218219220221222223224225226* If the activity playbook category name (i.e. activity type) matches a knownac 227* in the CRM, then we set the activity type in the payload.228* Some activity types may be locally created. They shouldn't besent to Salesfor229230231232233 V234id THEN(ownhubspot":* The resulting payload attribute will look like:'Type"=> 'Cold Call'BatchSyncTrait.php*/return [= 11512582;+ FollowupActivityTrait.php23.04.26 VasilevT LogActivityTrait.php15.04.26 Vasilev+ RecordManipulationsTrait.f20.04.26 Vasilev/** ActivityFieldID => ActivityType */$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory€'Subject' => $this->getActivityDecorator()->generateTitle(Sactivity),T SyncFieldsTrait.php15.04.26 Vasilev]:@ Client nhn23.04.26 VasilevWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams87:34 (14 chars)UTF-8Co 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45448
|
1627
|
2
|
2026-05-14T14:37:13.307193+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769433307_m1.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit K vHandleHubspotRateLimitTest100% <8• Thu 14 May 17:37:12* :QProject v© UserAutomatedReportsController.php:=custom.logAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.phpD JobsPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.logProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php xSF [jiminny@localhost]© DataClient.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:W© DecorateActivity.php18© LocalSearch.php• LocalSearchlnterface.phpC RemoteSearch.php© Service.phpv C Listeners© PlainTextDecorateActivity.phpE.env© HubspotPaginationService.php15.04.26 Vasilev15.04.26 VasilevT ActivityPlaybookTrait.php© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] XDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php4 console [PROD]2448© ConvertLeadActivities.php© PurgeLookupCache.php© HandleHubspotRateLimit.phptrait LogActivityTraitpublic function saveActivity(Activity $activity): Activity1);A console (EU]A6 X1 ^› D Metadata> C Migrationv 0 Pipedrive> D OpportunitySyncStrategy> D ProspectSearchStrategy© ApiFields.php27.04.26 Vasilev27.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev78798081828384$this->saveCrm0bject(ScrmObjectType, Sactivity, Spayload);return Sactivity:id = 33;© Client.php1 usage© FieldDefinitions.php23.04.26 Vasilev© PipedriveApiClient.php23.04.26 Vasilev• PipedriveApiException.php15.04.26 Vasilev© Service.php21.04.26 Vasilev© TokenStorage.php21.04.26 Vasilevv D Salesforce21.04.26 Vasilev• Fields21.04.26 Vasilev• OpportunityMatcher21.04.26Vasilev• OpportunitySyncStrategy21.04.26 VasilevD ProspectSearchStrategy21.04.26 Vasilevv • ServiceTraits21.04.26 Vasilev23.04.26 Vasilev private function buildSubjectPayload(Activity $activity, Playbook $playbook): arrayif ($this->matchesCrmType(Sactivity->getCategoryO)) 1/***DGo jiminny084143 ×4 ^— 215•m_layout_id =2162,1661,66799,66- * If the activity playbook category name (i.e. activity type) matches a knownac227* in the CRM, then we set the activity type in the payload.228* Some activity types may be locally created. They shouldn't besent to Salesfor229230231232233 V234id THEN(ownhubspat":* The resulting payload attribute will look like:'Type"=> 'Cold Call'BatchSyncTrait.php+ FollowupActivityTrait.php23.04.26 VasilevFT LogActivityTrait.php15.04.26 Vasilev+ RecordManipulationsTrait.f20.04.26 Vasilev*/return [/** ActivityFieldID => ActivityType */$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory€'Supject'=> $this->getActivityDecorator()->generateTitle($activity),= 11512582;T SyncFieldsTrait.php15.04.26 Vasilev]:@ Client nhn23.04.26 VasilevWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams99:20UTF-8Co 4 spaces...
|
NULL
|
2765905447232264644
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit K vHandleHubspotRateLimitTest100% <8• Thu 14 May 17:37:12* :QProject v© UserAutomatedReportsController.php:=custom.logAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.phpD JobsPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.logProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php xSF [jiminny@localhost]© DataClient.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:W© DecorateActivity.php18© LocalSearch.php• LocalSearchlnterface.phpC RemoteSearch.php© Service.phpv C Listeners© PlainTextDecorateActivity.phpE.env© HubspotPaginationService.php15.04.26 Vasilev15.04.26 VasilevT ActivityPlaybookTrait.php© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] XDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php4 console [PROD]2448© ConvertLeadActivities.php© PurgeLookupCache.php© HandleHubspotRateLimit.phptrait LogActivityTraitpublic function saveActivity(Activity $activity): Activity1);A console (EU]A6 X1 ^› D Metadata> C Migrationv 0 Pipedrive> D OpportunitySyncStrategy> D ProspectSearchStrategy© ApiFields.php27.04.26 Vasilev27.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev23.04.26 Vasilev78798081828384$this->saveCrm0bject(ScrmObjectType, Sactivity, Spayload);return Sactivity:id = 33;© Client.php1 usage© FieldDefinitions.php23.04.26 Vasilev© PipedriveApiClient.php23.04.26 Vasilev• PipedriveApiException.php15.04.26 Vasilev© Service.php21.04.26 Vasilev© TokenStorage.php21.04.26 Vasilevv D Salesforce21.04.26 Vasilev• Fields21.04.26 Vasilev• OpportunityMatcher21.04.26Vasilev• OpportunitySyncStrategy21.04.26 VasilevD ProspectSearchStrategy21.04.26 Vasilevv • ServiceTraits21.04.26 Vasilev23.04.26 Vasilev private function buildSubjectPayload(Activity $activity, Playbook $playbook): arrayif ($this->matchesCrmType(Sactivity->getCategoryO)) 1/***DGo jiminny084143 ×4 ^— 215•m_layout_id =2162,1661,66799,66- * If the activity playbook category name (i.e. activity type) matches a knownac227* in the CRM, then we set the activity type in the payload.228* Some activity types may be locally created. They shouldn't besent to Salesfor229230231232233 V234id THEN(ownhubspat":* The resulting payload attribute will look like:'Type"=> 'Cold Call'BatchSyncTrait.php+ FollowupActivityTrait.php23.04.26 VasilevFT LogActivityTrait.php15.04.26 Vasilev+ RecordManipulationsTrait.f20.04.26 Vasilev*/return [/** ActivityFieldID => ActivityType */$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory€'Supject'=> $this->getActivityDecorator()->generateTitle($activity),= 11512582;T SyncFieldsTrait.php15.04.26 Vasilev]:@ Client nhn23.04.26 VasilevWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams99:20UTF-8Co 4 spaces...
|
45446
|
NULL
|
NULL
|
NULL
|
|
45449
|
1628
|
2
|
2026-05-14T14:37:13.307212+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769433307_m2.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.47 GB availabld• Inu 14 Mаy 1/•3/:12Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
-4061887643733524785
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.47 GB availabld• Inu 14 Mаy 1/•3/:12Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45451
|
1628
|
3
|
2026-05-14T14:37:17.748387+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769437748_m2.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","depth":4,"bounds":{"left":0.43783244,"top":0.12210695,"width":0.31848404,"height":0.87789303},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false}]...
|
-2724287045098079756
|
7758231530128816516
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}...
|
45449
|
NULL
|
NULL
|
NULL
|
|
45450
|
1627
|
3
|
2026-05-14T14:37:17.748410+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769437748_m1.jpg...
|
PhpStorm
|
faVsco.js – LogActivityTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}
Execute
Explain Plan
Browse Query History
View Parameters...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.78194445,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.80277777,"top":0.3122222,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Salesforce\\ServiceTraits;\n\nuse Illuminate\\Events\\Dispatcher;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\HttpNotFoundException;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Lead;\nuse Jiminny\\Models\\Playbook;\nuse Jiminny\\Models\\PlaybookCategory;\nuse Jiminny\\Services\\Crm\\Helpers\\CrmHelperRepository;\nuse Jiminny\\Services\\Crm\\Salesforce\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Salesforce\\PayloadBuilder;\nuse Psr\\Log\\LoggerInterface;\n\ntrait LogActivityTrait\n{\n public ?Configuration $config;\n public ?Profile $profile;\n\n protected PayloadBuilder $payloadBuilder;\n protected LoggerInterface $logger;\n protected Dispatcher $eventDispatcher;\n protected CrmHelperRepository $crmHelperRepository;\n protected ?DecorateActivity $decorateActivity = null;\n\n abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;\n abstract public function matchesCrmType(PlaybookCategory $category): bool;\n\n abstract public function syncLead(string $crmId): ?Lead;\n abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;\n abstract public function createRecord(string $objectType, array $data): string;\n abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;\n\n /**\n * Save an activity, update CRM prospect objects\n *\n * Create or update a task or event (depending on most applicable playbook)\n */\n public function saveActivity(Activity $activity): Activity\n {\n $playbook = $this->getPlaybookFromActivity($activity);\n\n if ($playbook === null) {\n throw new InvalidArgumentException('Please configure a Playbook first.');\n }\n\n $this->logger->info('[Salesforce] Log activity', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n ]);\n\n $payload = [\n 'OwnerId' => $this->profile->getCrmProviderId(),\n 'Description' => $this->getActivityDecorator()->generateDescription($activity),\n ];\n\n $payload += $this->buildSubjectPayload($activity, $playbook);\n $payload += $this->buildProspectPayload($activity);\n\n $crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK\n ? Field::OBJECT_TASK\n : Field::OBJECT_EVENT;\n\n $this->logger->info('[Salesforce] Log activity. Payload Prepared', [\n 'activity_id' => $activity->getId(),\n 'object_type' => $playbook->getActivityType(),\n 'crm_object_type' => $crmObjectType,\n 'payload' => $payload,\n ]);\n\n $this->saveCrmObject($crmObjectType, $activity, $payload);\n\n return $activity;\n }\n\n private function buildSubjectPayload(Activity $activity, Playbook $playbook): array\n {\n if ($this->matchesCrmType($activity->getCategory())) {\n /**\n * If the activity playbook category name (i.e. activity type) matches a known activity type that exists\n * in the CRM, then we set the activity type in the payload.\n * Some activity types may be locally created. They shouldn't be sent to Salesforce.\n *\n * The resulting payload attribute will look like:\n * `Type` => 'Cold Call'\n */\n return [\n /** ActivityFieldID => ActivityType */\n $playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),\n 'Subject' => $this->getActivityDecorator()->generateTitle($activity),\n ];\n }\n\n /**\n * Building of the title seems very inconsistent\n * Subject here will be something like:\n * \"Local activity type: Activity Title\"\n */\n $subject = $activity->getCategory()->getName();\n if ($activity->getTitle() !== null) {\n $subject .= ': ' . $activity->getTitle();\n }\n\n return ['Subject' => $subject];\n }\n\n private function buildProspectPayload(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->getAccountId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'account_id' => $activity->getAccountId(),\n 'opportunity_id' => $activity->getOpportunityId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $hasLinkFeature = $this->crmHelperRepository->hasFeature(\n $activity,\n FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS\n );\n\n if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())\n || (! $hasLinkFeature && $activity->getOpportunityId())\n ) {\n $payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();\n } else {\n $payload['WhatId'] = $activity->getAccount()->getCrmProviderId();\n }\n }\n\n if ($activity->getContactId()) {\n $this->logger->info('[Salesforce] Activity has account id', [\n 'activity_id' => $activity->getId(),\n 'contact_id' => $activity->getContactId(),\n ]);\n\n $payload['WhoId'] = $activity->getContact()->getCrmProviderId();\n } elseif ($activity->getLeadId()) {\n $this->logger->info('[Salesforce] Activity has lead id', [\n 'activity_id' => $activity->getId(),\n 'lead_id' => $activity->getLeadId(),\n ]);\n\n /**\n * An activity may have:\n * a) a contact | account | opportunity (or combinations)\n * b) only a lead\n * c) none of the above\n *\n * An activity should not have a lead, and another prospect object at the same time.\n *\n * This logical flow should not happen naturally, but as a fallback: if an activity has both\n * a Lead and an Account, the account's WhatId takes precedence in the CRM payload.\n * The lead association will be detached locally, but the account WhatId is preserved in Salesforce.\n */\n $payload += $this->handleActivityLead($activity);\n }\n\n return $payload;\n }\n\n private function handleActivityLead(Activity $activity): array\n {\n $this->logger->info('[Salesforce] Activity sync lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Sync lead to pull fresh data. Leads change often,\n * they may get 'converted', and we must handle the new state accordingly\n */\n try {\n $activityLead = $this->syncLead(\n $activity->getLead()->getCrmProviderId()\n );\n } catch (HttpNotFoundException) {\n $this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not found, maybe it's remotely deleted\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n if ($activityLead === null) {\n $this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [\n 'activity_id' => $activity->getId(),\n ]);\n\n /**\n * Lead is not loaded, for some reason. It may be remotely found, but locally deleted.\n * Or an important Lead property may be missing, and it cannot be fully imported.\n */\n $this->resetLeadAssociation($activity);\n\n return [];\n }\n\n /**\n * The lead is not converted, directly use it as WhoId and move on.\n */\n if ($activityLead->getConvertedAt() === null) {\n return [\n 'WhoId' => $activity->getLead()->getCrmProviderId(),\n 'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.\n ];\n }\n\n /**\n * Task/Event payload properties for the CRM update\n */\n $whoId = null;\n $whatId = null;\n\n /**\n * Activity payload properties, that need to be updated.\n */\n $convertedOpportunityId = null;\n $convertedAccountId = null;\n $convertedContactId = null;\n $value = null;\n\n /**\n * If there is converted opportunity, it will update the activity stage.\n * If there isn't an opportunity, a converted account/contact cannot have a stage id,\n * so the activity shouldn't have a stage either.\n */\n $stageId = null;\n\n /**\n * The lead is definitely converted.\n * This means the lead may be associated with an opportunity, account, or contact.\n * The converted lead itself must be detached from the activity,\n * while the converted prospect objects must be associated instead,\n * since they now represent the state of the deal.\n */\n $activity->setLeadId(null);\n\n /**\n * CRM property \"WhatId\" can be either an Opportunity or an Account.\n * For us a converted Opportunity has higher priority than an Account.\n * An Opportunity carries more concrete data, including a reference to the Account record itself.\n */\n if ($activityLead->hasOpportunity()) {\n $convertedOpportunity = $activityLead->getOpportunity();\n\n $convertedOpportunityId = $convertedOpportunity->getId();\n $convertedAccountId = $convertedOpportunity->getAccountId();\n $stageId = $convertedOpportunity->getStageId();\n $value = $convertedOpportunity->getValue();\n\n $whatId = $convertedOpportunity->getCrmProviderId();\n }\n\n if ($activityLead->hasAccount()) {\n $convertedAccount = $activityLead->getAccount();\n\n $convertedAccountId ??= $convertedAccount->getId();\n\n $whatId ??= $convertedAccount->getCrmProviderId();\n }\n\n /**\n * WhoId can only be a Contact or a Lead.\n * Since we are detaching the Lead, it can only be a Contact for the current activity.\n * It does not conflict with any other object.\n */\n if ($activityLead->hasContact()) {\n $convertedContact = $activityLead->getContact();\n\n $convertedContactId = $convertedContact->getId();\n\n $whoId = $convertedContact->getCrmProviderId();\n }\n\n $activity->setOpportunityId($convertedOpportunityId);\n $activity->setAccountId($convertedAccountId);\n $activity->setContactId($convertedContactId);\n $activity->setStageId($stageId);\n $activity->setValue($value);\n\n $activity->save();\n\n $this->eventDispatcher->dispatch(\n new ActivityLeadConverted($activity, $activityLead)\n );\n\n $this->logger->info('[Salesforce] Lead is converted', [\n 'activity_id' => $activity->getId(),\n 'whoId' => $whoId,\n 'whatId' => $whatId,\n ]);\n\n return [\n 'WhoId' => $whoId,\n 'WhatId' => $whatId,\n ];\n }\n\n private function saveCrmObject(string $objectType, Activity $activity, array $payload): void\n {\n /**\n * Tasks and events have different payload structures,\n * so we need to consider the type of the object we are sending to the CRM\n */\n $specificPayload = $objectType === Field::OBJECT_TASK\n ? $this->payloadBuilder->buildTaskPayload($activity)\n : $this->payloadBuilder->buildEventPayload($activity);\n\n $payload = array_merge($payload, $specificPayload);\n\n if ($activity->hasCrmProviderId()) {\n $this->logger->info('[Salesforce] Updating crm object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n try {\n $this->updateCrmActivity($objectType, $activity, $payload);\n } catch (HttpNotFoundException) {\n $this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $activity->setCrmProviderId(null);\n $activity->save();\n }\n\n return;\n }\n\n $this->logger->info('[Salesforce] Creating CRM object', [\n 'activity_id' => $activity->getId(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'object_type' => $objectType,\n ]);\n\n $crmProviderId = $this->createRecord($objectType, $payload);\n\n $activity->setCrmProviderId($crmProviderId);\n $activity->save();\n }\n\n /**\n * @throws HttpNotFoundException\n */\n private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void\n {\n $sfActivity = $this->getRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n fields: ['Description', 'WhoId', 'WhatId']\n );\n\n if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {\n $this->logger->info('[Salesforce] Updating WhoId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n\n if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {\n $this->logger->info('[Salesforce] Updating WhatId', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n ]);\n } else {\n $payload['WhatId'] = null;\n }\n }\n\n $payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(\n $payload['Description'],\n $sfActivity['Description'] ?? null\n );\n\n $this->logger->info('[Salesforce] Updating CRM activity data', [\n 'objectType' => $objectType,\n 'activityId' => $activity->getUuid(),\n 'crmActivity' => $sfActivity,\n 'payload' => $payload,\n ]);\n\n $this->updateRecord(\n objectType: $objectType,\n objectId: $activity->getCrmProviderId(),\n data: $payload\n );\n }\n\n protected function getActivityDecorator(): DecorateActivity\n {\n if ($this->decorateActivity === null) {\n $this->decorateActivity = app(DecorateActivity::class);\n }\n\n return $this->decorateActivity;\n }\n\n private function resetLeadAssociation(Activity $activity): void\n {\n $activity->setStageId(null);\n $activity->setLeadId(null);\n $activity->save();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
3525368579526985675
|
7758231530128816516
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Salesforce\ServiceTraits;
use Illuminate\Events\Dispatcher;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Lead;
use Jiminny\Models\Playbook;
use Jiminny\Models\PlaybookCategory;
use Jiminny\Services\Crm\Helpers\CrmHelperRepository;
use Jiminny\Services\Crm\Salesforce\DecorateActivity;
use Jiminny\Services\Crm\Salesforce\PayloadBuilder;
use Psr\Log\LoggerInterface;
trait LogActivityTrait
{
public ?Configuration $config;
public ?Profile $profile;
protected PayloadBuilder $payloadBuilder;
protected LoggerInterface $logger;
protected Dispatcher $eventDispatcher;
protected CrmHelperRepository $crmHelperRepository;
protected ?DecorateActivity $decorateActivity = null;
abstract public function getPlaybookFromActivity(Activity $activity): ?Playbook;
abstract public function matchesCrmType(PlaybookCategory $category): bool;
abstract public function syncLead(string $crmId): ?Lead;
abstract public function getRecord(string $objectType, string $objectId, array $fields = []): array;
abstract public function createRecord(string $objectType, array $data): string;
abstract public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void;
/**
* Save an activity, update CRM prospect objects
*
* Create or update a task or event (depending on most applicable playbook)
*/
public function saveActivity(Activity $activity): Activity
{
$playbook = $this->getPlaybookFromActivity($activity);
if ($playbook === null) {
throw new InvalidArgumentException('Please configure a Playbook first.');
}
$this->logger->info('[Salesforce] Log activity', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
]);
$payload = [
'OwnerId' => $this->profile->getCrmProviderId(),
'Description' => $this->getActivityDecorator()->generateDescription($activity),
];
$payload += $this->buildSubjectPayload($activity, $playbook);
$payload += $this->buildProspectPayload($activity);
$crmObjectType = $playbook->getActivityType() === Playbook::ACTIVITY_TYPE_TASK
? Field::OBJECT_TASK
: Field::OBJECT_EVENT;
$this->logger->info('[Salesforce] Log activity. Payload Prepared', [
'activity_id' => $activity->getId(),
'object_type' => $playbook->getActivityType(),
'crm_object_type' => $crmObjectType,
'payload' => $payload,
]);
$this->saveCrmObject($crmObjectType, $activity, $payload);
return $activity;
}
private function buildSubjectPayload(Activity $activity, Playbook $playbook): array
{
if ($this->matchesCrmType($activity->getCategory())) {
/**
* If the activity playbook category name (i.e. activity type) matches a known activity type that exists
* in the CRM, then we set the activity type in the payload.
* Some activity types may be locally created. They shouldn't be sent to Salesforce.
*
* The resulting payload attribute will look like:
* `Type` => 'Cold Call'
*/
return [
/** ActivityFieldID => ActivityType */
$playbook->getActivityField()->getCrmProviderId() => $activity->getCategory()->getName(),
'Subject' => $this->getActivityDecorator()->generateTitle($activity),
];
}
/**
* Building of the title seems very inconsistent
* Subject here will be something like:
* "Local activity type: Activity Title"
*/
$subject = $activity->getCategory()->getName();
if ($activity->getTitle() !== null) {
$subject .= ': ' . $activity->getTitle();
}
return ['Subject' => $subject];
}
private function buildProspectPayload(Activity $activity): array
{
$payload = [];
if ($activity->getAccountId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'account_id' => $activity->getAccountId(),
'opportunity_id' => $activity->getOpportunityId(),
'contact_id' => $activity->getContactId(),
]);
$hasLinkFeature = $this->crmHelperRepository->hasFeature(
$activity,
FeatureEnum::LINK_ACTIVITY_TO_MULTIPLE_PROSPECTS
);
if (($hasLinkFeature && $activity->getOpportunityId() && ! $activity->getContactId())
|| (! $hasLinkFeature && $activity->getOpportunityId())
) {
$payload['WhatId'] = $activity->getOpportunity()->getCrmProviderId();
} else {
$payload['WhatId'] = $activity->getAccount()->getCrmProviderId();
}
}
if ($activity->getContactId()) {
$this->logger->info('[Salesforce] Activity has account id', [
'activity_id' => $activity->getId(),
'contact_id' => $activity->getContactId(),
]);
$payload['WhoId'] = $activity->getContact()->getCrmProviderId();
} elseif ($activity->getLeadId()) {
$this->logger->info('[Salesforce] Activity has lead id', [
'activity_id' => $activity->getId(),
'lead_id' => $activity->getLeadId(),
]);
/**
* An activity may have:
* a) a contact | account | opportunity (or combinations)
* b) only a lead
* c) none of the above
*
* An activity should not have a lead, and another prospect object at the same time.
*
* This logical flow should not happen naturally, but as a fallback: if an activity has both
* a Lead and an Account, the account's WhatId takes precedence in the CRM payload.
* The lead association will be detached locally, but the account WhatId is preserved in Salesforce.
*/
$payload += $this->handleActivityLead($activity);
}
return $payload;
}
private function handleActivityLead(Activity $activity): array
{
$this->logger->info('[Salesforce] Activity sync lead', [
'activity_id' => $activity->getId(),
]);
/**
* Sync lead to pull fresh data. Leads change often,
* they may get 'converted', and we must handle the new state accordingly
*/
try {
$activityLead = $this->syncLead(
$activity->getLead()->getCrmProviderId()
);
} catch (HttpNotFoundException) {
$this->logger->warning('[Salesforce] Activity lead is missing in Salesforce. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not found, maybe it's remotely deleted
*/
$this->resetLeadAssociation($activity);
return [];
}
if ($activityLead === null) {
$this->logger->warning('[Salesforce] Activity lead is missing in local DB. Resetting lead', [
'activity_id' => $activity->getId(),
]);
/**
* Lead is not loaded, for some reason. It may be remotely found, but locally deleted.
* Or an important Lead property may be missing, and it cannot be fully imported.
*/
$this->resetLeadAssociation($activity);
return [];
}
/**
* The lead is not converted, directly use it as WhoId and move on.
*/
if ($activityLead->getConvertedAt() === null) {
return [
'WhoId' => $activity->getLead()->getCrmProviderId(),
'WhatId' => null, // Clears WhatId on the remote record, unless an account WhatId was already set in the payload.
];
}
/**
* Task/Event payload properties for the CRM update
*/
$whoId = null;
$whatId = null;
/**
* Activity payload properties, that need to be updated.
*/
$convertedOpportunityId = null;
$convertedAccountId = null;
$convertedContactId = null;
$value = null;
/**
* If there is converted opportunity, it will update the activity stage.
* If there isn't an opportunity, a converted account/contact cannot have a stage id,
* so the activity shouldn't have a stage either.
*/
$stageId = null;
/**
* The lead is definitely converted.
* This means the lead may be associated with an opportunity, account, or contact.
* The converted lead itself must be detached from the activity,
* while the converted prospect objects must be associated instead,
* since they now represent the state of the deal.
*/
$activity->setLeadId(null);
/**
* CRM property "WhatId" can be either an Opportunity or an Account.
* For us a converted Opportunity has higher priority than an Account.
* An Opportunity carries more concrete data, including a reference to the Account record itself.
*/
if ($activityLead->hasOpportunity()) {
$convertedOpportunity = $activityLead->getOpportunity();
$convertedOpportunityId = $convertedOpportunity->getId();
$convertedAccountId = $convertedOpportunity->getAccountId();
$stageId = $convertedOpportunity->getStageId();
$value = $convertedOpportunity->getValue();
$whatId = $convertedOpportunity->getCrmProviderId();
}
if ($activityLead->hasAccount()) {
$convertedAccount = $activityLead->getAccount();
$convertedAccountId ??= $convertedAccount->getId();
$whatId ??= $convertedAccount->getCrmProviderId();
}
/**
* WhoId can only be a Contact or a Lead.
* Since we are detaching the Lead, it can only be a Contact for the current activity.
* It does not conflict with any other object.
*/
if ($activityLead->hasContact()) {
$convertedContact = $activityLead->getContact();
$convertedContactId = $convertedContact->getId();
$whoId = $convertedContact->getCrmProviderId();
}
$activity->setOpportunityId($convertedOpportunityId);
$activity->setAccountId($convertedAccountId);
$activity->setContactId($convertedContactId);
$activity->setStageId($stageId);
$activity->setValue($value);
$activity->save();
$this->eventDispatcher->dispatch(
new ActivityLeadConverted($activity, $activityLead)
);
$this->logger->info('[Salesforce] Lead is converted', [
'activity_id' => $activity->getId(),
'whoId' => $whoId,
'whatId' => $whatId,
]);
return [
'WhoId' => $whoId,
'WhatId' => $whatId,
];
}
private function saveCrmObject(string $objectType, Activity $activity, array $payload): void
{
/**
* Tasks and events have different payload structures,
* so we need to consider the type of the object we are sending to the CRM
*/
$specificPayload = $objectType === Field::OBJECT_TASK
? $this->payloadBuilder->buildTaskPayload($activity)
: $this->payloadBuilder->buildEventPayload($activity);
$payload = array_merge($payload, $specificPayload);
if ($activity->hasCrmProviderId()) {
$this->logger->info('[Salesforce] Updating crm object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
try {
$this->updateCrmActivity($objectType, $activity, $payload);
} catch (HttpNotFoundException) {
$this->logger->error('[Salesforce] Target crm object is missing in the crm. Resetting crm provider id', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$activity->setCrmProviderId(null);
$activity->save();
}
return;
}
$this->logger->info('[Salesforce] Creating CRM object', [
'activity_id' => $activity->getId(),
'crm_provider_id' => $activity->getCrmProviderId(),
'object_type' => $objectType,
]);
$crmProviderId = $this->createRecord($objectType, $payload);
$activity->setCrmProviderId($crmProviderId);
$activity->save();
}
/**
* @throws HttpNotFoundException
*/
private function updateCrmActivity(string $objectType, Activity $activity, array $payload): void
{
$sfActivity = $this->getRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
fields: ['Description', 'WhoId', 'WhatId']
);
if (! empty($payload['WhoId']) && $sfActivity['WhoId'] !== $payload['WhoId']) {
$this->logger->info('[Salesforce] Updating WhoId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
if (! empty($payload['WhatId']) && $sfActivity['WhatId'] !== $payload['WhatId']) {
$this->logger->info('[Salesforce] Updating WhatId', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
]);
} else {
$payload['WhatId'] = null;
}
}
$payload['Description'] = $this->getActivityDecorator()->mergeDescriptions(
$payload['Description'],
$sfActivity['Description'] ?? null
);
$this->logger->info('[Salesforce] Updating CRM activity data', [
'objectType' => $objectType,
'activityId' => $activity->getUuid(),
'crmActivity' => $sfActivity,
'payload' => $payload,
]);
$this->updateRecord(
objectType: $objectType,
objectId: $activity->getCrmProviderId(),
data: $payload
);
}
protected function getActivityDecorator(): DecorateActivity
{
if ($this->decorateActivity === null) {
$this->decorateActivity = app(DecorateActivity::class);
}
return $this->decorateActivity;
}
private function resetLeadAssociation(Activity $activity): void
{
$activity->setStageId(null);
$activity->setLeadId(null);
$activity->save();
}
}
Execute
Explain Plan
Browse Query History
View Parameters...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45454
|
1628
|
4
|
2026-05-14T14:37:39.512113+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769459512_m2.jpg...
|
PhpStorm
|
faVsco.js – WriteCrmTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preview insackt[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.38Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:36resteraay at 15.3oYesterdav at 13:34Yesterday at 13:34Yesterday at 13.33Yesterdav at 13:32resterday at 15.3Yesterdav at 13:31Yesterday at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29resterday at 13.2oYesterdav at 13:27Yesterday at 13:27Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:24Yesterdav at 13:23Yesterday at 13:22Yesterday at 13.20Yecterdav at 12:10Yesterdav at 13:19Yesterday at 13.10Yesterdav at 13:18Yesterday at 13:17Yesterday at 13:16Yacterdav at 12116Yesterdav at 13:15Yesterday at 13.1Yecterdav at 12:14Yesterday at 13:14Yesterday at 13:13Yoctorday at 12:19Yesterdav at 13:12Yesterday at 13.11Yesterdav at 13:10Yesterdav at 13:09v Size88 K:MPEG-4 movie62 KB71 KB23 Kb9 KE13 KB16 KB17 K:MPEG-4 movieMPEG-4 movieMPEG-4 movieMPE0"4 movie29 KB MPEG-4 movie6 KB12KBMP2G-4 movie9 KBI7 KBOKbMPEG-A movieMPEG"4 movie37 KE10 KBMoeeh movio7 KB8 K:MPEG-4 movieO KRI8 KB72 KBMPEG-1 movieMPEG-4 movie14 KEMPEG-4 movie13 KB9 KBMPEG-4 movie18 KB|MPEG-4 movie12 KPMDEG.A movic16 KBMPEG-4 movie6KE6 KBMPEG-4 movieMPEG-4 movie12 KBMPEG-4 movie23 K:MPEG-4 movieMDEC A movid6KBMPEG-4 movie11 KPMDEG-A movie11 KBMPEG-4 movie20 KB34 KB10 KB7 KB5 KBMPEG-4 movieMDEC.A movialMPEG-4 movie11 KPMDEG-A movia26 KB MPEG-4 movie111 KBMPEG-4 movie102 KВMPSG-A movie88 KB MPEG-4 movie59 KB98 KB07 KpMPEG-4 movieMDEG.A movio66 KB44 KBMPEG-4 movie03 KрMDEG-A movid78 KBMPEG-4 movie50 KB58 K8MPEG-4 movieAl Notes: OffLeaveFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfP Kdf-a,k Ffmiv Tree.sebitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenort 2.csviconfig.vmlIteration run Search HS.postman_collection.json--report(1).csvm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.46 GB availabld• Inu 14 Mаy 1/•3/•34Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
-4836291221105321116
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preview insackt[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.38Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:36resteraay at 15.3oYesterdav at 13:34Yesterday at 13:34Yesterday at 13.33Yesterdav at 13:32resterday at 15.3Yesterdav at 13:31Yesterday at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29resterday at 13.2oYesterdav at 13:27Yesterday at 13:27Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:24Yesterdav at 13:23Yesterday at 13:22Yesterday at 13.20Yecterdav at 12:10Yesterdav at 13:19Yesterday at 13.10Yesterdav at 13:18Yesterday at 13:17Yesterday at 13:16Yacterdav at 12116Yesterdav at 13:15Yesterday at 13.1Yecterdav at 12:14Yesterday at 13:14Yesterday at 13:13Yoctorday at 12:19Yesterdav at 13:12Yesterday at 13.11Yesterdav at 13:10Yesterdav at 13:09v Size88 K:MPEG-4 movie62 KB71 KB23 Kb9 KE13 KB16 KB17 K:MPEG-4 movieMPEG-4 movieMPEG-4 movieMPE0"4 movie29 KB MPEG-4 movie6 KB12KBMP2G-4 movie9 KBI7 KBOKbMPEG-A movieMPEG"4 movie37 KE10 KBMoeeh movio7 KB8 K:MPEG-4 movieO KRI8 KB72 KBMPEG-1 movieMPEG-4 movie14 KEMPEG-4 movie13 KB9 KBMPEG-4 movie18 KB|MPEG-4 movie12 KPMDEG.A movic16 KBMPEG-4 movie6KE6 KBMPEG-4 movieMPEG-4 movie12 KBMPEG-4 movie23 K:MPEG-4 movieMDEC A movid6KBMPEG-4 movie11 KPMDEG-A movie11 KBMPEG-4 movie20 KB34 KB10 KB7 KB5 KBMPEG-4 movieMDEC.A movialMPEG-4 movie11 KPMDEG-A movia26 KB MPEG-4 movie111 KBMPEG-4 movie102 KВMPSG-A movie88 KB MPEG-4 movie59 KB98 KB07 KpMPEG-4 movieMDEG.A movio66 KB44 KBMPEG-4 movie03 KрMDEG-A movid78 KBMPEG-4 movie50 KB58 K8MPEG-4 movieAl Notes: OffLeaveFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfP Kdf-a,k Ffmiv Tree.sebitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenort 2.csviconfig.vmlIteration run Search HS.postman_collection.json--report(1).csvm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.46 GB availabld• Inu 14 Mаy 1/•3/•34Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45452
|
1627
|
4
|
2026-05-14T14:37:39.552341+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769459552_m1.jpg...
|
PhpStorm
|
faVsco.js – WriteCrmTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhl100% <47FV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest8• Thu 14 May 17:37:39* :QProject vAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.php:• JobsPlanhatService.php© AutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.phpProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php X© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php X© DataClient.php© Playbook.php© PipedrivService.php© DecorateActivity.php© PlainTextDecorateActivity.php~/jiminny/app/app/Services/Crm/Hubspot/ServiceTraits/WriteCrmTrait.phpmowoaniController.php=.env.staging18© LocalSearch.php• LocalSearchlnterface.phpE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.phpClient.phpC RemoteSearch.php© Service.php© HubspotPaginationService.php© HandleHubspotRateLimit.php15.04.26 Vasilev24trait LogActivityTraitv C ListenersA6 X1л23.04.26 Vasilev85private function buildSubjectPayload(Activity $activity, Playbook $playbook): array© ConvertLeadActivities.php21.04.26 Vasilev90* in the CRM, then we set the activity type in the payload.© PurgeLookupCache.php21.04.26 Vasilev91* Some activity types may be locally created. They shouldn't be sent to Salesfol 216› D Metadata21.04.26 Vasilev92*> C Migration21.04.26 Vasilevv 0 Pipedrive93* The resulting payload attribute will look like:21.04.26Vasilev94Type=> 'Cold Call'> D OpportunitySyncStrategy21.04.26 Vasilev95*/> ProspectSearchStrategy23.04.26 Vasilev96return [© ApiFields.php23.04.26 Vasilev97/** ActivityFieldID => ActivityType */© Client.php15.04.26 Vasilev98$playbook->getActivityField()->getCrmProviderId() => $activity->getCategoryC.223© FieldDefinitions.php20.04.26 Vasilev99© PipedriveApiClient.php'Subject' => Sthis->getActivityDecorator()->generateTitle(Sactivity),15.04.26 Vasilev1001:• PipedriveApiException.php23.04.26 Vasilev101© Service.php15.04.26 Vasilev102© TokenStorage.php23.04.26 Vasilev103/**v D Salesforce23.04.26 Vasilev104* Building of the title seems very inconsistent• Fields23.04.26 Vasilev105* Subject here will be something like:• OpportunityMatcher23.04.26 Vasilev106*"Local activity type: Activity Title"• OpportunitySyncStrategy23.04.26 Vasilev107*/D ProspectSearchStrategy23.04.26 Vasilev108v • ServiceTraits$subject = Sactivity->getCategory(->getNameO:23.04.26 Vasilev109if (Sactivity->getTitle() |== null) {T BatchSyncTrait.php23.04.26 Vasilev110+ FollowupActivityTrait.php$subject .= ': ' . $activity->getTitle();15.04.26 Vasilev111T LogActivityTrait.php15.04.26 Vasilev112+ RecordManipulationsTrait./23.04.26 Vasilev113return ['Subject' => $subject];T SyncFieldsTrait.php23.04.26 Vasilev114@ Client nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)= custom.log=laravel.logSF [jiminny@localhost]A HS_local [jiminny@localho:W4 console [QAI PROD] X4 console [PROD]A console (EU]DGojiminny v084143 ×4 л215•m_layout_id =2,1661,66799,66217218219id = 33;220221222224id THEN '(own225226227228229230hubspot':-231232233V= 11512582;234W Windsurf Teams98:92 (11 chars)UTF-8Ca 4 spaces...
|
NULL
|
-6973900021411041732
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhl100% <47FV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest8• Thu 14 May 17:37:39* :QProject vAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.php:• JobsPlanhatService.php© AutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.phpProspectSearchStrategyD ServiceTraits© ImportActivityTypes.phpT WriteCrmTrait.php X© DecorateActivity.php© Salesforce/Service.phpT LogActivityTrait.php X© DataClient.php© Playbook.php© PipedrivService.php© DecorateActivity.php© PlainTextDecorateActivity.php~/jiminny/app/app/Services/Crm/Hubspot/ServiceTraits/WriteCrmTrait.phpmowoaniController.php=.env.staging18© LocalSearch.php• LocalSearchlnterface.phpE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.phpClient.phpC RemoteSearch.php© Service.php© HubspotPaginationService.php© HandleHubspotRateLimit.php15.04.26 Vasilev24trait LogActivityTraitv C ListenersA6 X1л23.04.26 Vasilev85private function buildSubjectPayload(Activity $activity, Playbook $playbook): array© ConvertLeadActivities.php21.04.26 Vasilev90* in the CRM, then we set the activity type in the payload.© PurgeLookupCache.php21.04.26 Vasilev91* Some activity types may be locally created. They shouldn't be sent to Salesfol 216› D Metadata21.04.26 Vasilev92*> C Migration21.04.26 Vasilevv 0 Pipedrive93* The resulting payload attribute will look like:21.04.26Vasilev94Type=> 'Cold Call'> D OpportunitySyncStrategy21.04.26 Vasilev95*/> ProspectSearchStrategy23.04.26 Vasilev96return [© ApiFields.php23.04.26 Vasilev97/** ActivityFieldID => ActivityType */© Client.php15.04.26 Vasilev98$playbook->getActivityField()->getCrmProviderId() => $activity->getCategoryC.223© FieldDefinitions.php20.04.26 Vasilev99© PipedriveApiClient.php'Subject' => Sthis->getActivityDecorator()->generateTitle(Sactivity),15.04.26 Vasilev1001:• PipedriveApiException.php23.04.26 Vasilev101© Service.php15.04.26 Vasilev102© TokenStorage.php23.04.26 Vasilev103/**v D Salesforce23.04.26 Vasilev104* Building of the title seems very inconsistent• Fields23.04.26 Vasilev105* Subject here will be something like:• OpportunityMatcher23.04.26 Vasilev106*"Local activity type: Activity Title"• OpportunitySyncStrategy23.04.26 Vasilev107*/D ProspectSearchStrategy23.04.26 Vasilev108v • ServiceTraits$subject = Sactivity->getCategory(->getNameO:23.04.26 Vasilev109if (Sactivity->getTitle() |== null) {T BatchSyncTrait.php23.04.26 Vasilev110+ FollowupActivityTrait.php$subject .= ': ' . $activity->getTitle();15.04.26 Vasilev111T LogActivityTrait.php15.04.26 Vasilev112+ RecordManipulationsTrait./23.04.26 Vasilev113return ['Subject' => $subject];T SyncFieldsTrait.php23.04.26 Vasilev114@ Client nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)= custom.log=laravel.logSF [jiminny@localhost]A HS_local [jiminny@localho:W4 console [QAI PROD] X4 console [PROD]A console (EU]DGojiminny v084143 ×4 л215•m_layout_id =2,1661,66799,66217218219id = 33;220221222224id THEN '(own225226227228229230hubspot':-231232233V= 11512582;234W Windsurf Teams98:92 (11 chars)UTF-8Ca 4 spaces...
|
45450
|
NULL
|
NULL
|
NULL
|
|
45453
|
1627
|
5
|
2026-05-14T14:37:41.144897+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769461144_m1.jpg...
|
PhpStorm
|
faVsco.js – WriteCrmTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
8
6
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot\ServiceTraits;
use Carbon\Carbon;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Field;
use Jiminny\Repositories\Crm\FieldDataRepository;
use Jiminny\Services\Crm\Hubspot\DecorateActivity;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationCategoryV4;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationTypeIdV4;
use SevenShores\Hubspot\Exceptions\BadRequest;
use SevenShores\Hubspot\Http\Response;
use SevenShores\Hubspot\Exceptions\HubspotException;
use Sentry;
trait WriteCrmTrait
{
private const string ACTION_CREATE = 'create';
private const string ACTION_UPDATE = 'update';
private const string ACTION_DELETE = 'delete';
/**
* @inheritdoc
*/
public function saveActivity(Activity $activity): Activity
{
switch ($activity->getCrmType()) {
case Activity::TYPE_CONFERENCE:
$activity = $this->buildConferencePayload($activity);
break;
case Activity::TYPE_SOFTPHONE:
case Activity::TYPE_SOFTPHONE_INBOUND:
$activity = $this->buildSoftphonePayload($activity);
break;
case Activity::TYPE_SMS_INBOUND:
case Activity::TYPE_SMS_OUTBOUND:
$activity = $this->buildTextMessagePayload($activity);
break;
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildConferencePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatStartTime($activity),
'type' => 'MEETING',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'meetingOutcome' => $decorator->convertMeetingOutcome($activity),
'internalMeetingNotes' => $decorator->generateDescription($activity),
];
// Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.
if (! $activity->hasCrmProviderId()) {
if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {
$metadata['startTime'] = $decorator->formatStartTime($activity);
$metadata['endTime'] = $decorator->formatEndTime($activity);
}
$metadata['title'] = $decorator->generateTitle($activity);
}
// For now, this is just a "meetingOutcome" field for some customers.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function fetchCustomFieldData(Activity $activity, string $objectType): array
{
$payload = [];
$fieldDataRepository = app(FieldDataRepository::class);
$fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);
foreach ($fieldData as $data) {
// Add the field and value to the payload.
$payload += [
$data->getField()->getCrmProviderId() => $data->getValue(),
];
}
return $payload;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity
{
if (! $activity->hasCrmProviderId()) {
$this->createActivity($activity, $engagement, $metadata);
return $activity;
}
try {
$oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());
} catch (HubspotException $e) {
$this->logger->warning('[HubSpot] Engagement not found', [
'activity_id' => $activity->getUuid(),
'crm_provider_id' => $activity->getCrmProviderId(),
'exception' => $e->getMessage(),
]);
// potentially here we can log new activity if it is not found
return $activity;
}
$type = $oldEngagement['engagement']['type'] ?? null;
$bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';
$decorator = $this->getDecorateActivity();
if ($type !== 'TASK') {
$oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldDescription
);
$oldAssociations = $oldEngagement['associations'] ?? [];
$this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);
} else {
$oldTaskBody = $oldEngagement['metadata']['body'] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldTaskBody
);
$this->updateTask($activity, $engagement, $metadata);
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateNonTaskActivity(
Activity $activity,
array $engagement,
array $metadata,
array $oldAssociations
): void {
if ($activity->isTypeConference()) {
$this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);
} else {
$this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);
}
$this->updateActivityAssociations($activity, $oldAssociations);
$this->logCrmEngagementManipulation(
self::ACTION_UPDATE,
['crmId' => $activity->getCrmProviderId()],
$metadata,
);
}
private function updateActivityAssociations(Activity $activity, array $oldAssociations): void
{
$currentAssociations = $this->getActivityAssociations($activity);
$associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);
// No changes - exit
if (empty($associationChanges)) {
return;
}
$this->logger->info('[HubSpot] Updating associations', [
'team' => $this->team->getUuid(),
'activity' => $activity->getUuid(),
'associationChanges' => $associationChanges,
]);
$this->updateAssociations($activity, $associationChanges);
}
private function getAssociationDifferences(
Activity $activity,
array $oldAssociations,
array $currentAssociations
): array {
$objects = ['contactIds', 'companyIds', 'dealIds'];
$changes = [];
foreach ($objects as $object) {
$oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);
$currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);
$added = array_diff($currentIds, $oldIds);
$removed = array_diff($oldIds, $currentIds);
$type = match ($object) {
'contactIds' => 'contact',
'companyIds' => 'company',
'dealIds' => 'deal',
};
$shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);
if (! empty($removed) && ! $shouldIncludeRemoved) {
$this->logger->info('[HubSpot] Skipping association removal', [
'team' => $this->team->getUuid(),
'type' => $type,
'oldIds' => $oldIds,
'currentIds' => $currentIds,
'skippedRemovals' => array_values($removed),
]);
}
if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {
$changes[$type] = [
'added' => array_values($added),
'removed' => array_values($removed),
];
}
}
return $changes;
}
/**
* Determines whether removed associations should be synced to HubSpot.
*
* For contacts and companies, we always sync removals (original behavior).
* For deals, we only sync removals when:
* - There are new deals being added (replacement scenario), OR
* - The activity has an account associated (indicating intentional association management)
*
* This prevents accidentally removing deal associations that exist in HubSpot
* but not in Jiminny's database (e.g., deals manually added by users in HubSpot).
*/
private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool
{
// Contacts and companies: always sync removals
if ($type !== 'deal') {
return true;
}
// Deals: sync removals if we're adding new deals (replacement)
if (! empty($added)) {
return true;
}
// Deals: sync removals only if activity has an account (intentional management)
return $activity->hasAccount();
}
private function normalizeIds(array $ids): array
{
$stringIds = array_map('strval', $ids);
$uniqueIds = array_unique($stringIds);
sort($uniqueIds);
return $uniqueIds;
}
private function updateAssociations(Activity $activity, array $associationChanges): void
{
$objectType = $activity->isTypeConference() ? 'meeting' : 'call';
foreach ($associationChanges as $type => $changes) {
if (! empty($changes['added'])) {
$associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);
$payload = $this->payloadBuilder->buildAddAssociationPayload(
$activity->getCrmProviderId(),
$changes['added'],
$associationType
);
$this->getClient()->addAssociations($objectType, $type, $payload);
}
if (! empty($changes['removed'])) {
$payload = $this->payloadBuilder->buildRemoveAssociationPayload(
$activity->getCrmProviderId(),
$changes['removed']
);
$this->getClient()->removeAssociations($objectType, $type, $payload);
}
}
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response
{
// If already set by us/client, do not override it
if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {
$this->logger->info('[HubSpot] Meeting activity type already set', [
'meetingId' => $meetingId,
'activityType' => $engagement['activityType'],
]);
unset($engagement['activityType']);
}
$payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);
return $this->getClient()->updateMeeting($meetingId, $payload);
}
private function hasEngagementActivityType(string $engagementId): bool
{
try {
$engagementData = $this->getClient()->getEngagementData($engagementId);
if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {
return true;
}
return false;
} catch (\Exception $exception) {
Sentry::captureException($exception);
$this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [
'engagementId' => $engagementId,
'exception' => $exception->getMessage(),
]);
}
return true;
}
private function updateTask(Activity $activity, array $engagement, array $metadata): void
{
$this->getClient()->deleteEngagement($activity->getCrmProviderId());
$this->logCrmEngagementManipulation(
self::ACTION_DELETE,
['crmId' => $activity->getCrmProviderId()],
);
$this->createActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createActivity(Activity $activity, array $engagement, array $metadata): void
{
$associations = $this->getActivityAssociations($activity);
$associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);
if ($activity->isTypeConference()) {
try {
$hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);
$activityId = $hsEngagement->data->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
} else {
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
$activityId = $hsEngagement->data->engagement->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
}
}
private function convertActivityMeetingAssociationsV4(Activity $activity): array
{
$associations = [];
$contactIds = $this->getParticipantsIds($activity);
foreach ($contactIds as $contactId) {
$associations[] = $this->buildAssociation(
(int) $contactId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]
);
}
if ($activity->hasAccount()) {
$crmProviderId = $activity->getAccount()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]
);
}
}
if ($activity->hasOpportunity()) {
$crmProviderId = $activity->getOpportunity()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]
);
}
}
return $associations;
}
private function buildAssociation(int $id, array $categoryToTypeIds): array
{
$types = [];
foreach ($categoryToTypeIds as $category => $typeId) {
$types[] = $this->buildAssociationType($category, $typeId);
}
return [
'to' => ['id' => (string) $id],
'types' => $types,
];
}
private function buildAssociationType(string $category, int $typeId): array
{
return [
'associationCategory' => $category,
'associationTypeId' => $typeId,
];
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createMeetingV3(array $engagement, array $associations, array $metadata): Response
{
$payload = $this->payloadBuilder->getV3MeetingPayload(
engagement: $engagement,
metadata: $metadata,
associations: $associations
);
return $this->getClient()->createMeeting($payload);
}
/**
* @throws BadRequest
* @throws HubspotException
*/
private function buildSoftphonePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'CALL',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'toNumber' => $decorator->formatCallToParticipant($activity),
'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),
'status' => $decorator->convertCallStatus($activity),
'durationMilliseconds' => (int) $activity->getDuration() * 1000,
'body' => $decorator->generateDescription($activity),
];
// For now, this is just a "disposition" field to store Call Outcome.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildTextMessagePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'NOTE',
];
$metadata = [
'body' => $decorator->generateDescription($activity),
];
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function getActivityAssociations(Activity $activity): array
{
return [
'contactIds' => $this->getParticipantsIds($activity),
'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],
'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],
'ownerIds' => [],
];
}
/**
* Get DecorateActivity instance. Can be overridden in tests for mocking.
*/
protected function getDecorateActivity(): DecorateActivity
{
return new DecorateActivity();
}
public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
if (empty($fields['subject'])) {
return null;
}
$associations = $this->getActivityAssociations($activity);
if (empty($fields['timestamp']) === false) {
$formatTimestamp = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['timestamp']);
$timestamp = $formatTimestamp->getTimestamp();
} else {
$timestamp = strtotime('+1 day');
}
$reminder = null;
if (empty($fields['reminder']) === false) {
$formatReminder = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['reminder']);
$reminder = $formatReminder->getTimestamp() * 1000;
}
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $timestamp * 1000,
'type' => 'TASK',
];
$metadata = [
'subject' => $fields['subject'],
'body' => '',
'status' => 'NOT_STARTED',
'taskType' => 'CALL',
'reminders' => $reminder ? [$reminder] : [],
];
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
} catch (BadRequest $e) {
$this->logger->info('[HubSpot] Failed to create followup task', [
'activity' => $activity->getUuid(),
'engagement' => $engagement,
'metadata' => $metadata,
'error' => $e->getMessage(),
]);
return null;
}
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
// We don't actually create a corresponding activity object on our side yet.
return (string) $hsEngagement->data->engagement->id;
}
private function logCrmEngagementManipulation(
string $action,
array $engagementData,
array $data = [],
array $associations = [],
): void {
$payload = ['team' => $this->team->getUuid()];
if ($action === self::ACTION_CREATE) {
$payload['engagementData'] = $engagementData;
$payload['data'] = $data;
$payload['associations'] = $associations;
}
if ($action === self::ACTION_UPDATE) {
$payload['engagementId'] = $engagementData['crmId'];
$payload['data'] = $data;
}
if ($action === self::ACTION_DELETE) {
$payload['engagementId'] = $engagementData['crmId'];
}
$this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"bounds":{"left":0.78055555,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.80138886,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot\\ServiceTraits;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Repositories\\Crm\\FieldDataRepository;\nuse Jiminny\\Services\\Crm\\Hubspot\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationCategoryV4;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationTypeIdV4;\nuse SevenShores\\Hubspot\\Exceptions\\BadRequest;\nuse SevenShores\\Hubspot\\Http\\Response;\nuse SevenShores\\Hubspot\\Exceptions\\HubspotException;\nuse Sentry;\n\ntrait WriteCrmTrait\n{\n private const string ACTION_CREATE = 'create';\n private const string ACTION_UPDATE = 'update';\n private const string ACTION_DELETE = 'delete';\n\n /**\n * @inheritdoc\n */\n public function saveActivity(Activity $activity): Activity\n {\n switch ($activity->getCrmType()) {\n case Activity::TYPE_CONFERENCE:\n $activity = $this->buildConferencePayload($activity);\n\n break;\n case Activity::TYPE_SOFTPHONE:\n case Activity::TYPE_SOFTPHONE_INBOUND:\n $activity = $this->buildSoftphonePayload($activity);\n\n break;\n\n case Activity::TYPE_SMS_INBOUND:\n case Activity::TYPE_SMS_OUTBOUND:\n $activity = $this->buildTextMessagePayload($activity);\n\n break;\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildConferencePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatStartTime($activity),\n 'type' => 'MEETING',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'meetingOutcome' => $decorator->convertMeetingOutcome($activity),\n 'internalMeetingNotes' => $decorator->generateDescription($activity),\n ];\n\n // Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.\n if (! $activity->hasCrmProviderId()) {\n if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {\n $metadata['startTime'] = $decorator->formatStartTime($activity);\n $metadata['endTime'] = $decorator->formatEndTime($activity);\n }\n $metadata['title'] = $decorator->generateTitle($activity);\n }\n\n // For now, this is just a \"meetingOutcome\" field for some customers.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function fetchCustomFieldData(Activity $activity, string $objectType): array\n {\n $payload = [];\n\n $fieldDataRepository = app(FieldDataRepository::class);\n $fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);\n\n foreach ($fieldData as $data) {\n // Add the field and value to the payload.\n $payload += [\n $data->getField()->getCrmProviderId() => $data->getValue(),\n ];\n }\n\n return $payload;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity\n {\n if (! $activity->hasCrmProviderId()) {\n $this->createActivity($activity, $engagement, $metadata);\n\n return $activity;\n }\n\n try {\n $oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());\n } catch (HubspotException $e) {\n $this->logger->warning('[HubSpot] Engagement not found', [\n 'activity_id' => $activity->getUuid(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'exception' => $e->getMessage(),\n ]);\n\n // potentially here we can log new activity if it is not found\n\n return $activity;\n }\n\n $type = $oldEngagement['engagement']['type'] ?? null;\n $bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';\n\n $decorator = $this->getDecorateActivity();\n\n if ($type !== 'TASK') {\n $oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldDescription\n );\n\n $oldAssociations = $oldEngagement['associations'] ?? [];\n $this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);\n } else {\n $oldTaskBody = $oldEngagement['metadata']['body'] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldTaskBody\n );\n $this->updateTask($activity, $engagement, $metadata);\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateNonTaskActivity(\n Activity $activity,\n array $engagement,\n array $metadata,\n array $oldAssociations\n ): void {\n if ($activity->isTypeConference()) {\n $this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);\n } else {\n $this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);\n }\n\n $this->updateActivityAssociations($activity, $oldAssociations);\n\n $this->logCrmEngagementManipulation(\n self::ACTION_UPDATE,\n ['crmId' => $activity->getCrmProviderId()],\n $metadata,\n );\n }\n\n private function updateActivityAssociations(Activity $activity, array $oldAssociations): void\n {\n $currentAssociations = $this->getActivityAssociations($activity);\n $associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);\n\n // No changes - exit\n if (empty($associationChanges)) {\n return;\n }\n\n $this->logger->info('[HubSpot] Updating associations', [\n 'team' => $this->team->getUuid(),\n 'activity' => $activity->getUuid(),\n 'associationChanges' => $associationChanges,\n ]);\n\n $this->updateAssociations($activity, $associationChanges);\n }\n\n private function getAssociationDifferences(\n Activity $activity,\n array $oldAssociations,\n array $currentAssociations\n ): array {\n $objects = ['contactIds', 'companyIds', 'dealIds'];\n $changes = [];\n\n foreach ($objects as $object) {\n $oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);\n $currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);\n\n $added = array_diff($currentIds, $oldIds);\n $removed = array_diff($oldIds, $currentIds);\n\n $type = match ($object) {\n 'contactIds' => 'contact',\n 'companyIds' => 'company',\n 'dealIds' => 'deal',\n };\n\n $shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);\n\n if (! empty($removed) && ! $shouldIncludeRemoved) {\n $this->logger->info('[HubSpot] Skipping association removal', [\n 'team' => $this->team->getUuid(),\n 'type' => $type,\n 'oldIds' => $oldIds,\n 'currentIds' => $currentIds,\n 'skippedRemovals' => array_values($removed),\n ]);\n }\n\n if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {\n $changes[$type] = [\n 'added' => array_values($added),\n 'removed' => array_values($removed),\n ];\n }\n }\n\n return $changes;\n }\n\n /**\n * Determines whether removed associations should be synced to HubSpot.\n *\n * For contacts and companies, we always sync removals (original behavior).\n * For deals, we only sync removals when:\n * - There are new deals being added (replacement scenario), OR\n * - The activity has an account associated (indicating intentional association management)\n *\n * This prevents accidentally removing deal associations that exist in HubSpot\n * but not in Jiminny's database (e.g., deals manually added by users in HubSpot).\n */\n private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool\n {\n // Contacts and companies: always sync removals\n if ($type !== 'deal') {\n return true;\n }\n\n // Deals: sync removals if we're adding new deals (replacement)\n if (! empty($added)) {\n return true;\n }\n\n // Deals: sync removals only if activity has an account (intentional management)\n return $activity->hasAccount();\n }\n\n private function normalizeIds(array $ids): array\n {\n $stringIds = array_map('strval', $ids);\n $uniqueIds = array_unique($stringIds);\n sort($uniqueIds);\n\n return $uniqueIds;\n }\n\n private function updateAssociations(Activity $activity, array $associationChanges): void\n {\n $objectType = $activity->isTypeConference() ? 'meeting' : 'call';\n\n foreach ($associationChanges as $type => $changes) {\n if (! empty($changes['added'])) {\n $associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);\n $payload = $this->payloadBuilder->buildAddAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['added'],\n $associationType\n );\n $this->getClient()->addAssociations($objectType, $type, $payload);\n }\n\n if (! empty($changes['removed'])) {\n $payload = $this->payloadBuilder->buildRemoveAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['removed']\n );\n $this->getClient()->removeAssociations($objectType, $type, $payload);\n }\n }\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response\n {\n // If already set by us/client, do not override it\n if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {\n $this->logger->info('[HubSpot] Meeting activity type already set', [\n 'meetingId' => $meetingId,\n 'activityType' => $engagement['activityType'],\n ]);\n\n unset($engagement['activityType']);\n }\n\n $payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);\n\n return $this->getClient()->updateMeeting($meetingId, $payload);\n }\n\n private function hasEngagementActivityType(string $engagementId): bool\n {\n try {\n $engagementData = $this->getClient()->getEngagementData($engagementId);\n if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {\n return true;\n }\n\n return false;\n } catch (\\Exception $exception) {\n Sentry::captureException($exception);\n\n $this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [\n 'engagementId' => $engagementId,\n 'exception' => $exception->getMessage(),\n ]);\n }\n\n return true;\n }\n\n private function updateTask(Activity $activity, array $engagement, array $metadata): void\n {\n $this->getClient()->deleteEngagement($activity->getCrmProviderId());\n\n $this->logCrmEngagementManipulation(\n self::ACTION_DELETE,\n ['crmId' => $activity->getCrmProviderId()],\n );\n\n $this->createActivity($activity, $engagement, $metadata);\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createActivity(Activity $activity, array $engagement, array $metadata): void\n {\n $associations = $this->getActivityAssociations($activity);\n $associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);\n\n if ($activity->isTypeConference()) {\n try {\n $hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);\n $activityId = $hsEngagement->data->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n } else {\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n $activityId = $hsEngagement->data->engagement->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n }\n }\n\n private function convertActivityMeetingAssociationsV4(Activity $activity): array\n {\n $associations = [];\n\n $contactIds = $this->getParticipantsIds($activity);\n\n foreach ($contactIds as $contactId) {\n $associations[] = $this->buildAssociation(\n (int) $contactId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]\n );\n }\n\n if ($activity->hasAccount()) {\n $crmProviderId = $activity->getAccount()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]\n );\n }\n }\n\n if ($activity->hasOpportunity()) {\n $crmProviderId = $activity->getOpportunity()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]\n );\n }\n }\n\n return $associations;\n }\n\n private function buildAssociation(int $id, array $categoryToTypeIds): array\n {\n $types = [];\n\n foreach ($categoryToTypeIds as $category => $typeId) {\n $types[] = $this->buildAssociationType($category, $typeId);\n }\n\n return [\n 'to' => ['id' => (string) $id],\n 'types' => $types,\n ];\n }\n\n private function buildAssociationType(string $category, int $typeId): array\n {\n return [\n 'associationCategory' => $category,\n 'associationTypeId' => $typeId,\n ];\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createMeetingV3(array $engagement, array $associations, array $metadata): Response\n {\n $payload = $this->payloadBuilder->getV3MeetingPayload(\n engagement: $engagement,\n metadata: $metadata,\n associations: $associations\n );\n\n return $this->getClient()->createMeeting($payload);\n }\n\n /**\n * @throws BadRequest\n * @throws HubspotException\n */\n private function buildSoftphonePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'CALL',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'toNumber' => $decorator->formatCallToParticipant($activity),\n 'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),\n 'status' => $decorator->convertCallStatus($activity),\n 'durationMilliseconds' => (int) $activity->getDuration() * 1000,\n 'body' => $decorator->generateDescription($activity),\n ];\n\n // For now, this is just a \"disposition\" field to store Call Outcome.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildTextMessagePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'NOTE',\n ];\n\n $metadata = [\n 'body' => $decorator->generateDescription($activity),\n ];\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function getActivityAssociations(Activity $activity): array\n {\n return [\n 'contactIds' => $this->getParticipantsIds($activity),\n 'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],\n 'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],\n 'ownerIds' => [],\n ];\n }\n\n /**\n * Get DecorateActivity instance. Can be overridden in tests for mocking.\n */\n protected function getDecorateActivity(): DecorateActivity\n {\n return new DecorateActivity();\n }\n\n public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n if (empty($fields['subject'])) {\n return null;\n }\n\n $associations = $this->getActivityAssociations($activity);\n\n if (empty($fields['timestamp']) === false) {\n $formatTimestamp = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['timestamp']);\n $timestamp = $formatTimestamp->getTimestamp();\n } else {\n $timestamp = strtotime('+1 day');\n }\n\n $reminder = null;\n if (empty($fields['reminder']) === false) {\n $formatReminder = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['reminder']);\n $reminder = $formatReminder->getTimestamp() * 1000;\n }\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $timestamp * 1000,\n 'type' => 'TASK',\n ];\n\n $metadata = [\n 'subject' => $fields['subject'],\n 'body' => '',\n 'status' => 'NOT_STARTED',\n 'taskType' => 'CALL',\n 'reminders' => $reminder ? [$reminder] : [],\n ];\n\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n } catch (BadRequest $e) {\n $this->logger->info('[HubSpot] Failed to create followup task', [\n 'activity' => $activity->getUuid(),\n 'engagement' => $engagement,\n 'metadata' => $metadata,\n 'error' => $e->getMessage(),\n ]);\n\n return null;\n }\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n // We don't actually create a corresponding activity object on our side yet.\n return (string) $hsEngagement->data->engagement->id;\n }\n\n private function logCrmEngagementManipulation(\n string $action,\n array $engagementData,\n array $data = [],\n array $associations = [],\n ): void {\n $payload = ['team' => $this->team->getUuid()];\n\n if ($action === self::ACTION_CREATE) {\n $payload['engagementData'] = $engagementData;\n $payload['data'] = $data;\n $payload['associations'] = $associations;\n }\n\n if ($action === self::ACTION_UPDATE) {\n $payload['engagementId'] = $engagementData['crmId'];\n $payload['data'] = $data;\n }\n\n if ($action === self::ACTION_DELETE) {\n $payload['engagementId'] = $engagementData['crmId'];\n }\n\n $this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot\\ServiceTraits;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Repositories\\Crm\\FieldDataRepository;\nuse Jiminny\\Services\\Crm\\Hubspot\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationCategoryV4;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationTypeIdV4;\nuse SevenShores\\Hubspot\\Exceptions\\BadRequest;\nuse SevenShores\\Hubspot\\Http\\Response;\nuse SevenShores\\Hubspot\\Exceptions\\HubspotException;\nuse Sentry;\n\ntrait WriteCrmTrait\n{\n private const string ACTION_CREATE = 'create';\n private const string ACTION_UPDATE = 'update';\n private const string ACTION_DELETE = 'delete';\n\n /**\n * @inheritdoc\n */\n public function saveActivity(Activity $activity): Activity\n {\n switch ($activity->getCrmType()) {\n case Activity::TYPE_CONFERENCE:\n $activity = $this->buildConferencePayload($activity);\n\n break;\n case Activity::TYPE_SOFTPHONE:\n case Activity::TYPE_SOFTPHONE_INBOUND:\n $activity = $this->buildSoftphonePayload($activity);\n\n break;\n\n case Activity::TYPE_SMS_INBOUND:\n case Activity::TYPE_SMS_OUTBOUND:\n $activity = $this->buildTextMessagePayload($activity);\n\n break;\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildConferencePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatStartTime($activity),\n 'type' => 'MEETING',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'meetingOutcome' => $decorator->convertMeetingOutcome($activity),\n 'internalMeetingNotes' => $decorator->generateDescription($activity),\n ];\n\n // Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.\n if (! $activity->hasCrmProviderId()) {\n if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {\n $metadata['startTime'] = $decorator->formatStartTime($activity);\n $metadata['endTime'] = $decorator->formatEndTime($activity);\n }\n $metadata['title'] = $decorator->generateTitle($activity);\n }\n\n // For now, this is just a \"meetingOutcome\" field for some customers.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function fetchCustomFieldData(Activity $activity, string $objectType): array\n {\n $payload = [];\n\n $fieldDataRepository = app(FieldDataRepository::class);\n $fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);\n\n foreach ($fieldData as $data) {\n // Add the field and value to the payload.\n $payload += [\n $data->getField()->getCrmProviderId() => $data->getValue(),\n ];\n }\n\n return $payload;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity\n {\n if (! $activity->hasCrmProviderId()) {\n $this->createActivity($activity, $engagement, $metadata);\n\n return $activity;\n }\n\n try {\n $oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());\n } catch (HubspotException $e) {\n $this->logger->warning('[HubSpot] Engagement not found', [\n 'activity_id' => $activity->getUuid(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'exception' => $e->getMessage(),\n ]);\n\n // potentially here we can log new activity if it is not found\n\n return $activity;\n }\n\n $type = $oldEngagement['engagement']['type'] ?? null;\n $bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';\n\n $decorator = $this->getDecorateActivity();\n\n if ($type !== 'TASK') {\n $oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldDescription\n );\n\n $oldAssociations = $oldEngagement['associations'] ?? [];\n $this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);\n } else {\n $oldTaskBody = $oldEngagement['metadata']['body'] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldTaskBody\n );\n $this->updateTask($activity, $engagement, $metadata);\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateNonTaskActivity(\n Activity $activity,\n array $engagement,\n array $metadata,\n array $oldAssociations\n ): void {\n if ($activity->isTypeConference()) {\n $this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);\n } else {\n $this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);\n }\n\n $this->updateActivityAssociations($activity, $oldAssociations);\n\n $this->logCrmEngagementManipulation(\n self::ACTION_UPDATE,\n ['crmId' => $activity->getCrmProviderId()],\n $metadata,\n );\n }\n\n private function updateActivityAssociations(Activity $activity, array $oldAssociations): void\n {\n $currentAssociations = $this->getActivityAssociations($activity);\n $associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);\n\n // No changes - exit\n if (empty($associationChanges)) {\n return;\n }\n\n $this->logger->info('[HubSpot] Updating associations', [\n 'team' => $this->team->getUuid(),\n 'activity' => $activity->getUuid(),\n 'associationChanges' => $associationChanges,\n ]);\n\n $this->updateAssociations($activity, $associationChanges);\n }\n\n private function getAssociationDifferences(\n Activity $activity,\n array $oldAssociations,\n array $currentAssociations\n ): array {\n $objects = ['contactIds', 'companyIds', 'dealIds'];\n $changes = [];\n\n foreach ($objects as $object) {\n $oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);\n $currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);\n\n $added = array_diff($currentIds, $oldIds);\n $removed = array_diff($oldIds, $currentIds);\n\n $type = match ($object) {\n 'contactIds' => 'contact',\n 'companyIds' => 'company',\n 'dealIds' => 'deal',\n };\n\n $shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);\n\n if (! empty($removed) && ! $shouldIncludeRemoved) {\n $this->logger->info('[HubSpot] Skipping association removal', [\n 'team' => $this->team->getUuid(),\n 'type' => $type,\n 'oldIds' => $oldIds,\n 'currentIds' => $currentIds,\n 'skippedRemovals' => array_values($removed),\n ]);\n }\n\n if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {\n $changes[$type] = [\n 'added' => array_values($added),\n 'removed' => array_values($removed),\n ];\n }\n }\n\n return $changes;\n }\n\n /**\n * Determines whether removed associations should be synced to HubSpot.\n *\n * For contacts and companies, we always sync removals (original behavior).\n * For deals, we only sync removals when:\n * - There are new deals being added (replacement scenario), OR\n * - The activity has an account associated (indicating intentional association management)\n *\n * This prevents accidentally removing deal associations that exist in HubSpot\n * but not in Jiminny's database (e.g., deals manually added by users in HubSpot).\n */\n private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool\n {\n // Contacts and companies: always sync removals\n if ($type !== 'deal') {\n return true;\n }\n\n // Deals: sync removals if we're adding new deals (replacement)\n if (! empty($added)) {\n return true;\n }\n\n // Deals: sync removals only if activity has an account (intentional management)\n return $activity->hasAccount();\n }\n\n private function normalizeIds(array $ids): array\n {\n $stringIds = array_map('strval', $ids);\n $uniqueIds = array_unique($stringIds);\n sort($uniqueIds);\n\n return $uniqueIds;\n }\n\n private function updateAssociations(Activity $activity, array $associationChanges): void\n {\n $objectType = $activity->isTypeConference() ? 'meeting' : 'call';\n\n foreach ($associationChanges as $type => $changes) {\n if (! empty($changes['added'])) {\n $associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);\n $payload = $this->payloadBuilder->buildAddAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['added'],\n $associationType\n );\n $this->getClient()->addAssociations($objectType, $type, $payload);\n }\n\n if (! empty($changes['removed'])) {\n $payload = $this->payloadBuilder->buildRemoveAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['removed']\n );\n $this->getClient()->removeAssociations($objectType, $type, $payload);\n }\n }\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response\n {\n // If already set by us/client, do not override it\n if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {\n $this->logger->info('[HubSpot] Meeting activity type already set', [\n 'meetingId' => $meetingId,\n 'activityType' => $engagement['activityType'],\n ]);\n\n unset($engagement['activityType']);\n }\n\n $payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);\n\n return $this->getClient()->updateMeeting($meetingId, $payload);\n }\n\n private function hasEngagementActivityType(string $engagementId): bool\n {\n try {\n $engagementData = $this->getClient()->getEngagementData($engagementId);\n if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {\n return true;\n }\n\n return false;\n } catch (\\Exception $exception) {\n Sentry::captureException($exception);\n\n $this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [\n 'engagementId' => $engagementId,\n 'exception' => $exception->getMessage(),\n ]);\n }\n\n return true;\n }\n\n private function updateTask(Activity $activity, array $engagement, array $metadata): void\n {\n $this->getClient()->deleteEngagement($activity->getCrmProviderId());\n\n $this->logCrmEngagementManipulation(\n self::ACTION_DELETE,\n ['crmId' => $activity->getCrmProviderId()],\n );\n\n $this->createActivity($activity, $engagement, $metadata);\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createActivity(Activity $activity, array $engagement, array $metadata): void\n {\n $associations = $this->getActivityAssociations($activity);\n $associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);\n\n if ($activity->isTypeConference()) {\n try {\n $hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);\n $activityId = $hsEngagement->data->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n } else {\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n $activityId = $hsEngagement->data->engagement->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n }\n }\n\n private function convertActivityMeetingAssociationsV4(Activity $activity): array\n {\n $associations = [];\n\n $contactIds = $this->getParticipantsIds($activity);\n\n foreach ($contactIds as $contactId) {\n $associations[] = $this->buildAssociation(\n (int) $contactId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]\n );\n }\n\n if ($activity->hasAccount()) {\n $crmProviderId = $activity->getAccount()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]\n );\n }\n }\n\n if ($activity->hasOpportunity()) {\n $crmProviderId = $activity->getOpportunity()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]\n );\n }\n }\n\n return $associations;\n }\n\n private function buildAssociation(int $id, array $categoryToTypeIds): array\n {\n $types = [];\n\n foreach ($categoryToTypeIds as $category => $typeId) {\n $types[] = $this->buildAssociationType($category, $typeId);\n }\n\n return [\n 'to' => ['id' => (string) $id],\n 'types' => $types,\n ];\n }\n\n private function buildAssociationType(string $category, int $typeId): array\n {\n return [\n 'associationCategory' => $category,\n 'associationTypeId' => $typeId,\n ];\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createMeetingV3(array $engagement, array $associations, array $metadata): Response\n {\n $payload = $this->payloadBuilder->getV3MeetingPayload(\n engagement: $engagement,\n metadata: $metadata,\n associations: $associations\n );\n\n return $this->getClient()->createMeeting($payload);\n }\n\n /**\n * @throws BadRequest\n * @throws HubspotException\n */\n private function buildSoftphonePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'CALL',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'toNumber' => $decorator->formatCallToParticipant($activity),\n 'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),\n 'status' => $decorator->convertCallStatus($activity),\n 'durationMilliseconds' => (int) $activity->getDuration() * 1000,\n 'body' => $decorator->generateDescription($activity),\n ];\n\n // For now, this is just a \"disposition\" field to store Call Outcome.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildTextMessagePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'NOTE',\n ];\n\n $metadata = [\n 'body' => $decorator->generateDescription($activity),\n ];\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function getActivityAssociations(Activity $activity): array\n {\n return [\n 'contactIds' => $this->getParticipantsIds($activity),\n 'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],\n 'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],\n 'ownerIds' => [],\n ];\n }\n\n /**\n * Get DecorateActivity instance. Can be overridden in tests for mocking.\n */\n protected function getDecorateActivity(): DecorateActivity\n {\n return new DecorateActivity();\n }\n\n public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n if (empty($fields['subject'])) {\n return null;\n }\n\n $associations = $this->getActivityAssociations($activity);\n\n if (empty($fields['timestamp']) === false) {\n $formatTimestamp = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['timestamp']);\n $timestamp = $formatTimestamp->getTimestamp();\n } else {\n $timestamp = strtotime('+1 day');\n }\n\n $reminder = null;\n if (empty($fields['reminder']) === false) {\n $formatReminder = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['reminder']);\n $reminder = $formatReminder->getTimestamp() * 1000;\n }\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $timestamp * 1000,\n 'type' => 'TASK',\n ];\n\n $metadata = [\n 'subject' => $fields['subject'],\n 'body' => '',\n 'status' => 'NOT_STARTED',\n 'taskType' => 'CALL',\n 'reminders' => $reminder ? [$reminder] : [],\n ];\n\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n } catch (BadRequest $e) {\n $this->logger->info('[HubSpot] Failed to create followup task', [\n 'activity' => $activity->getUuid(),\n 'engagement' => $engagement,\n 'metadata' => $metadata,\n 'error' => $e->getMessage(),\n ]);\n\n return null;\n }\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n // We don't actually create a corresponding activity object on our side yet.\n return (string) $hsEngagement->data->engagement->id;\n }\n\n private function logCrmEngagementManipulation(\n string $action,\n array $engagementData,\n array $data = [],\n array $associations = [],\n ): void {\n $payload = ['team' => $this->team->getUuid()];\n\n if ($action === self::ACTION_CREATE) {\n $payload['engagementData'] = $engagementData;\n $payload['data'] = $data;\n $payload['associations'] = $associations;\n }\n\n if ($action === self::ACTION_UPDATE) {\n $payload['engagementId'] = $engagementData['crmId'];\n $payload['data'] = $data;\n }\n\n if ($action === self::ACTION_DELETE) {\n $payload['engagementId'] = $engagementData['crmId'];\n }\n\n $this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"bounds":{"left":0.8645833,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.8854167,"top":0.34444445,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"bounds":{"left":0.9048611,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.92569447,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.9458333,"top":0.3422222,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.9611111,"top":0.3422222,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.025,"top":0.06666667,"width":0.050694443,"height":0.034444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
3382584868951134281
|
6551498163460912845
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
8
6
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot\ServiceTraits;
use Carbon\Carbon;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Field;
use Jiminny\Repositories\Crm\FieldDataRepository;
use Jiminny\Services\Crm\Hubspot\DecorateActivity;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationCategoryV4;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationTypeIdV4;
use SevenShores\Hubspot\Exceptions\BadRequest;
use SevenShores\Hubspot\Http\Response;
use SevenShores\Hubspot\Exceptions\HubspotException;
use Sentry;
trait WriteCrmTrait
{
private const string ACTION_CREATE = 'create';
private const string ACTION_UPDATE = 'update';
private const string ACTION_DELETE = 'delete';
/**
* @inheritdoc
*/
public function saveActivity(Activity $activity): Activity
{
switch ($activity->getCrmType()) {
case Activity::TYPE_CONFERENCE:
$activity = $this->buildConferencePayload($activity);
break;
case Activity::TYPE_SOFTPHONE:
case Activity::TYPE_SOFTPHONE_INBOUND:
$activity = $this->buildSoftphonePayload($activity);
break;
case Activity::TYPE_SMS_INBOUND:
case Activity::TYPE_SMS_OUTBOUND:
$activity = $this->buildTextMessagePayload($activity);
break;
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildConferencePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatStartTime($activity),
'type' => 'MEETING',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'meetingOutcome' => $decorator->convertMeetingOutcome($activity),
'internalMeetingNotes' => $decorator->generateDescription($activity),
];
// Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.
if (! $activity->hasCrmProviderId()) {
if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {
$metadata['startTime'] = $decorator->formatStartTime($activity);
$metadata['endTime'] = $decorator->formatEndTime($activity);
}
$metadata['title'] = $decorator->generateTitle($activity);
}
// For now, this is just a "meetingOutcome" field for some customers.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function fetchCustomFieldData(Activity $activity, string $objectType): array
{
$payload = [];
$fieldDataRepository = app(FieldDataRepository::class);
$fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);
foreach ($fieldData as $data) {
// Add the field and value to the payload.
$payload += [
$data->getField()->getCrmProviderId() => $data->getValue(),
];
}
return $payload;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity
{
if (! $activity->hasCrmProviderId()) {
$this->createActivity($activity, $engagement, $metadata);
return $activity;
}
try {
$oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());
} catch (HubspotException $e) {
$this->logger->warning('[HubSpot] Engagement not found', [
'activity_id' => $activity->getUuid(),
'crm_provider_id' => $activity->getCrmProviderId(),
'exception' => $e->getMessage(),
]);
// potentially here we can log new activity if it is not found
return $activity;
}
$type = $oldEngagement['engagement']['type'] ?? null;
$bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';
$decorator = $this->getDecorateActivity();
if ($type !== 'TASK') {
$oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldDescription
);
$oldAssociations = $oldEngagement['associations'] ?? [];
$this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);
} else {
$oldTaskBody = $oldEngagement['metadata']['body'] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldTaskBody
);
$this->updateTask($activity, $engagement, $metadata);
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateNonTaskActivity(
Activity $activity,
array $engagement,
array $metadata,
array $oldAssociations
): void {
if ($activity->isTypeConference()) {
$this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);
} else {
$this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);
}
$this->updateActivityAssociations($activity, $oldAssociations);
$this->logCrmEngagementManipulation(
self::ACTION_UPDATE,
['crmId' => $activity->getCrmProviderId()],
$metadata,
);
}
private function updateActivityAssociations(Activity $activity, array $oldAssociations): void
{
$currentAssociations = $this->getActivityAssociations($activity);
$associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);
// No changes - exit
if (empty($associationChanges)) {
return;
}
$this->logger->info('[HubSpot] Updating associations', [
'team' => $this->team->getUuid(),
'activity' => $activity->getUuid(),
'associationChanges' => $associationChanges,
]);
$this->updateAssociations($activity, $associationChanges);
}
private function getAssociationDifferences(
Activity $activity,
array $oldAssociations,
array $currentAssociations
): array {
$objects = ['contactIds', 'companyIds', 'dealIds'];
$changes = [];
foreach ($objects as $object) {
$oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);
$currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);
$added = array_diff($currentIds, $oldIds);
$removed = array_diff($oldIds, $currentIds);
$type = match ($object) {
'contactIds' => 'contact',
'companyIds' => 'company',
'dealIds' => 'deal',
};
$shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);
if (! empty($removed) && ! $shouldIncludeRemoved) {
$this->logger->info('[HubSpot] Skipping association removal', [
'team' => $this->team->getUuid(),
'type' => $type,
'oldIds' => $oldIds,
'currentIds' => $currentIds,
'skippedRemovals' => array_values($removed),
]);
}
if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {
$changes[$type] = [
'added' => array_values($added),
'removed' => array_values($removed),
];
}
}
return $changes;
}
/**
* Determines whether removed associations should be synced to HubSpot.
*
* For contacts and companies, we always sync removals (original behavior).
* For deals, we only sync removals when:
* - There are new deals being added (replacement scenario), OR
* - The activity has an account associated (indicating intentional association management)
*
* This prevents accidentally removing deal associations that exist in HubSpot
* but not in Jiminny's database (e.g., deals manually added by users in HubSpot).
*/
private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool
{
// Contacts and companies: always sync removals
if ($type !== 'deal') {
return true;
}
// Deals: sync removals if we're adding new deals (replacement)
if (! empty($added)) {
return true;
}
// Deals: sync removals only if activity has an account (intentional management)
return $activity->hasAccount();
}
private function normalizeIds(array $ids): array
{
$stringIds = array_map('strval', $ids);
$uniqueIds = array_unique($stringIds);
sort($uniqueIds);
return $uniqueIds;
}
private function updateAssociations(Activity $activity, array $associationChanges): void
{
$objectType = $activity->isTypeConference() ? 'meeting' : 'call';
foreach ($associationChanges as $type => $changes) {
if (! empty($changes['added'])) {
$associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);
$payload = $this->payloadBuilder->buildAddAssociationPayload(
$activity->getCrmProviderId(),
$changes['added'],
$associationType
);
$this->getClient()->addAssociations($objectType, $type, $payload);
}
if (! empty($changes['removed'])) {
$payload = $this->payloadBuilder->buildRemoveAssociationPayload(
$activity->getCrmProviderId(),
$changes['removed']
);
$this->getClient()->removeAssociations($objectType, $type, $payload);
}
}
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response
{
// If already set by us/client, do not override it
if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {
$this->logger->info('[HubSpot] Meeting activity type already set', [
'meetingId' => $meetingId,
'activityType' => $engagement['activityType'],
]);
unset($engagement['activityType']);
}
$payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);
return $this->getClient()->updateMeeting($meetingId, $payload);
}
private function hasEngagementActivityType(string $engagementId): bool
{
try {
$engagementData = $this->getClient()->getEngagementData($engagementId);
if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {
return true;
}
return false;
} catch (\Exception $exception) {
Sentry::captureException($exception);
$this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [
'engagementId' => $engagementId,
'exception' => $exception->getMessage(),
]);
}
return true;
}
private function updateTask(Activity $activity, array $engagement, array $metadata): void
{
$this->getClient()->deleteEngagement($activity->getCrmProviderId());
$this->logCrmEngagementManipulation(
self::ACTION_DELETE,
['crmId' => $activity->getCrmProviderId()],
);
$this->createActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createActivity(Activity $activity, array $engagement, array $metadata): void
{
$associations = $this->getActivityAssociations($activity);
$associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);
if ($activity->isTypeConference()) {
try {
$hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);
$activityId = $hsEngagement->data->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
} else {
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
$activityId = $hsEngagement->data->engagement->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
}
}
private function convertActivityMeetingAssociationsV4(Activity $activity): array
{
$associations = [];
$contactIds = $this->getParticipantsIds($activity);
foreach ($contactIds as $contactId) {
$associations[] = $this->buildAssociation(
(int) $contactId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]
);
}
if ($activity->hasAccount()) {
$crmProviderId = $activity->getAccount()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]
);
}
}
if ($activity->hasOpportunity()) {
$crmProviderId = $activity->getOpportunity()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]
);
}
}
return $associations;
}
private function buildAssociation(int $id, array $categoryToTypeIds): array
{
$types = [];
foreach ($categoryToTypeIds as $category => $typeId) {
$types[] = $this->buildAssociationType($category, $typeId);
}
return [
'to' => ['id' => (string) $id],
'types' => $types,
];
}
private function buildAssociationType(string $category, int $typeId): array
{
return [
'associationCategory' => $category,
'associationTypeId' => $typeId,
];
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createMeetingV3(array $engagement, array $associations, array $metadata): Response
{
$payload = $this->payloadBuilder->getV3MeetingPayload(
engagement: $engagement,
metadata: $metadata,
associations: $associations
);
return $this->getClient()->createMeeting($payload);
}
/**
* @throws BadRequest
* @throws HubspotException
*/
private function buildSoftphonePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'CALL',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'toNumber' => $decorator->formatCallToParticipant($activity),
'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),
'status' => $decorator->convertCallStatus($activity),
'durationMilliseconds' => (int) $activity->getDuration() * 1000,
'body' => $decorator->generateDescription($activity),
];
// For now, this is just a "disposition" field to store Call Outcome.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildTextMessagePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'NOTE',
];
$metadata = [
'body' => $decorator->generateDescription($activity),
];
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function getActivityAssociations(Activity $activity): array
{
return [
'contactIds' => $this->getParticipantsIds($activity),
'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],
'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],
'ownerIds' => [],
];
}
/**
* Get DecorateActivity instance. Can be overridden in tests for mocking.
*/
protected function getDecorateActivity(): DecorateActivity
{
return new DecorateActivity();
}
public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
if (empty($fields['subject'])) {
return null;
}
$associations = $this->getActivityAssociations($activity);
if (empty($fields['timestamp']) === false) {
$formatTimestamp = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['timestamp']);
$timestamp = $formatTimestamp->getTimestamp();
} else {
$timestamp = strtotime('+1 day');
}
$reminder = null;
if (empty($fields['reminder']) === false) {
$formatReminder = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['reminder']);
$reminder = $formatReminder->getTimestamp() * 1000;
}
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $timestamp * 1000,
'type' => 'TASK',
];
$metadata = [
'subject' => $fields['subject'],
'body' => '',
'status' => 'NOT_STARTED',
'taskType' => 'CALL',
'reminders' => $reminder ? [$reminder] : [],
];
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
} catch (BadRequest $e) {
$this->logger->info('[HubSpot] Failed to create followup task', [
'activity' => $activity->getUuid(),
'engagement' => $engagement,
'metadata' => $metadata,
'error' => $e->getMessage(),
]);
return null;
}
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
// We don't actually create a corresponding activity object on our side yet.
return (string) $hsEngagement->data->engagement->id;
}
private function logCrmEngagementManipulation(
string $action,
array $engagementData,
array $data = [],
array $associations = [],
): void {
$payload = ['team' => $this->team->getUuid()];
if ($action === self::ACTION_CREATE) {
$payload['engagementData'] = $engagementData;
$payload['data'] = $data;
$payload['associations'] = $associations;
}
if ($action === self::ACTION_UPDATE) {
$payload['engagementId'] = $engagementData['crmId'];
$payload['data'] = $data;
}
if ($action === self::ACTION_DELETE) {
$payload['engagementId'] = $engagementData['crmId'];
}
$this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45455
|
1628
|
5
|
2026-05-14T14:37:59.289683+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769479289_m2.jpg...
|
PhpStorm
|
faVsco.js – WriteCrmTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
8
6
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot\ServiceTraits;
use Carbon\Carbon;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Field;
use Jiminny\Repositories\Crm\FieldDataRepository;
use Jiminny\Services\Crm\Hubspot\DecorateActivity;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationCategoryV4;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationTypeIdV4;
use SevenShores\Hubspot\Exceptions\BadRequest;
use SevenShores\Hubspot\Http\Response;
use SevenShores\Hubspot\Exceptions\HubspotException;
use Sentry;
trait WriteCrmTrait
{
private const string ACTION_CREATE = 'create';
private const string ACTION_UPDATE = 'update';
private const string ACTION_DELETE = 'delete';
/**
* @inheritdoc
*/
public function saveActivity(Activity $activity): Activity
{
switch ($activity->getCrmType()) {
case Activity::TYPE_CONFERENCE:
$activity = $this->buildConferencePayload($activity);
break;
case Activity::TYPE_SOFTPHONE:
case Activity::TYPE_SOFTPHONE_INBOUND:
$activity = $this->buildSoftphonePayload($activity);
break;
case Activity::TYPE_SMS_INBOUND:
case Activity::TYPE_SMS_OUTBOUND:
$activity = $this->buildTextMessagePayload($activity);
break;
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildConferencePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatStartTime($activity),
'type' => 'MEETING',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'meetingOutcome' => $decorator->convertMeetingOutcome($activity),
'internalMeetingNotes' => $decorator->generateDescription($activity),
];
// Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.
if (! $activity->hasCrmProviderId()) {
if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {
$metadata['startTime'] = $decorator->formatStartTime($activity);
$metadata['endTime'] = $decorator->formatEndTime($activity);
}
$metadata['title'] = $decorator->generateTitle($activity);
}
// For now, this is just a "meetingOutcome" field for some customers.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function fetchCustomFieldData(Activity $activity, string $objectType): array
{
$payload = [];
$fieldDataRepository = app(FieldDataRepository::class);
$fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);
foreach ($fieldData as $data) {
// Add the field and value to the payload.
$payload += [
$data->getField()->getCrmProviderId() => $data->getValue(),
];
}
return $payload;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity
{
if (! $activity->hasCrmProviderId()) {
$this->createActivity($activity, $engagement, $metadata);
return $activity;
}
try {
$oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());
} catch (HubspotException $e) {
$this->logger->warning('[HubSpot] Engagement not found', [
'activity_id' => $activity->getUuid(),
'crm_provider_id' => $activity->getCrmProviderId(),
'exception' => $e->getMessage(),
]);
// potentially here we can log new activity if it is not found
return $activity;
}
$type = $oldEngagement['engagement']['type'] ?? null;
$bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';
$decorator = $this->getDecorateActivity();
if ($type !== 'TASK') {
$oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldDescription
);
$oldAssociations = $oldEngagement['associations'] ?? [];
$this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);
} else {
$oldTaskBody = $oldEngagement['metadata']['body'] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldTaskBody
);
$this->updateTask($activity, $engagement, $metadata);
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateNonTaskActivity(
Activity $activity,
array $engagement,
array $metadata,
array $oldAssociations
): void {
if ($activity->isTypeConference()) {
$this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);
} else {
$this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);
}
$this->updateActivityAssociations($activity, $oldAssociations);
$this->logCrmEngagementManipulation(
self::ACTION_UPDATE,
['crmId' => $activity->getCrmProviderId()],
$metadata,
);
}
private function updateActivityAssociations(Activity $activity, array $oldAssociations): void
{
$currentAssociations = $this->getActivityAssociations($activity);
$associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);
// No changes - exit
if (empty($associationChanges)) {
return;
}
$this->logger->info('[HubSpot] Updating associations', [
'team' => $this->team->getUuid(),
'activity' => $activity->getUuid(),
'associationChanges' => $associationChanges,
]);
$this->updateAssociations($activity, $associationChanges);
}
private function getAssociationDifferences(
Activity $activity,
array $oldAssociations,
array $currentAssociations
): array {
$objects = ['contactIds', 'companyIds', 'dealIds'];
$changes = [];
foreach ($objects as $object) {
$oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);
$currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);
$added = array_diff($currentIds, $oldIds);
$removed = array_diff($oldIds, $currentIds);
$type = match ($object) {
'contactIds' => 'contact',
'companyIds' => 'company',
'dealIds' => 'deal',
};
$shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);
if (! empty($removed) && ! $shouldIncludeRemoved) {
$this->logger->info('[HubSpot] Skipping association removal', [
'team' => $this->team->getUuid(),
'type' => $type,
'oldIds' => $oldIds,
'currentIds' => $currentIds,
'skippedRemovals' => array_values($removed),
]);
}
if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {
$changes[$type] = [
'added' => array_values($added),
'removed' => array_values($removed),
];
}
}
return $changes;
}
/**
* Determines whether removed associations should be synced to HubSpot.
*
* For contacts and companies, we always sync removals (original behavior).
* For deals, we only sync removals when:
* - There are new deals being added (replacement scenario), OR
* - The activity has an account associated (indicating intentional association management)
*
* This prevents accidentally removing deal associations that exist in HubSpot
* but not in Jiminny's database (e.g., deals manually added by users in HubSpot).
*/
private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool
{
// Contacts and companies: always sync removals
if ($type !== 'deal') {
return true;
}
// Deals: sync removals if we're adding new deals (replacement)
if (! empty($added)) {
return true;
}
// Deals: sync removals only if activity has an account (intentional management)
return $activity->hasAccount();
}
private function normalizeIds(array $ids): array
{
$stringIds = array_map('strval', $ids);
$uniqueIds = array_unique($stringIds);
sort($uniqueIds);
return $uniqueIds;
}
private function updateAssociations(Activity $activity, array $associationChanges): void
{
$objectType = $activity->isTypeConference() ? 'meeting' : 'call';
foreach ($associationChanges as $type => $changes) {
if (! empty($changes['added'])) {
$associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);
$payload = $this->payloadBuilder->buildAddAssociationPayload(
$activity->getCrmProviderId(),
$changes['added'],
$associationType
);
$this->getClient()->addAssociations($objectType, $type, $payload);
}
if (! empty($changes['removed'])) {
$payload = $this->payloadBuilder->buildRemoveAssociationPayload(
$activity->getCrmProviderId(),
$changes['removed']
);
$this->getClient()->removeAssociations($objectType, $type, $payload);
}
}
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response
{
// If already set by us/client, do not override it
if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {
$this->logger->info('[HubSpot] Meeting activity type already set', [
'meetingId' => $meetingId,
'activityType' => $engagement['activityType'],
]);
unset($engagement['activityType']);
}
$payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);
return $this->getClient()->updateMeeting($meetingId, $payload);
}
private function hasEngagementActivityType(string $engagementId): bool
{
try {
$engagementData = $this->getClient()->getEngagementData($engagementId);
if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {
return true;
}
return false;
} catch (\Exception $exception) {
Sentry::captureException($exception);
$this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [
'engagementId' => $engagementId,
'exception' => $exception->getMessage(),
]);
}
return true;
}
private function updateTask(Activity $activity, array $engagement, array $metadata): void
{
$this->getClient()->deleteEngagement($activity->getCrmProviderId());
$this->logCrmEngagementManipulation(
self::ACTION_DELETE,
['crmId' => $activity->getCrmProviderId()],
);
$this->createActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createActivity(Activity $activity, array $engagement, array $metadata): void
{
$associations = $this->getActivityAssociations($activity);
$associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);
if ($activity->isTypeConference()) {
try {
$hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);
$activityId = $hsEngagement->data->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
} else {
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
$activityId = $hsEngagement->data->engagement->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
}
}
private function convertActivityMeetingAssociationsV4(Activity $activity): array
{
$associations = [];
$contactIds = $this->getParticipantsIds($activity);
foreach ($contactIds as $contactId) {
$associations[] = $this->buildAssociation(
(int) $contactId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]
);
}
if ($activity->hasAccount()) {
$crmProviderId = $activity->getAccount()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]
);
}
}
if ($activity->hasOpportunity()) {
$crmProviderId = $activity->getOpportunity()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]
);
}
}
return $associations;
}
private function buildAssociation(int $id, array $categoryToTypeIds): array
{
$types = [];
foreach ($categoryToTypeIds as $category => $typeId) {
$types[] = $this->buildAssociationType($category, $typeId);
}
return [
'to' => ['id' => (string) $id],
'types' => $types,
];
}
private function buildAssociationType(string $category, int $typeId): array
{
return [
'associationCategory' => $category,
'associationTypeId' => $typeId,
];
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createMeetingV3(array $engagement, array $associations, array $metadata): Response
{
$payload = $this->payloadBuilder->getV3MeetingPayload(
engagement: $engagement,
metadata: $metadata,
associations: $associations
);
return $this->getClient()->createMeeting($payload);
}
/**
* @throws BadRequest
* @throws HubspotException
*/
private function buildSoftphonePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'CALL',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'toNumber' => $decorator->formatCallToParticipant($activity),
'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),
'status' => $decorator->convertCallStatus($activity),
'durationMilliseconds' => (int) $activity->getDuration() * 1000,
'body' => $decorator->generateDescription($activity),
];
// For now, this is just a "disposition" field to store Call Outcome.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildTextMessagePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'NOTE',
];
$metadata = [
'body' => $decorator->generateDescription($activity),
];
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function getActivityAssociations(Activity $activity): array
{
return [
'contactIds' => $this->getParticipantsIds($activity),
'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],
'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],
'ownerIds' => [],
];
}
/**
* Get DecorateActivity instance. Can be overridden in tests for mocking.
*/
protected function getDecorateActivity(): DecorateActivity
{
return new DecorateActivity();
}
public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
if (empty($fields['subject'])) {
return null;
}
$associations = $this->getActivityAssociations($activity);
if (empty($fields['timestamp']) === false) {
$formatTimestamp = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['timestamp']);
$timestamp = $formatTimestamp->getTimestamp();
} else {
$timestamp = strtotime('+1 day');
}
$reminder = null;
if (empty($fields['reminder']) === false) {
$formatReminder = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['reminder']);
$reminder = $formatReminder->getTimestamp() * 1000;
}
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $timestamp * 1000,
'type' => 'TASK',
];
$metadata = [
'subject' => $fields['subject'],
'body' => '',
'status' => 'NOT_STARTED',
'taskType' => 'CALL',
'reminders' => $reminder ? [$reminder] : [],
];
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
} catch (BadRequest $e) {
$this->logger->info('[HubSpot] Failed to create followup task', [
'activity' => $activity->getUuid(),
'engagement' => $engagement,
'metadata' => $metadata,
'error' => $e->getMessage(),
]);
return null;
}
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
// We don't actually create a corresponding activity object on our side yet.
return (string) $hsEngagement->data->engagement->id;
}
private function logCrmEngagementManipulation(
string $action,
array $engagementData,
array $data = [],
array $associations = [],
): void {
$payload = ['team' => $this->team->getUuid()];
if ($action === self::ACTION_CREATE) {
$payload['engagementData'] = $engagementData;
$payload['data'] = $data;
$payload['associations'] = $associations;
}
if ($action === self::ACTION_UPDATE) {
$payload['engagementId'] = $engagementData['crmId'];
$payload['data'] = $data;
}
if ($action === self::ACTION_DELETE) {
$payload['engagementId'] = $engagementData['crmId'];
}
$this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot\\ServiceTraits;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Repositories\\Crm\\FieldDataRepository;\nuse Jiminny\\Services\\Crm\\Hubspot\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationCategoryV4;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationTypeIdV4;\nuse SevenShores\\Hubspot\\Exceptions\\BadRequest;\nuse SevenShores\\Hubspot\\Http\\Response;\nuse SevenShores\\Hubspot\\Exceptions\\HubspotException;\nuse Sentry;\n\ntrait WriteCrmTrait\n{\n private const string ACTION_CREATE = 'create';\n private const string ACTION_UPDATE = 'update';\n private const string ACTION_DELETE = 'delete';\n\n /**\n * @inheritdoc\n */\n public function saveActivity(Activity $activity): Activity\n {\n switch ($activity->getCrmType()) {\n case Activity::TYPE_CONFERENCE:\n $activity = $this->buildConferencePayload($activity);\n\n break;\n case Activity::TYPE_SOFTPHONE:\n case Activity::TYPE_SOFTPHONE_INBOUND:\n $activity = $this->buildSoftphonePayload($activity);\n\n break;\n\n case Activity::TYPE_SMS_INBOUND:\n case Activity::TYPE_SMS_OUTBOUND:\n $activity = $this->buildTextMessagePayload($activity);\n\n break;\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildConferencePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatStartTime($activity),\n 'type' => 'MEETING',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'meetingOutcome' => $decorator->convertMeetingOutcome($activity),\n 'internalMeetingNotes' => $decorator->generateDescription($activity),\n ];\n\n // Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.\n if (! $activity->hasCrmProviderId()) {\n if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {\n $metadata['startTime'] = $decorator->formatStartTime($activity);\n $metadata['endTime'] = $decorator->formatEndTime($activity);\n }\n $metadata['title'] = $decorator->generateTitle($activity);\n }\n\n // For now, this is just a \"meetingOutcome\" field for some customers.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function fetchCustomFieldData(Activity $activity, string $objectType): array\n {\n $payload = [];\n\n $fieldDataRepository = app(FieldDataRepository::class);\n $fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);\n\n foreach ($fieldData as $data) {\n // Add the field and value to the payload.\n $payload += [\n $data->getField()->getCrmProviderId() => $data->getValue(),\n ];\n }\n\n return $payload;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity\n {\n if (! $activity->hasCrmProviderId()) {\n $this->createActivity($activity, $engagement, $metadata);\n\n return $activity;\n }\n\n try {\n $oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());\n } catch (HubspotException $e) {\n $this->logger->warning('[HubSpot] Engagement not found', [\n 'activity_id' => $activity->getUuid(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'exception' => $e->getMessage(),\n ]);\n\n // potentially here we can log new activity if it is not found\n\n return $activity;\n }\n\n $type = $oldEngagement['engagement']['type'] ?? null;\n $bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';\n\n $decorator = $this->getDecorateActivity();\n\n if ($type !== 'TASK') {\n $oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldDescription\n );\n\n $oldAssociations = $oldEngagement['associations'] ?? [];\n $this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);\n } else {\n $oldTaskBody = $oldEngagement['metadata']['body'] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldTaskBody\n );\n $this->updateTask($activity, $engagement, $metadata);\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateNonTaskActivity(\n Activity $activity,\n array $engagement,\n array $metadata,\n array $oldAssociations\n ): void {\n if ($activity->isTypeConference()) {\n $this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);\n } else {\n $this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);\n }\n\n $this->updateActivityAssociations($activity, $oldAssociations);\n\n $this->logCrmEngagementManipulation(\n self::ACTION_UPDATE,\n ['crmId' => $activity->getCrmProviderId()],\n $metadata,\n );\n }\n\n private function updateActivityAssociations(Activity $activity, array $oldAssociations): void\n {\n $currentAssociations = $this->getActivityAssociations($activity);\n $associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);\n\n // No changes - exit\n if (empty($associationChanges)) {\n return;\n }\n\n $this->logger->info('[HubSpot] Updating associations', [\n 'team' => $this->team->getUuid(),\n 'activity' => $activity->getUuid(),\n 'associationChanges' => $associationChanges,\n ]);\n\n $this->updateAssociations($activity, $associationChanges);\n }\n\n private function getAssociationDifferences(\n Activity $activity,\n array $oldAssociations,\n array $currentAssociations\n ): array {\n $objects = ['contactIds', 'companyIds', 'dealIds'];\n $changes = [];\n\n foreach ($objects as $object) {\n $oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);\n $currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);\n\n $added = array_diff($currentIds, $oldIds);\n $removed = array_diff($oldIds, $currentIds);\n\n $type = match ($object) {\n 'contactIds' => 'contact',\n 'companyIds' => 'company',\n 'dealIds' => 'deal',\n };\n\n $shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);\n\n if (! empty($removed) && ! $shouldIncludeRemoved) {\n $this->logger->info('[HubSpot] Skipping association removal', [\n 'team' => $this->team->getUuid(),\n 'type' => $type,\n 'oldIds' => $oldIds,\n 'currentIds' => $currentIds,\n 'skippedRemovals' => array_values($removed),\n ]);\n }\n\n if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {\n $changes[$type] = [\n 'added' => array_values($added),\n 'removed' => array_values($removed),\n ];\n }\n }\n\n return $changes;\n }\n\n /**\n * Determines whether removed associations should be synced to HubSpot.\n *\n * For contacts and companies, we always sync removals (original behavior).\n * For deals, we only sync removals when:\n * - There are new deals being added (replacement scenario), OR\n * - The activity has an account associated (indicating intentional association management)\n *\n * This prevents accidentally removing deal associations that exist in HubSpot\n * but not in Jiminny's database (e.g., deals manually added by users in HubSpot).\n */\n private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool\n {\n // Contacts and companies: always sync removals\n if ($type !== 'deal') {\n return true;\n }\n\n // Deals: sync removals if we're adding new deals (replacement)\n if (! empty($added)) {\n return true;\n }\n\n // Deals: sync removals only if activity has an account (intentional management)\n return $activity->hasAccount();\n }\n\n private function normalizeIds(array $ids): array\n {\n $stringIds = array_map('strval', $ids);\n $uniqueIds = array_unique($stringIds);\n sort($uniqueIds);\n\n return $uniqueIds;\n }\n\n private function updateAssociations(Activity $activity, array $associationChanges): void\n {\n $objectType = $activity->isTypeConference() ? 'meeting' : 'call';\n\n foreach ($associationChanges as $type => $changes) {\n if (! empty($changes['added'])) {\n $associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);\n $payload = $this->payloadBuilder->buildAddAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['added'],\n $associationType\n );\n $this->getClient()->addAssociations($objectType, $type, $payload);\n }\n\n if (! empty($changes['removed'])) {\n $payload = $this->payloadBuilder->buildRemoveAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['removed']\n );\n $this->getClient()->removeAssociations($objectType, $type, $payload);\n }\n }\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response\n {\n // If already set by us/client, do not override it\n if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {\n $this->logger->info('[HubSpot] Meeting activity type already set', [\n 'meetingId' => $meetingId,\n 'activityType' => $engagement['activityType'],\n ]);\n\n unset($engagement['activityType']);\n }\n\n $payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);\n\n return $this->getClient()->updateMeeting($meetingId, $payload);\n }\n\n private function hasEngagementActivityType(string $engagementId): bool\n {\n try {\n $engagementData = $this->getClient()->getEngagementData($engagementId);\n if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {\n return true;\n }\n\n return false;\n } catch (\\Exception $exception) {\n Sentry::captureException($exception);\n\n $this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [\n 'engagementId' => $engagementId,\n 'exception' => $exception->getMessage(),\n ]);\n }\n\n return true;\n }\n\n private function updateTask(Activity $activity, array $engagement, array $metadata): void\n {\n $this->getClient()->deleteEngagement($activity->getCrmProviderId());\n\n $this->logCrmEngagementManipulation(\n self::ACTION_DELETE,\n ['crmId' => $activity->getCrmProviderId()],\n );\n\n $this->createActivity($activity, $engagement, $metadata);\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createActivity(Activity $activity, array $engagement, array $metadata): void\n {\n $associations = $this->getActivityAssociations($activity);\n $associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);\n\n if ($activity->isTypeConference()) {\n try {\n $hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);\n $activityId = $hsEngagement->data->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n } else {\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n $activityId = $hsEngagement->data->engagement->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n }\n }\n\n private function convertActivityMeetingAssociationsV4(Activity $activity): array\n {\n $associations = [];\n\n $contactIds = $this->getParticipantsIds($activity);\n\n foreach ($contactIds as $contactId) {\n $associations[] = $this->buildAssociation(\n (int) $contactId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]\n );\n }\n\n if ($activity->hasAccount()) {\n $crmProviderId = $activity->getAccount()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]\n );\n }\n }\n\n if ($activity->hasOpportunity()) {\n $crmProviderId = $activity->getOpportunity()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]\n );\n }\n }\n\n return $associations;\n }\n\n private function buildAssociation(int $id, array $categoryToTypeIds): array\n {\n $types = [];\n\n foreach ($categoryToTypeIds as $category => $typeId) {\n $types[] = $this->buildAssociationType($category, $typeId);\n }\n\n return [\n 'to' => ['id' => (string) $id],\n 'types' => $types,\n ];\n }\n\n private function buildAssociationType(string $category, int $typeId): array\n {\n return [\n 'associationCategory' => $category,\n 'associationTypeId' => $typeId,\n ];\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createMeetingV3(array $engagement, array $associations, array $metadata): Response\n {\n $payload = $this->payloadBuilder->getV3MeetingPayload(\n engagement: $engagement,\n metadata: $metadata,\n associations: $associations\n );\n\n return $this->getClient()->createMeeting($payload);\n }\n\n /**\n * @throws BadRequest\n * @throws HubspotException\n */\n private function buildSoftphonePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'CALL',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'toNumber' => $decorator->formatCallToParticipant($activity),\n 'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),\n 'status' => $decorator->convertCallStatus($activity),\n 'durationMilliseconds' => (int) $activity->getDuration() * 1000,\n 'body' => $decorator->generateDescription($activity),\n ];\n\n // For now, this is just a \"disposition\" field to store Call Outcome.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildTextMessagePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'NOTE',\n ];\n\n $metadata = [\n 'body' => $decorator->generateDescription($activity),\n ];\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function getActivityAssociations(Activity $activity): array\n {\n return [\n 'contactIds' => $this->getParticipantsIds($activity),\n 'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],\n 'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],\n 'ownerIds' => [],\n ];\n }\n\n /**\n * Get DecorateActivity instance. Can be overridden in tests for mocking.\n */\n protected function getDecorateActivity(): DecorateActivity\n {\n return new DecorateActivity();\n }\n\n public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n if (empty($fields['subject'])) {\n return null;\n }\n\n $associations = $this->getActivityAssociations($activity);\n\n if (empty($fields['timestamp']) === false) {\n $formatTimestamp = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['timestamp']);\n $timestamp = $formatTimestamp->getTimestamp();\n } else {\n $timestamp = strtotime('+1 day');\n }\n\n $reminder = null;\n if (empty($fields['reminder']) === false) {\n $formatReminder = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['reminder']);\n $reminder = $formatReminder->getTimestamp() * 1000;\n }\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $timestamp * 1000,\n 'type' => 'TASK',\n ];\n\n $metadata = [\n 'subject' => $fields['subject'],\n 'body' => '',\n 'status' => 'NOT_STARTED',\n 'taskType' => 'CALL',\n 'reminders' => $reminder ? [$reminder] : [],\n ];\n\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n } catch (BadRequest $e) {\n $this->logger->info('[HubSpot] Failed to create followup task', [\n 'activity' => $activity->getUuid(),\n 'engagement' => $engagement,\n 'metadata' => $metadata,\n 'error' => $e->getMessage(),\n ]);\n\n return null;\n }\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n // We don't actually create a corresponding activity object on our side yet.\n return (string) $hsEngagement->data->engagement->id;\n }\n\n private function logCrmEngagementManipulation(\n string $action,\n array $engagementData,\n array $data = [],\n array $associations = [],\n ): void {\n $payload = ['team' => $this->team->getUuid()];\n\n if ($action === self::ACTION_CREATE) {\n $payload['engagementData'] = $engagementData;\n $payload['data'] = $data;\n $payload['associations'] = $associations;\n }\n\n if ($action === self::ACTION_UPDATE) {\n $payload['engagementId'] = $engagementData['crmId'];\n $payload['data'] = $data;\n }\n\n if ($action === self::ACTION_DELETE) {\n $payload['engagementId'] = $engagementData['crmId'];\n }\n\n $this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);\n }\n}","depth":4,"bounds":{"left":0.39261967,"top":0.17956904,"width":0.31615692,"height":0.820431},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot\\ServiceTraits;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Crm\\Field;\nuse Jiminny\\Repositories\\Crm\\FieldDataRepository;\nuse Jiminny\\Services\\Crm\\Hubspot\\DecorateActivity;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationCategoryV4;\nuse Jiminny\\Services\\Crm\\Hubspot\\Utils\\AssociationTypeIdV4;\nuse SevenShores\\Hubspot\\Exceptions\\BadRequest;\nuse SevenShores\\Hubspot\\Http\\Response;\nuse SevenShores\\Hubspot\\Exceptions\\HubspotException;\nuse Sentry;\n\ntrait WriteCrmTrait\n{\n private const string ACTION_CREATE = 'create';\n private const string ACTION_UPDATE = 'update';\n private const string ACTION_DELETE = 'delete';\n\n /**\n * @inheritdoc\n */\n public function saveActivity(Activity $activity): Activity\n {\n switch ($activity->getCrmType()) {\n case Activity::TYPE_CONFERENCE:\n $activity = $this->buildConferencePayload($activity);\n\n break;\n case Activity::TYPE_SOFTPHONE:\n case Activity::TYPE_SOFTPHONE_INBOUND:\n $activity = $this->buildSoftphonePayload($activity);\n\n break;\n\n case Activity::TYPE_SMS_INBOUND:\n case Activity::TYPE_SMS_OUTBOUND:\n $activity = $this->buildTextMessagePayload($activity);\n\n break;\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildConferencePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatStartTime($activity),\n 'type' => 'MEETING',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'meetingOutcome' => $decorator->convertMeetingOutcome($activity),\n 'internalMeetingNotes' => $decorator->generateDescription($activity),\n ];\n\n // Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.\n if (! $activity->hasCrmProviderId()) {\n if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {\n $metadata['startTime'] = $decorator->formatStartTime($activity);\n $metadata['endTime'] = $decorator->formatEndTime($activity);\n }\n $metadata['title'] = $decorator->generateTitle($activity);\n }\n\n // For now, this is just a \"meetingOutcome\" field for some customers.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function fetchCustomFieldData(Activity $activity, string $objectType): array\n {\n $payload = [];\n\n $fieldDataRepository = app(FieldDataRepository::class);\n $fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);\n\n foreach ($fieldData as $data) {\n // Add the field and value to the payload.\n $payload += [\n $data->getField()->getCrmProviderId() => $data->getValue(),\n ];\n }\n\n return $payload;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity\n {\n if (! $activity->hasCrmProviderId()) {\n $this->createActivity($activity, $engagement, $metadata);\n\n return $activity;\n }\n\n try {\n $oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());\n } catch (HubspotException $e) {\n $this->logger->warning('[HubSpot] Engagement not found', [\n 'activity_id' => $activity->getUuid(),\n 'crm_provider_id' => $activity->getCrmProviderId(),\n 'exception' => $e->getMessage(),\n ]);\n\n // potentially here we can log new activity if it is not found\n\n return $activity;\n }\n\n $type = $oldEngagement['engagement']['type'] ?? null;\n $bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';\n\n $decorator = $this->getDecorateActivity();\n\n if ($type !== 'TASK') {\n $oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldDescription\n );\n\n $oldAssociations = $oldEngagement['associations'] ?? [];\n $this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);\n } else {\n $oldTaskBody = $oldEngagement['metadata']['body'] ?? '';\n $metadata[$bodyAttribute] = $decorator->mergeDescriptions(\n $metadata[$bodyAttribute],\n $oldTaskBody\n );\n $this->updateTask($activity, $engagement, $metadata);\n }\n\n return $activity;\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateNonTaskActivity(\n Activity $activity,\n array $engagement,\n array $metadata,\n array $oldAssociations\n ): void {\n if ($activity->isTypeConference()) {\n $this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);\n } else {\n $this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);\n }\n\n $this->updateActivityAssociations($activity, $oldAssociations);\n\n $this->logCrmEngagementManipulation(\n self::ACTION_UPDATE,\n ['crmId' => $activity->getCrmProviderId()],\n $metadata,\n );\n }\n\n private function updateActivityAssociations(Activity $activity, array $oldAssociations): void\n {\n $currentAssociations = $this->getActivityAssociations($activity);\n $associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);\n\n // No changes - exit\n if (empty($associationChanges)) {\n return;\n }\n\n $this->logger->info('[HubSpot] Updating associations', [\n 'team' => $this->team->getUuid(),\n 'activity' => $activity->getUuid(),\n 'associationChanges' => $associationChanges,\n ]);\n\n $this->updateAssociations($activity, $associationChanges);\n }\n\n private function getAssociationDifferences(\n Activity $activity,\n array $oldAssociations,\n array $currentAssociations\n ): array {\n $objects = ['contactIds', 'companyIds', 'dealIds'];\n $changes = [];\n\n foreach ($objects as $object) {\n $oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);\n $currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);\n\n $added = array_diff($currentIds, $oldIds);\n $removed = array_diff($oldIds, $currentIds);\n\n $type = match ($object) {\n 'contactIds' => 'contact',\n 'companyIds' => 'company',\n 'dealIds' => 'deal',\n };\n\n $shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);\n\n if (! empty($removed) && ! $shouldIncludeRemoved) {\n $this->logger->info('[HubSpot] Skipping association removal', [\n 'team' => $this->team->getUuid(),\n 'type' => $type,\n 'oldIds' => $oldIds,\n 'currentIds' => $currentIds,\n 'skippedRemovals' => array_values($removed),\n ]);\n }\n\n if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {\n $changes[$type] = [\n 'added' => array_values($added),\n 'removed' => array_values($removed),\n ];\n }\n }\n\n return $changes;\n }\n\n /**\n * Determines whether removed associations should be synced to HubSpot.\n *\n * For contacts and companies, we always sync removals (original behavior).\n * For deals, we only sync removals when:\n * - There are new deals being added (replacement scenario), OR\n * - The activity has an account associated (indicating intentional association management)\n *\n * This prevents accidentally removing deal associations that exist in HubSpot\n * but not in Jiminny's database (e.g., deals manually added by users in HubSpot).\n */\n private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool\n {\n // Contacts and companies: always sync removals\n if ($type !== 'deal') {\n return true;\n }\n\n // Deals: sync removals if we're adding new deals (replacement)\n if (! empty($added)) {\n return true;\n }\n\n // Deals: sync removals only if activity has an account (intentional management)\n return $activity->hasAccount();\n }\n\n private function normalizeIds(array $ids): array\n {\n $stringIds = array_map('strval', $ids);\n $uniqueIds = array_unique($stringIds);\n sort($uniqueIds);\n\n return $uniqueIds;\n }\n\n private function updateAssociations(Activity $activity, array $associationChanges): void\n {\n $objectType = $activity->isTypeConference() ? 'meeting' : 'call';\n\n foreach ($associationChanges as $type => $changes) {\n if (! empty($changes['added'])) {\n $associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);\n $payload = $this->payloadBuilder->buildAddAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['added'],\n $associationType\n );\n $this->getClient()->addAssociations($objectType, $type, $payload);\n }\n\n if (! empty($changes['removed'])) {\n $payload = $this->payloadBuilder->buildRemoveAssociationPayload(\n $activity->getCrmProviderId(),\n $changes['removed']\n );\n $this->getClient()->removeAssociations($objectType, $type, $payload);\n }\n }\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response\n {\n // If already set by us/client, do not override it\n if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {\n $this->logger->info('[HubSpot] Meeting activity type already set', [\n 'meetingId' => $meetingId,\n 'activityType' => $engagement['activityType'],\n ]);\n\n unset($engagement['activityType']);\n }\n\n $payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);\n\n return $this->getClient()->updateMeeting($meetingId, $payload);\n }\n\n private function hasEngagementActivityType(string $engagementId): bool\n {\n try {\n $engagementData = $this->getClient()->getEngagementData($engagementId);\n if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {\n return true;\n }\n\n return false;\n } catch (\\Exception $exception) {\n Sentry::captureException($exception);\n\n $this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [\n 'engagementId' => $engagementId,\n 'exception' => $exception->getMessage(),\n ]);\n }\n\n return true;\n }\n\n private function updateTask(Activity $activity, array $engagement, array $metadata): void\n {\n $this->getClient()->deleteEngagement($activity->getCrmProviderId());\n\n $this->logCrmEngagementManipulation(\n self::ACTION_DELETE,\n ['crmId' => $activity->getCrmProviderId()],\n );\n\n $this->createActivity($activity, $engagement, $metadata);\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createActivity(Activity $activity, array $engagement, array $metadata): void\n {\n $associations = $this->getActivityAssociations($activity);\n $associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);\n\n if ($activity->isTypeConference()) {\n try {\n $hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);\n $activityId = $hsEngagement->data->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n } else {\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n $activityId = $hsEngagement->data->engagement->id;\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n $activity->crm_provider_id = $activityId;\n $activity->save();\n } catch (BadRequest $exception) {\n Sentry::captureException($exception);\n\n $this->logger->warning('[HubSpot] Error while creating engagements', [\n 'activity' => $activity->getUuid(),\n 'message' => $exception->getMessage(),\n 'engagement' => $engagement,\n 'associations' => $associations,\n 'metadata' => $metadata,\n ]);\n }\n }\n }\n\n private function convertActivityMeetingAssociationsV4(Activity $activity): array\n {\n $associations = [];\n\n $contactIds = $this->getParticipantsIds($activity);\n\n foreach ($contactIds as $contactId) {\n $associations[] = $this->buildAssociation(\n (int) $contactId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]\n );\n }\n\n if ($activity->hasAccount()) {\n $crmProviderId = $activity->getAccount()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]\n );\n }\n }\n\n if ($activity->hasOpportunity()) {\n $crmProviderId = $activity->getOpportunity()?->getCrmProviderId();\n if ($crmProviderId) {\n $associations[] = $this->buildAssociation(\n (int) $crmProviderId,\n [AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]\n );\n }\n }\n\n return $associations;\n }\n\n private function buildAssociation(int $id, array $categoryToTypeIds): array\n {\n $types = [];\n\n foreach ($categoryToTypeIds as $category => $typeId) {\n $types[] = $this->buildAssociationType($category, $typeId);\n }\n\n return [\n 'to' => ['id' => (string) $id],\n 'types' => $types,\n ];\n }\n\n private function buildAssociationType(string $category, int $typeId): array\n {\n return [\n 'associationCategory' => $category,\n 'associationTypeId' => $typeId,\n ];\n }\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function createMeetingV3(array $engagement, array $associations, array $metadata): Response\n {\n $payload = $this->payloadBuilder->getV3MeetingPayload(\n engagement: $engagement,\n metadata: $metadata,\n associations: $associations\n );\n\n return $this->getClient()->createMeeting($payload);\n }\n\n /**\n * @throws BadRequest\n * @throws HubspotException\n */\n private function buildSoftphonePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'CALL',\n ];\n\n if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {\n $engagement['activityType'] = $activity->getActivityType()->getName();\n }\n\n $metadata = [\n 'toNumber' => $decorator->formatCallToParticipant($activity),\n 'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),\n 'status' => $decorator->convertCallStatus($activity),\n 'durationMilliseconds' => (int) $activity->getDuration() * 1000,\n 'body' => $decorator->generateDescription($activity),\n ];\n\n // For now, this is just a \"disposition\" field to store Call Outcome.\n $metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n\n /**\n * @throws HubspotException\n * @throws BadRequest\n */\n private function buildTextMessagePayload(Activity $activity): Activity\n {\n $decorator = $this->getDecorateActivity();\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $decorator->formatCreatedAt($activity),\n 'type' => 'NOTE',\n ];\n\n $metadata = [\n 'body' => $decorator->generateDescription($activity),\n ];\n\n return $this->upsertActivity($activity, $engagement, $metadata);\n }\n\n private function getActivityAssociations(Activity $activity): array\n {\n return [\n 'contactIds' => $this->getParticipantsIds($activity),\n 'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],\n 'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],\n 'ownerIds' => [],\n ];\n }\n\n /**\n * Get DecorateActivity instance. Can be overridden in tests for mocking.\n */\n protected function getDecorateActivity(): DecorateActivity\n {\n return new DecorateActivity();\n }\n\n public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n if (empty($fields['subject'])) {\n return null;\n }\n\n $associations = $this->getActivityAssociations($activity);\n\n if (empty($fields['timestamp']) === false) {\n $formatTimestamp = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['timestamp']);\n $timestamp = $formatTimestamp->getTimestamp();\n } else {\n $timestamp = strtotime('+1 day');\n }\n\n $reminder = null;\n if (empty($fields['reminder']) === false) {\n $formatReminder = Carbon::createFromFormat('Y-m-d\\TH:i:s\\Z', $fields['reminder']);\n $reminder = $formatReminder->getTimestamp() * 1000;\n }\n\n $engagement = [\n 'active' => true,\n 'ownerId' => $this->profile->getCrmProviderId(),\n 'timestamp' => $timestamp * 1000,\n 'type' => 'TASK',\n ];\n\n $metadata = [\n 'subject' => $fields['subject'],\n 'body' => '',\n 'status' => 'NOT_STARTED',\n 'taskType' => 'CALL',\n 'reminders' => $reminder ? [$reminder] : [],\n ];\n\n try {\n $hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);\n } catch (BadRequest $e) {\n $this->logger->info('[HubSpot] Failed to create followup task', [\n 'activity' => $activity->getUuid(),\n 'engagement' => $engagement,\n 'metadata' => $metadata,\n 'error' => $e->getMessage(),\n ]);\n\n return null;\n }\n\n $this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);\n\n // We don't actually create a corresponding activity object on our side yet.\n return (string) $hsEngagement->data->engagement->id;\n }\n\n private function logCrmEngagementManipulation(\n string $action,\n array $engagementData,\n array $data = [],\n array $associations = [],\n ): void {\n $payload = ['team' => $this->team->getUuid()];\n\n if ($action === self::ACTION_CREATE) {\n $payload['engagementData'] = $engagementData;\n $payload['data'] = $data;\n $payload['associations'] = $associations;\n }\n\n if ($action === self::ACTION_UPDATE) {\n $payload['engagementId'] = $engagementData['crmId'];\n $payload['data'] = $data;\n }\n\n if ($action === self::ACTION_DELETE) {\n $payload['engagementId'] = $engagementData['crmId'];\n }\n\n $this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.28224733,"top":1.0,"width":0.024268618,"height":-0.04788506},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
3382584868951134281
|
6551498163460912845
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
8
6
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot\ServiceTraits;
use Carbon\Carbon;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Field;
use Jiminny\Repositories\Crm\FieldDataRepository;
use Jiminny\Services\Crm\Hubspot\DecorateActivity;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationCategoryV4;
use Jiminny\Services\Crm\Hubspot\Utils\AssociationTypeIdV4;
use SevenShores\Hubspot\Exceptions\BadRequest;
use SevenShores\Hubspot\Http\Response;
use SevenShores\Hubspot\Exceptions\HubspotException;
use Sentry;
trait WriteCrmTrait
{
private const string ACTION_CREATE = 'create';
private const string ACTION_UPDATE = 'update';
private const string ACTION_DELETE = 'delete';
/**
* @inheritdoc
*/
public function saveActivity(Activity $activity): Activity
{
switch ($activity->getCrmType()) {
case Activity::TYPE_CONFERENCE:
$activity = $this->buildConferencePayload($activity);
break;
case Activity::TYPE_SOFTPHONE:
case Activity::TYPE_SOFTPHONE_INBOUND:
$activity = $this->buildSoftphonePayload($activity);
break;
case Activity::TYPE_SMS_INBOUND:
case Activity::TYPE_SMS_OUTBOUND:
$activity = $this->buildTextMessagePayload($activity);
break;
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildConferencePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatStartTime($activity),
'type' => 'MEETING',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'meetingOutcome' => $decorator->convertMeetingOutcome($activity),
'internalMeetingNotes' => $decorator->generateDescription($activity),
];
// Only if they are creating a fresh engagement should we update the times, otherwise it will cause a cal sync.
if (! $activity->hasCrmProviderId()) {
if ($activity->hasActualStartTime() && $activity->hasActualEndTime()) {
$metadata['startTime'] = $decorator->formatStartTime($activity);
$metadata['endTime'] = $decorator->formatEndTime($activity);
}
$metadata['title'] = $decorator->generateTitle($activity);
}
// For now, this is just a "meetingOutcome" field for some customers.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function fetchCustomFieldData(Activity $activity, string $objectType): array
{
$payload = [];
$fieldDataRepository = app(FieldDataRepository::class);
$fieldData = $fieldDataRepository->getActivityFieldData($activity, $objectType);
foreach ($fieldData as $data) {
// Add the field and value to the payload.
$payload += [
$data->getField()->getCrmProviderId() => $data->getValue(),
];
}
return $payload;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function upsertActivity(Activity $activity, array $engagement, array $metadata): Activity
{
if (! $activity->hasCrmProviderId()) {
$this->createActivity($activity, $engagement, $metadata);
return $activity;
}
try {
$oldEngagement = $this->getClient()->getEngagementData($activity->getCrmProviderId());
} catch (HubspotException $e) {
$this->logger->warning('[HubSpot] Engagement not found', [
'activity_id' => $activity->getUuid(),
'crm_provider_id' => $activity->getCrmProviderId(),
'exception' => $e->getMessage(),
]);
// potentially here we can log new activity if it is not found
return $activity;
}
$type = $oldEngagement['engagement']['type'] ?? null;
$bodyAttribute = $activity->isTypeConference() ? 'internalMeetingNotes' : 'body';
$decorator = $this->getDecorateActivity();
if ($type !== 'TASK') {
$oldDescription = $oldEngagement['metadata'][$bodyAttribute] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldDescription
);
$oldAssociations = $oldEngagement['associations'] ?? [];
$this->updateNonTaskActivity($activity, $engagement, $metadata, $oldAssociations);
} else {
$oldTaskBody = $oldEngagement['metadata']['body'] ?? '';
$metadata[$bodyAttribute] = $decorator->mergeDescriptions(
$metadata[$bodyAttribute],
$oldTaskBody
);
$this->updateTask($activity, $engagement, $metadata);
}
return $activity;
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateNonTaskActivity(
Activity $activity,
array $engagement,
array $metadata,
array $oldAssociations
): void {
if ($activity->isTypeConference()) {
$this->updateMeetingV3($activity->getCrmProviderId(), $engagement, $metadata);
} else {
$this->getClient()->updateEngagement($activity->getCrmProviderId(), $engagement, $metadata);
}
$this->updateActivityAssociations($activity, $oldAssociations);
$this->logCrmEngagementManipulation(
self::ACTION_UPDATE,
['crmId' => $activity->getCrmProviderId()],
$metadata,
);
}
private function updateActivityAssociations(Activity $activity, array $oldAssociations): void
{
$currentAssociations = $this->getActivityAssociations($activity);
$associationChanges = $this->getAssociationDifferences($activity, $oldAssociations, $currentAssociations);
// No changes - exit
if (empty($associationChanges)) {
return;
}
$this->logger->info('[HubSpot] Updating associations', [
'team' => $this->team->getUuid(),
'activity' => $activity->getUuid(),
'associationChanges' => $associationChanges,
]);
$this->updateAssociations($activity, $associationChanges);
}
private function getAssociationDifferences(
Activity $activity,
array $oldAssociations,
array $currentAssociations
): array {
$objects = ['contactIds', 'companyIds', 'dealIds'];
$changes = [];
foreach ($objects as $object) {
$oldIds = $this->normalizeIds($oldAssociations[$object] ?? []);
$currentIds = $this->normalizeIds($currentAssociations[$object] ?? []);
$added = array_diff($currentIds, $oldIds);
$removed = array_diff($oldIds, $currentIds);
$type = match ($object) {
'contactIds' => 'contact',
'companyIds' => 'company',
'dealIds' => 'deal',
};
$shouldIncludeRemoved = $this->shouldIncludeRemovedAssociations($type, $added, $activity);
if (! empty($removed) && ! $shouldIncludeRemoved) {
$this->logger->info('[HubSpot] Skipping association removal', [
'team' => $this->team->getUuid(),
'type' => $type,
'oldIds' => $oldIds,
'currentIds' => $currentIds,
'skippedRemovals' => array_values($removed),
]);
}
if (! empty($added) || (! empty($removed) && $shouldIncludeRemoved)) {
$changes[$type] = [
'added' => array_values($added),
'removed' => array_values($removed),
];
}
}
return $changes;
}
/**
* Determines whether removed associations should be synced to HubSpot.
*
* For contacts and companies, we always sync removals (original behavior).
* For deals, we only sync removals when:
* - There are new deals being added (replacement scenario), OR
* - The activity has an account associated (indicating intentional association management)
*
* This prevents accidentally removing deal associations that exist in HubSpot
* but not in Jiminny's database (e.g., deals manually added by users in HubSpot).
*/
private function shouldIncludeRemovedAssociations(string $type, array $added, Activity $activity): bool
{
// Contacts and companies: always sync removals
if ($type !== 'deal') {
return true;
}
// Deals: sync removals if we're adding new deals (replacement)
if (! empty($added)) {
return true;
}
// Deals: sync removals only if activity has an account (intentional management)
return $activity->hasAccount();
}
private function normalizeIds(array $ids): array
{
$stringIds = array_map('strval', $ids);
$uniqueIds = array_unique($stringIds);
sort($uniqueIds);
return $uniqueIds;
}
private function updateAssociations(Activity $activity, array $associationChanges): void
{
$objectType = $activity->isTypeConference() ? 'meeting' : 'call';
foreach ($associationChanges as $type => $changes) {
if (! empty($changes['added'])) {
$associationType = (new AssociationTypeIdV4())->getAssociationType($objectType, $type);
$payload = $this->payloadBuilder->buildAddAssociationPayload(
$activity->getCrmProviderId(),
$changes['added'],
$associationType
);
$this->getClient()->addAssociations($objectType, $type, $payload);
}
if (! empty($changes['removed'])) {
$payload = $this->payloadBuilder->buildRemoveAssociationPayload(
$activity->getCrmProviderId(),
$changes['removed']
);
$this->getClient()->removeAssociations($objectType, $type, $payload);
}
}
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function updateMeetingV3(string $meetingId, array $engagement, array $metadata): Response
{
// If already set by us/client, do not override it
if (isset($engagement['activityType']) && $this->hasEngagementActivityType($meetingId)) {
$this->logger->info('[HubSpot] Meeting activity type already set', [
'meetingId' => $meetingId,
'activityType' => $engagement['activityType'],
]);
unset($engagement['activityType']);
}
$payload = $this->payloadBuilder->getV3MeetingPayload($engagement, $metadata);
return $this->getClient()->updateMeeting($meetingId, $payload);
}
private function hasEngagementActivityType(string $engagementId): bool
{
try {
$engagementData = $this->getClient()->getEngagementData($engagementId);
if (isset($engagementData['engagement']['activityType']) && trim($engagementData['engagement']['activityType']) != '') {
return true;
}
return false;
} catch (\Exception $exception) {
Sentry::captureException($exception);
$this->logger->info('[HubSpot] Exception checking engagement activity type, defaulting to preserve existing', [
'engagementId' => $engagementId,
'exception' => $exception->getMessage(),
]);
}
return true;
}
private function updateTask(Activity $activity, array $engagement, array $metadata): void
{
$this->getClient()->deleteEngagement($activity->getCrmProviderId());
$this->logCrmEngagementManipulation(
self::ACTION_DELETE,
['crmId' => $activity->getCrmProviderId()],
);
$this->createActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createActivity(Activity $activity, array $engagement, array $metadata): void
{
$associations = $this->getActivityAssociations($activity);
$associationsV4 = $this->convertActivityMeetingAssociationsV4($activity);
if ($activity->isTypeConference()) {
try {
$hsEngagement = $this->createMeetingV3($engagement, $associationsV4, $metadata);
$activityId = $hsEngagement->data->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associationsV4);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
} else {
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
$activityId = $hsEngagement->data->engagement->id;
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
$activity->crm_provider_id = $activityId;
$activity->save();
} catch (BadRequest $exception) {
Sentry::captureException($exception);
$this->logger->warning('[HubSpot] Error while creating engagements', [
'activity' => $activity->getUuid(),
'message' => $exception->getMessage(),
'engagement' => $engagement,
'associations' => $associations,
'metadata' => $metadata,
]);
}
}
}
private function convertActivityMeetingAssociationsV4(Activity $activity): array
{
$associations = [];
$contactIds = $this->getParticipantsIds($activity);
foreach ($contactIds as $contactId) {
$associations[] = $this->buildAssociation(
(int) $contactId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_CONTACT]
);
}
if ($activity->hasAccount()) {
$crmProviderId = $activity->getAccount()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_COMPANY]
);
}
}
if ($activity->hasOpportunity()) {
$crmProviderId = $activity->getOpportunity()?->getCrmProviderId();
if ($crmProviderId) {
$associations[] = $this->buildAssociation(
(int) $crmProviderId,
[AssociationCategoryV4::HUBSPOT_DEFINED => AssociationTypeIdV4::MEETING_TO_DEAL]
);
}
}
return $associations;
}
private function buildAssociation(int $id, array $categoryToTypeIds): array
{
$types = [];
foreach ($categoryToTypeIds as $category => $typeId) {
$types[] = $this->buildAssociationType($category, $typeId);
}
return [
'to' => ['id' => (string) $id],
'types' => $types,
];
}
private function buildAssociationType(string $category, int $typeId): array
{
return [
'associationCategory' => $category,
'associationTypeId' => $typeId,
];
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function createMeetingV3(array $engagement, array $associations, array $metadata): Response
{
$payload = $this->payloadBuilder->getV3MeetingPayload(
engagement: $engagement,
metadata: $metadata,
associations: $associations
);
return $this->getClient()->createMeeting($payload);
}
/**
* @throws BadRequest
* @throws HubspotException
*/
private function buildSoftphonePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'CALL',
];
if ($activity->hasActivityType() && $this->matchesCrmType($activity->getActivityType())) {
$engagement['activityType'] = $activity->getActivityType()->getName();
}
$metadata = [
'toNumber' => $decorator->formatCallToParticipant($activity),
'fromNumber' => $activity->getFromParticipant()?->getPhoneNumber(),
'status' => $decorator->convertCallStatus($activity),
'durationMilliseconds' => (int) $activity->getDuration() * 1000,
'body' => $decorator->generateDescription($activity),
];
// For now, this is just a "disposition" field to store Call Outcome.
$metadata = array_merge($metadata, $this->fetchCustomFieldData($activity, Field::OBJECT_TASK));
return $this->upsertActivity($activity, $engagement, $metadata);
}
/**
* @throws HubspotException
* @throws BadRequest
*/
private function buildTextMessagePayload(Activity $activity): Activity
{
$decorator = $this->getDecorateActivity();
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $decorator->formatCreatedAt($activity),
'type' => 'NOTE',
];
$metadata = [
'body' => $decorator->generateDescription($activity),
];
return $this->upsertActivity($activity, $engagement, $metadata);
}
private function getActivityAssociations(Activity $activity): array
{
return [
'contactIds' => $this->getParticipantsIds($activity),
'companyIds' => $activity->hasAccount() ? [$activity->getAccount()->getCrmProviderId()] : [],
'dealIds' => $activity->hasOpportunity() ? [$activity->getOpportunity()->getCrmProviderId()] : [],
'ownerIds' => [],
];
}
/**
* Get DecorateActivity instance. Can be overridden in tests for mocking.
*/
protected function getDecorateActivity(): DecorateActivity
{
return new DecorateActivity();
}
public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
if (empty($fields['subject'])) {
return null;
}
$associations = $this->getActivityAssociations($activity);
if (empty($fields['timestamp']) === false) {
$formatTimestamp = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['timestamp']);
$timestamp = $formatTimestamp->getTimestamp();
} else {
$timestamp = strtotime('+1 day');
}
$reminder = null;
if (empty($fields['reminder']) === false) {
$formatReminder = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $fields['reminder']);
$reminder = $formatReminder->getTimestamp() * 1000;
}
$engagement = [
'active' => true,
'ownerId' => $this->profile->getCrmProviderId(),
'timestamp' => $timestamp * 1000,
'type' => 'TASK',
];
$metadata = [
'subject' => $fields['subject'],
'body' => '',
'status' => 'NOT_STARTED',
'taskType' => 'CALL',
'reminders' => $reminder ? [$reminder] : [],
];
try {
$hsEngagement = $this->getClient()->createEngagement($engagement, $associations, $metadata);
} catch (BadRequest $e) {
$this->logger->info('[HubSpot] Failed to create followup task', [
'activity' => $activity->getUuid(),
'engagement' => $engagement,
'metadata' => $metadata,
'error' => $e->getMessage(),
]);
return null;
}
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
// We don't actually create a corresponding activity object on our side yet.
return (string) $hsEngagement->data->engagement->id;
}
private function logCrmEngagementManipulation(
string $action,
array $engagementData,
array $data = [],
array $associations = [],
): void {
$payload = ['team' => $this->team->getUuid()];
if ($action === self::ACTION_CREATE) {
$payload['engagementData'] = $engagementData;
$payload['data'] = $data;
$payload['associations'] = $associations;
}
if ($action === self::ACTION_UPDATE) {
$payload['engagementId'] = $engagementData['crmId'];
$payload['data'] = $data;
}
if ($action === self::ACTION_DELETE) {
$payload['engagementId'] = $engagementData['crmId'];
}
$this->logger->info('[HubSpot] Engagement manipulated (' . $action . ')', $payload);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
45454
|
NULL
|
NULL
|
NULL
|
|
45456
|
1627
|
6
|
2026-05-14T14:38:03.983210+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769483983_m1.jpg...
|
PhpStorm
|
faVsco.js – DecorateActivity.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-5840353787124240911
|
-7195274138713911831
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit K vHandleHubspotRateLimitTestv100% C8• Thu 14 May 17:38:03* :QProject vAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.php:=custom.log+ SyncCrmEntitiesTrait.phpPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.phpT SyncFieldsTrait.php+ WriteCrmTrait.php© ImportActivityTypes.phpT WriteCrmTrait.phpDecorateActivity.php x© Salesforce/Service.phpT LogActivityTrait.php> D Utils© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpD WebhookT ActivityPlaybookTrait.php18.••© BatchSyncCollector.php© BatchSyncRedisService.php© DetachActivityObject.php© Client.php© ClosedDealStagesService.php© PlainTextDecorateActivity.php-env© HubspotPaginationService.phpHandleHubspotRateLimit.php5namespace Jiminny (Services\Crm Hubspot;© CrmHelperRepository.phpAccountController.php=.env.stagingRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php01 A2 A15 X12 ^G DealFieldsService.php© DecorateActivity.phpuse© FieldDefinitions.php© FieldTypeConverter.php© HubspotClientinterface.php121314classDecorateActivity extends BaseDecorateActivity© HubspotTokenManager.php5 usages© PayloadBuilder.php© RemoteCrmObjectManipulatoi© ResponseNormalize.php© Service.php© SyncFieldAction.php© SyncRelatedActivityManager.|© WebhookSyncBatchProcessolv D IntegrationApp• AccessorsD ApiD ConfigDDTOD Filters→ Jobs• ProspectSearchStrategy• ServiceTraits© DataClient.php15 C1617 ©181920|2122232425262728293045public const string JIMINNX_MARKER = 'Jiminny Summary:' ;public function generateTitle(Activity $activity): ?stringif ($activity->hasTitle()) {$title = $activity->getTitle();} elseif ($activity->hasActivityTypeO)) {$title = $activity->getActivityType() ->getName();} else {$title = 'Conference Call':return $title;public function convertMeetingOutcome(Activity Sactivity): ?string{...}© DecorateActivity.php2 usages© LocalSearch.php46public function convertCallStatus(Activity $activity): string{...}© LocalSearchlnterface.php55DamntaCaornhnhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)=laravel.logSF [jiminny@localhost]A HS_local [jiminny@localho:W4 console [QAI PROD] X4 console [PROD]A console (EU]D68 jiminny084143 ×4 ^215•m_layout_id =2162,1661,66799,662172181 219id = 33;122281— 221|222=223— 224|id THEN •(own225226_227228229230hubspot':=231— 232-233V= 11512582;_234W Windsurf Teams17:21UTF-8Ca 4 spaces...
|
45453
|
NULL
|
NULL
|
NULL
|
|
45458
|
1628
|
6
|
2026-05-14T14:38:03.998118+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769483998_m2.jpg...
|
PhpStorm
|
faVsco.js – DecorateActivity.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-1234920426369963436
|
-7196396190330140245
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preview insackt[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.38Yesterday at 13:38Yesterday at 13.3/Yesterdav at 13:36Yesterday at 13:36resterday at 15.3oYesterdav at 13:39Yesterday at 13:34Yesterday at 13.33Yesterdav at 13:33resterday at 15.32Yesterdav at 13:31Yesterday at 13:30Yesterday at 13:30Yesterday at 13:29resterday at 13.2oYesterdav at 13:28Yesterday at 13:27Yesterday at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13.25Yesterdav at 13:24Yesterdav at 13:24Yesterday at 13:23Yesterday at 13.20Yecterdav at 12:20Yesterdav at 13:19Yesterday at 13.19Yesterdav at 13:18Yesterday at 13:18Yesterday at 13:17Yactordav at 12:16Yesterdav at 13:16Yesterday at 13.1Yecterdav at 12:15Yesterday at 13:14Yesterday at 13:13Yoctorday at 12:12Yesterdav at 13:12Yesterday at 13.12Yesterdav at 13:10v Size100 K:MPEG-4 movie88 KB62 KB/1 Kb23 KB9 KB13 KB16 K:MPEG-4 movieMPEG-4 movieMPEG-4 movieMPEO"4 movie17 KB29 KBMDSG-A movieMP2G-4 movie12 KBMPFG-A movieI KD8 KEMPEG"4 movieMPEG-4 movie37 KBMPEG-4 movie10 KB7K:MPEG-4 movie8 KRI9 KB8 KBMPEG-1 movieMPEG-4 movie72 KEMPEG-4 movie14 KB13 KBMPEG-4 movie9 KBIMPEG-4 movie19 KPMDEC.A movic10 KBMPEG-4 movie16 KEMPEG-4 movie6 KBMPEG-4 movie6 KBMPEG-4 movie12 K:23 KBMDEC A movid6KBMPEG-4 movieAKP11 KB11 KBMDEG-A movie20 K:34 KB10 KB7 KBMPEG-4 movieMDEC.A movialMPEG-4 movieMDSG-A movie11 KB26 KBMPEG-4 movie111 KBIMPSG-A movie102 KB MPEG-4 movie88 KB59 KB09 kpMPEG-4 movieMDEG.A movio97 KB66 KBMPEG-4 movieAAKPMDEG-A movie93 KBMPEG-4 movie78 KB50 K8MPEG-4 movieAl Notes: OffLeaveFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc tolde0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zipreport(2).xmlAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esviconfig.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentPDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archive5KRMarkdo…..umentWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.46 GB availabld• Inu 14 May 1/.30.0.Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45457
|
1627
|
7
|
2026-05-14T14:38:05.590243+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769485590_m1.jpg...
|
PhpStorm
|
faVsco.js – DecorateActivity.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
2
15
12
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot;
use Illuminate\Support\Collection;
use Jiminny\Models\Activity;
use Jiminny\Repositories\ActivityMessageRepository;
use Jiminny\Repositories\ParticipantRepository;
use Jiminny\Services\Crm\DecorateActivity\BaseDecorateActivity;
class DecorateActivity extends BaseDecorateActivity
{
public const string JIMINNY_MARKER = 'Jiminny Summary:';
public function generateTitle(Activity $activity): ?string
{
if ($activity->hasTitle()) {
$title = $activity->getTitle();
} elseif ($activity->hasActivityType()) {
$title = $activity->getActivityType()->getName();
} else {
$title = 'Conference Call';
}
return $title;
}
public function convertMeetingOutcome(Activity $activity): ?string
{
switch ($activity->getStatus()) {
case Activity::STATUS_SCHEDULED:
return 'SCHEDULED';
case Activity::STATUS_CANCELLED:
return 'CANCELED';
case Activity::STATUS_COMPLETED:
return 'COMPLETED';
//case Activity::STATUS_NO_SHOW:
// return 'NO_SHOW';
default:
return null;
}
}
public function convertCallStatus(Activity $activity): string
{
switch ($activity->getStatus()) {
case Activity::STATUS_NO_ANSWER:
return 'NO_ANSWER';
default:
return 'COMPLETED';
}
}
public function generateDescription(Activity $activity): ?string
{
if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {
return $this->formatSmsDescription($activity);
}
$description = $this->baseDescription();
if ($activity->hasTitle() && $activity->hasActivityType()) {
$description .= $this->formatActivityType($activity->getActivityType()->getName());
}
if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {
$description .= $this->formatSoftphoneDetails($activity);
}
$description .= $this->formatReasonOrPreview($activity);
if ($activity->isTypeConference()) {
$description .= $this->formatAttendeesList($activity);
}
return $description
. $this->formatNotes($activity)
. $this->formatMessages($activity)
. $this->formatSummary($activity);
}
public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string
{
if (empty($existingCrmDescription)) {
return $jiminnyDescription;
}
if (! $this->isJiminnyDescription($existingCrmDescription)) {
return $existingCrmDescription . '<hr>' . $jiminnyDescription;
}
$existingSections = $this->parseHtmlSections($existingCrmDescription);
$newSections = $this->parseHtmlSections($jiminnyDescription);
return $this->mergeHtmlSections($newSections, $existingSections);
}
private function parseHtmlSections(string $html): array
{
$sections = [
'beforeJiminny' => '',
'header' => '',
];
foreach (self::SECTION_HEADERS as $name) {
$sections[$name] = '';
}
$headerStartPos = $this->findHeaderStartPosition($html);
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($headerStartPos !== false && $headerStartPos > 0) {
$sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));
}
if ($headerStartPos !== false) {
$jiminnyStart = $headerStartPos;
} elseif ($markerPos !== false) {
$jiminnyStart = $markerPos;
} else {
$jiminnyStart = 0;
}
$firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);
if ($firstSectionPos === false) {
$sections['header'] = substr($html, $jiminnyStart);
} else {
$sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);
}
$sections['header'] = trim($sections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);
}
return $sections;
}
private function findHeaderStartPosition(string $html): int|false
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*<span[^>]*>\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
return $matches[0][1];
}
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($markerPos === false) {
return false;
}
$beforeMarker = substr($html, 0, $markerPos);
$lastPTagPos = strrpos($beforeMarker, '<p');
return $lastPTagPos !== false ? $lastPTagPos : $markerPos;
}
private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false
{
$firstPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($firstPos === false || $pos < $firstPos) {
$firstPos = $pos;
}
}
}
return $firstPos;
}
private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
return '';
}
$headerMatch = $matches[0][0];
$headerPos = $matches[0][1];
$contentStart = $headerPos + strlen($headerMatch);
$nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);
if ($nextSectionPos === false) {
$content = substr($html, $contentStart);
} else {
$content = substr($html, $contentStart, $nextSectionPos - $contentStart);
}
return trim($content);
}
private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false
{
$nextPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($nextPos === false || $pos < $nextPos) {
$nextPos = $pos;
}
}
}
return $nextPos;
}
private function mergeHtmlSections(array $newSections, array $existingSections): string
{
$result = '';
if (! empty($existingSections['beforeJiminny'])) {
$result .= $existingSections['beforeJiminny'];
}
$result .= $this->wrapHeader($newSections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$existingContent = $existingSections[$sectionName] ?? '';
$newContent = $newSections[$sectionName] ?? '';
$content = ! empty($existingContent) ? $existingContent : $newContent;
if (! empty($content)) {
$result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;
}
}
return $result;
}
private function wrapHeader(string $header): string
{
$header = trim($header);
if (str_starts_with($header, '<p>')) {
return $header;
}
if (str_starts_with($header, self::JIMINNY_MARKER)) {
return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));
}
return $header;
}
private function baseDescription(): string
{
return sprintf(
'<p><strong><span style="font-size: 15px; line-height: 30px;">%s</span></strong></p>',
'Jiminny Summary:'
);
}
private function formatSoftphoneDetails(Activity $activity): string
{
$isOutbound = $activity->isTypeSoftPhone();
$isInbound = $activity->isTypeSoftphoneInbound();
if (! $isOutbound && ! $isInbound) {
return '';
}
$output = $this->formatTitle($activity->getTitle());
$output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));
$phone = $isOutbound
? $activity->to?->phone_number
: $activity->from?->phone_number;
if ($phone) {
$output .= $isOutbound
? $this->formatDialedNumber($phone)
: $this->formatCallerNumber($phone);
}
return $output . '<p></p>';
}
private function formatReasonOrPreview(Activity $activity): string
{
if ($activity->hasReasonCodeBotKicked()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker removed from this meeting'
. '</span></p>';
}
if ($activity->hasReasonCodeNotCompliant()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker did not join due to recording consent not being provided by attendees'
. '</span></p>';
}
return $this->formatPreviewUrl($activity);
}
public function formatStartTime(Activity $activity): int
{
return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatEndTime(Activity $activity): int
{
return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCreatedAt(Activity $activity): int
{
return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCallToParticipant(Activity $activity): ?string
{
$callToParticipant = $activity->getToParticipant()?->getPhoneNumber();
if ($callToParticipant && $activity->hasContact()) {
return $activity->getContact()->getName() . ' ' . $callToParticipant;
}
return null;
}
private function formatActivityType(string $activityType): string
{
return '<p><strong><span style="font-size: 18.6667px; line-height: 22.4px;">' . $activityType . '</span></strong></p>';
}
private function formatTitle(?string $title): string
{
return $title ? '<p><span style="font-size: 16px; line-height: 19.2px;">' . $title . '</span></p>' : '';
}
private function formatCallDuration(string $duration): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Call Duration: ' . $duration . '</span></p>';
}
private function formatDialedNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Dialed: ' . $phoneNumber . '</span></p>';
}
private function formatCallerNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Caller: ' . $phoneNumber . '</span></p>';
}
private function formatAttendeesList(Activity $activity): string
{
$attendeesList = '<p><strong>Attendees</strong></p><ul>';
$participantsRepository = app(ParticipantRepository::class);
// Only include participants that joined.
$participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);
foreach ($participants as $participant) {
$attendee = '<li>';
if ($participant->hasName()) {
$attendee .= $participant->getName();
if ($participant->hasPhoneNumber()) {
$attendee .= ' (' . $participant->getPhoneNumber() . ')';
} elseif ($participant->hasEmailAddress()) {
$attendee .= ' (' . $participant->getEmailAddress() . ')';
}
} else {
$attendee .= $participant->getPhoneNumber();
}
if ($participant->isCoach()) {
$attendee .= ' <strong>coach</strong>';
}
if ($participant->getTitle()) {
$attendee .= ', ' . $participant->getTitle();
}
$attendeesList .= $attendee . '</li>';
}
return $attendeesList . '</ul>';
}
private function formatPreviewUrl(Activity $activity): string
{
$description = '';
$team = $activity->getUser()->getTeam();
if ($activity->canReviewActivity()) {
$playbackUrl = $team->getPartner()->getPlaybackUrl($activity);
$description .= '<p><span style="font-size: 13.3333px; line-height: 16px;"><a href="'
. $playbackUrl
. '" target="_blank">Review in Jiminny</a> ▶️</span></p>';
}
return $description;
}
private function formatNotes(Activity $activity): string
{
$description = '';
if ($activity->getNotes()->isEmpty()) {
return $description;
}
$description .= '<p><strong>Notes</strong></p>';
foreach ($activity->getNotes() as $note) {
$time = ($note->getTime() > 3600)
? gmdate('H:i:s', (int) $note->getTime())
: gmdate('i:s', (int) $note->getTime());
$description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';
}
return $description . '</p>';
}
private function formatMessages(Activity $activity): string
{
$description = '';
$messageRepository = app(ActivityMessageRepository::class);
// Get all private messages.
$privateMessages = $messageRepository->getPrivateMessages($activity);
if ($privateMessages->isNotEmpty()) {
$description .= '<p><strong>Coaching Chat</strong></p>';
$description .= $this->getMessagesAsString($privateMessages);
$description .= '</p>';
}
// Get all public messages
$publicMessages = $messageRepository->getPublicMessages($activity);
if ($publicMessages->isNotEmpty()) {
$description .= '<p><strong>Customer Chat</strong></p>';
$description .= $this->getMessagesAsString($publicMessages);
$description .= '</p>';
}
return $description;
}
private function getMessagesAsString(Collection $messages): string
{
$description = '';
/** @var Activity\Message $message */
foreach ($messages as $message) {
$description .= '<p>' . $message->participant->getName()
. ': ' . $message->getAttribute('message') . '</p>';
}
return $description;
}
private function formatSummary(Activity $activity): string
{
$description = '';
if ($activity->getSummary() !== null) {
$description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';
}
return $description;
}
private function formatSmsDescription(Activity $activity): string
{
// Use Rich-text formatting.
$description = '<p><span style="font-size: 16px; line-height: 19.2px;"><strong>' . $activity->getTitle() . '</strong></span></p>';
$description .= '<p><span style="font-size: 16px; line-height: 19.2px;">' . $activity->getDescription() . '</span></p>';
return $description;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.73333335,"top":0.3122222,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.75277776,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.7736111,"top":0.3122222,"width":0.02013889,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"12","depth":4,"bounds":{"left":0.79791665,"top":0.3122222,"width":0.02013889,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Repositories\\ActivityMessageRepository;\nuse Jiminny\\Repositories\\ParticipantRepository;\nuse Jiminny\\Services\\Crm\\DecorateActivity\\BaseDecorateActivity;\n\nclass DecorateActivity extends BaseDecorateActivity\n{\n public const string JIMINNY_MARKER = 'Jiminny Summary:';\n\n public function generateTitle(Activity $activity): ?string\n {\n if ($activity->hasTitle()) {\n $title = $activity->getTitle();\n } elseif ($activity->hasActivityType()) {\n $title = $activity->getActivityType()->getName();\n } else {\n $title = 'Conference Call';\n }\n\n return $title;\n }\n\n public function convertMeetingOutcome(Activity $activity): ?string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_SCHEDULED:\n return 'SCHEDULED';\n case Activity::STATUS_CANCELLED:\n return 'CANCELED';\n case Activity::STATUS_COMPLETED:\n return 'COMPLETED';\n //case Activity::STATUS_NO_SHOW:\n // return 'NO_SHOW';\n default:\n return null;\n }\n }\n\n public function convertCallStatus(Activity $activity): string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_NO_ANSWER:\n return 'NO_ANSWER';\n default:\n return 'COMPLETED';\n }\n }\n\n public function generateDescription(Activity $activity): ?string\n {\n if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {\n return $this->formatSmsDescription($activity);\n }\n\n $description = $this->baseDescription();\n\n if ($activity->hasTitle() && $activity->hasActivityType()) {\n $description .= $this->formatActivityType($activity->getActivityType()->getName());\n }\n\n if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {\n $description .= $this->formatSoftphoneDetails($activity);\n }\n\n $description .= $this->formatReasonOrPreview($activity);\n\n if ($activity->isTypeConference()) {\n $description .= $this->formatAttendeesList($activity);\n }\n\n return $description\n . $this->formatNotes($activity)\n . $this->formatMessages($activity)\n . $this->formatSummary($activity);\n }\n\n public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string\n {\n if (empty($existingCrmDescription)) {\n return $jiminnyDescription;\n }\n\n if (! $this->isJiminnyDescription($existingCrmDescription)) {\n return $existingCrmDescription . '<hr>' . $jiminnyDescription;\n }\n\n $existingSections = $this->parseHtmlSections($existingCrmDescription);\n $newSections = $this->parseHtmlSections($jiminnyDescription);\n\n return $this->mergeHtmlSections($newSections, $existingSections);\n }\n\n private function parseHtmlSections(string $html): array\n {\n $sections = [\n 'beforeJiminny' => '',\n 'header' => '',\n ];\n\n foreach (self::SECTION_HEADERS as $name) {\n $sections[$name] = '';\n }\n\n $headerStartPos = $this->findHeaderStartPosition($html);\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n\n if ($headerStartPos !== false && $headerStartPos > 0) {\n $sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));\n }\n\n if ($headerStartPos !== false) {\n $jiminnyStart = $headerStartPos;\n } elseif ($markerPos !== false) {\n $jiminnyStart = $markerPos;\n } else {\n $jiminnyStart = 0;\n }\n\n $firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);\n\n if ($firstSectionPos === false) {\n $sections['header'] = substr($html, $jiminnyStart);\n } else {\n $sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);\n }\n\n $sections['header'] = trim($sections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);\n }\n\n return $sections;\n }\n\n private function findHeaderStartPosition(string $html): int|false\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*<span[^>]*>\\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';\n\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {\n return $matches[0][1];\n }\n\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n if ($markerPos === false) {\n return false;\n }\n\n $beforeMarker = substr($html, 0, $markerPos);\n $lastPTagPos = strrpos($beforeMarker, '<p');\n\n return $lastPTagPos !== false ? $lastPTagPos : $markerPos;\n }\n\n private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false\n {\n $firstPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($firstPos === false || $pos < $firstPos) {\n $firstPos = $pos;\n }\n }\n }\n\n return $firstPos;\n }\n\n private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n\n if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n return '';\n }\n\n $headerMatch = $matches[0][0];\n $headerPos = $matches[0][1];\n $contentStart = $headerPos + strlen($headerMatch);\n\n $nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);\n\n if ($nextSectionPos === false) {\n $content = substr($html, $contentStart);\n } else {\n $content = substr($html, $contentStart, $nextSectionPos - $contentStart);\n }\n\n return trim($content);\n }\n\n private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false\n {\n $nextPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($nextPos === false || $pos < $nextPos) {\n $nextPos = $pos;\n }\n }\n }\n\n return $nextPos;\n }\n\n private function mergeHtmlSections(array $newSections, array $existingSections): string\n {\n $result = '';\n\n if (! empty($existingSections['beforeJiminny'])) {\n $result .= $existingSections['beforeJiminny'];\n }\n\n $result .= $this->wrapHeader($newSections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $existingContent = $existingSections[$sectionName] ?? '';\n $newContent = $newSections[$sectionName] ?? '';\n\n $content = ! empty($existingContent) ? $existingContent : $newContent;\n\n if (! empty($content)) {\n $result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;\n }\n }\n\n return $result;\n }\n\n private function wrapHeader(string $header): string\n {\n $header = trim($header);\n\n if (str_starts_with($header, '<p>')) {\n return $header;\n }\n\n if (str_starts_with($header, self::JIMINNY_MARKER)) {\n return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));\n }\n\n return $header;\n }\n\n private function baseDescription(): string\n {\n return sprintf(\n '<p><strong><span style=\"font-size: 15px; line-height: 30px;\">%s</span></strong></p>',\n 'Jiminny Summary:'\n );\n }\n\n private function formatSoftphoneDetails(Activity $activity): string\n {\n $isOutbound = $activity->isTypeSoftPhone();\n $isInbound = $activity->isTypeSoftphoneInbound();\n\n if (! $isOutbound && ! $isInbound) {\n return '';\n }\n\n $output = $this->formatTitle($activity->getTitle());\n $output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));\n\n $phone = $isOutbound\n ? $activity->to?->phone_number\n : $activity->from?->phone_number;\n\n if ($phone) {\n $output .= $isOutbound\n ? $this->formatDialedNumber($phone)\n : $this->formatCallerNumber($phone);\n }\n\n return $output . '<p></p>';\n }\n\n private function formatReasonOrPreview(Activity $activity): string\n {\n if ($activity->hasReasonCodeBotKicked()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker removed from this meeting'\n . '</span></p>';\n }\n\n if ($activity->hasReasonCodeNotCompliant()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker did not join due to recording consent not being provided by attendees'\n . '</span></p>';\n }\n\n return $this->formatPreviewUrl($activity);\n }\n\n\n public function formatStartTime(Activity $activity): int\n {\n return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatEndTime(Activity $activity): int\n {\n return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCreatedAt(Activity $activity): int\n {\n return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCallToParticipant(Activity $activity): ?string\n {\n $callToParticipant = $activity->getToParticipant()?->getPhoneNumber();\n if ($callToParticipant && $activity->hasContact()) {\n return $activity->getContact()->getName() . ' ' . $callToParticipant;\n }\n\n return null;\n }\n\n private function formatActivityType(string $activityType): string\n {\n return '<p><strong><span style=\"font-size: 18.6667px; line-height: 22.4px;\">' . $activityType . '</span></strong></p>';\n }\n\n private function formatTitle(?string $title): string\n {\n return $title ? '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $title . '</span></p>' : '';\n }\n\n private function formatCallDuration(string $duration): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Call Duration: ' . $duration . '</span></p>';\n }\n\n private function formatDialedNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Dialed: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatCallerNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Caller: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatAttendeesList(Activity $activity): string\n {\n $attendeesList = '<p><strong>Attendees</strong></p><ul>';\n\n $participantsRepository = app(ParticipantRepository::class);\n // Only include participants that joined.\n $participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);\n foreach ($participants as $participant) {\n $attendee = '<li>';\n if ($participant->hasName()) {\n $attendee .= $participant->getName();\n if ($participant->hasPhoneNumber()) {\n $attendee .= ' (' . $participant->getPhoneNumber() . ')';\n } elseif ($participant->hasEmailAddress()) {\n $attendee .= ' (' . $participant->getEmailAddress() . ')';\n }\n } else {\n $attendee .= $participant->getPhoneNumber();\n }\n\n if ($participant->isCoach()) {\n $attendee .= ' <strong>coach</strong>';\n }\n\n if ($participant->getTitle()) {\n $attendee .= ', ' . $participant->getTitle();\n }\n\n $attendeesList .= $attendee . '</li>';\n }\n\n return $attendeesList . '</ul>';\n }\n\n private function formatPreviewUrl(Activity $activity): string\n {\n $description = '';\n $team = $activity->getUser()->getTeam();\n\n if ($activity->canReviewActivity()) {\n $playbackUrl = $team->getPartner()->getPlaybackUrl($activity);\n $description .= '<p><span style=\"font-size: 13.3333px; line-height: 16px;\"><a href=\"'\n . $playbackUrl\n . '\" target=\"_blank\">Review in Jiminny</a> ▶️</span></p>';\n }\n\n return $description;\n }\n\n private function formatNotes(Activity $activity): string\n {\n $description = '';\n if ($activity->getNotes()->isEmpty()) {\n return $description;\n }\n\n $description .= '<p><strong>Notes</strong></p>';\n foreach ($activity->getNotes() as $note) {\n $time = ($note->getTime() > 3600)\n ? gmdate('H:i:s', (int) $note->getTime())\n : gmdate('i:s', (int) $note->getTime());\n\n $description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';\n }\n\n return $description . '</p>';\n }\n\n private function formatMessages(Activity $activity): string\n {\n $description = '';\n $messageRepository = app(ActivityMessageRepository::class);\n\n // Get all private messages.\n $privateMessages = $messageRepository->getPrivateMessages($activity);\n if ($privateMessages->isNotEmpty()) {\n $description .= '<p><strong>Coaching Chat</strong></p>';\n $description .= $this->getMessagesAsString($privateMessages);\n $description .= '</p>';\n }\n\n // Get all public messages\n $publicMessages = $messageRepository->getPublicMessages($activity);\n if ($publicMessages->isNotEmpty()) {\n $description .= '<p><strong>Customer Chat</strong></p>';\n $description .= $this->getMessagesAsString($publicMessages);\n $description .= '</p>';\n }\n\n return $description;\n }\n\n private function getMessagesAsString(Collection $messages): string\n {\n $description = '';\n\n /** @var Activity\\Message $message */\n foreach ($messages as $message) {\n $description .= '<p>' . $message->participant->getName()\n . ': ' . $message->getAttribute('message') . '</p>';\n }\n\n return $description;\n }\n\n private function formatSummary(Activity $activity): string\n {\n $description = '';\n if ($activity->getSummary() !== null) {\n $description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';\n }\n\n return $description;\n }\n\n private function formatSmsDescription(Activity $activity): string\n {\n // Use Rich-text formatting.\n $description = '<p><span style=\"font-size: 16px; line-height: 19.2px;\"><strong>' . $activity->getTitle() . '</strong></span></p>';\n $description .= '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $activity->getDescription() . '</span></p>';\n\n return $description;\n }\n}","depth":4,"bounds":{"left":0.26666668,"top":0.21111111,"width":0.6548611,"height":0.7888889},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Repositories\\ActivityMessageRepository;\nuse Jiminny\\Repositories\\ParticipantRepository;\nuse Jiminny\\Services\\Crm\\DecorateActivity\\BaseDecorateActivity;\n\nclass DecorateActivity extends BaseDecorateActivity\n{\n public const string JIMINNY_MARKER = 'Jiminny Summary:';\n\n public function generateTitle(Activity $activity): ?string\n {\n if ($activity->hasTitle()) {\n $title = $activity->getTitle();\n } elseif ($activity->hasActivityType()) {\n $title = $activity->getActivityType()->getName();\n } else {\n $title = 'Conference Call';\n }\n\n return $title;\n }\n\n public function convertMeetingOutcome(Activity $activity): ?string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_SCHEDULED:\n return 'SCHEDULED';\n case Activity::STATUS_CANCELLED:\n return 'CANCELED';\n case Activity::STATUS_COMPLETED:\n return 'COMPLETED';\n //case Activity::STATUS_NO_SHOW:\n // return 'NO_SHOW';\n default:\n return null;\n }\n }\n\n public function convertCallStatus(Activity $activity): string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_NO_ANSWER:\n return 'NO_ANSWER';\n default:\n return 'COMPLETED';\n }\n }\n\n public function generateDescription(Activity $activity): ?string\n {\n if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {\n return $this->formatSmsDescription($activity);\n }\n\n $description = $this->baseDescription();\n\n if ($activity->hasTitle() && $activity->hasActivityType()) {\n $description .= $this->formatActivityType($activity->getActivityType()->getName());\n }\n\n if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {\n $description .= $this->formatSoftphoneDetails($activity);\n }\n\n $description .= $this->formatReasonOrPreview($activity);\n\n if ($activity->isTypeConference()) {\n $description .= $this->formatAttendeesList($activity);\n }\n\n return $description\n . $this->formatNotes($activity)\n . $this->formatMessages($activity)\n . $this->formatSummary($activity);\n }\n\n public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string\n {\n if (empty($existingCrmDescription)) {\n return $jiminnyDescription;\n }\n\n if (! $this->isJiminnyDescription($existingCrmDescription)) {\n return $existingCrmDescription . '<hr>' . $jiminnyDescription;\n }\n\n $existingSections = $this->parseHtmlSections($existingCrmDescription);\n $newSections = $this->parseHtmlSections($jiminnyDescription);\n\n return $this->mergeHtmlSections($newSections, $existingSections);\n }\n\n private function parseHtmlSections(string $html): array\n {\n $sections = [\n 'beforeJiminny' => '',\n 'header' => '',\n ];\n\n foreach (self::SECTION_HEADERS as $name) {\n $sections[$name] = '';\n }\n\n $headerStartPos = $this->findHeaderStartPosition($html);\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n\n if ($headerStartPos !== false && $headerStartPos > 0) {\n $sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));\n }\n\n if ($headerStartPos !== false) {\n $jiminnyStart = $headerStartPos;\n } elseif ($markerPos !== false) {\n $jiminnyStart = $markerPos;\n } else {\n $jiminnyStart = 0;\n }\n\n $firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);\n\n if ($firstSectionPos === false) {\n $sections['header'] = substr($html, $jiminnyStart);\n } else {\n $sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);\n }\n\n $sections['header'] = trim($sections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);\n }\n\n return $sections;\n }\n\n private function findHeaderStartPosition(string $html): int|false\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*<span[^>]*>\\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';\n\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {\n return $matches[0][1];\n }\n\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n if ($markerPos === false) {\n return false;\n }\n\n $beforeMarker = substr($html, 0, $markerPos);\n $lastPTagPos = strrpos($beforeMarker, '<p');\n\n return $lastPTagPos !== false ? $lastPTagPos : $markerPos;\n }\n\n private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false\n {\n $firstPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($firstPos === false || $pos < $firstPos) {\n $firstPos = $pos;\n }\n }\n }\n\n return $firstPos;\n }\n\n private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n\n if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n return '';\n }\n\n $headerMatch = $matches[0][0];\n $headerPos = $matches[0][1];\n $contentStart = $headerPos + strlen($headerMatch);\n\n $nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);\n\n if ($nextSectionPos === false) {\n $content = substr($html, $contentStart);\n } else {\n $content = substr($html, $contentStart, $nextSectionPos - $contentStart);\n }\n\n return trim($content);\n }\n\n private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false\n {\n $nextPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($nextPos === false || $pos < $nextPos) {\n $nextPos = $pos;\n }\n }\n }\n\n return $nextPos;\n }\n\n private function mergeHtmlSections(array $newSections, array $existingSections): string\n {\n $result = '';\n\n if (! empty($existingSections['beforeJiminny'])) {\n $result .= $existingSections['beforeJiminny'];\n }\n\n $result .= $this->wrapHeader($newSections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $existingContent = $existingSections[$sectionName] ?? '';\n $newContent = $newSections[$sectionName] ?? '';\n\n $content = ! empty($existingContent) ? $existingContent : $newContent;\n\n if (! empty($content)) {\n $result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;\n }\n }\n\n return $result;\n }\n\n private function wrapHeader(string $header): string\n {\n $header = trim($header);\n\n if (str_starts_with($header, '<p>')) {\n return $header;\n }\n\n if (str_starts_with($header, self::JIMINNY_MARKER)) {\n return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));\n }\n\n return $header;\n }\n\n private function baseDescription(): string\n {\n return sprintf(\n '<p><strong><span style=\"font-size: 15px; line-height: 30px;\">%s</span></strong></p>',\n 'Jiminny Summary:'\n );\n }\n\n private function formatSoftphoneDetails(Activity $activity): string\n {\n $isOutbound = $activity->isTypeSoftPhone();\n $isInbound = $activity->isTypeSoftphoneInbound();\n\n if (! $isOutbound && ! $isInbound) {\n return '';\n }\n\n $output = $this->formatTitle($activity->getTitle());\n $output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));\n\n $phone = $isOutbound\n ? $activity->to?->phone_number\n : $activity->from?->phone_number;\n\n if ($phone) {\n $output .= $isOutbound\n ? $this->formatDialedNumber($phone)\n : $this->formatCallerNumber($phone);\n }\n\n return $output . '<p></p>';\n }\n\n private function formatReasonOrPreview(Activity $activity): string\n {\n if ($activity->hasReasonCodeBotKicked()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker removed from this meeting'\n . '</span></p>';\n }\n\n if ($activity->hasReasonCodeNotCompliant()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker did not join due to recording consent not being provided by attendees'\n . '</span></p>';\n }\n\n return $this->formatPreviewUrl($activity);\n }\n\n\n public function formatStartTime(Activity $activity): int\n {\n return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatEndTime(Activity $activity): int\n {\n return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCreatedAt(Activity $activity): int\n {\n return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCallToParticipant(Activity $activity): ?string\n {\n $callToParticipant = $activity->getToParticipant()?->getPhoneNumber();\n if ($callToParticipant && $activity->hasContact()) {\n return $activity->getContact()->getName() . ' ' . $callToParticipant;\n }\n\n return null;\n }\n\n private function formatActivityType(string $activityType): string\n {\n return '<p><strong><span style=\"font-size: 18.6667px; line-height: 22.4px;\">' . $activityType . '</span></strong></p>';\n }\n\n private function formatTitle(?string $title): string\n {\n return $title ? '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $title . '</span></p>' : '';\n }\n\n private function formatCallDuration(string $duration): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Call Duration: ' . $duration . '</span></p>';\n }\n\n private function formatDialedNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Dialed: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatCallerNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Caller: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatAttendeesList(Activity $activity): string\n {\n $attendeesList = '<p><strong>Attendees</strong></p><ul>';\n\n $participantsRepository = app(ParticipantRepository::class);\n // Only include participants that joined.\n $participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);\n foreach ($participants as $participant) {\n $attendee = '<li>';\n if ($participant->hasName()) {\n $attendee .= $participant->getName();\n if ($participant->hasPhoneNumber()) {\n $attendee .= ' (' . $participant->getPhoneNumber() . ')';\n } elseif ($participant->hasEmailAddress()) {\n $attendee .= ' (' . $participant->getEmailAddress() . ')';\n }\n } else {\n $attendee .= $participant->getPhoneNumber();\n }\n\n if ($participant->isCoach()) {\n $attendee .= ' <strong>coach</strong>';\n }\n\n if ($participant->getTitle()) {\n $attendee .= ', ' . $participant->getTitle();\n }\n\n $attendeesList .= $attendee . '</li>';\n }\n\n return $attendeesList . '</ul>';\n }\n\n private function formatPreviewUrl(Activity $activity): string\n {\n $description = '';\n $team = $activity->getUser()->getTeam();\n\n if ($activity->canReviewActivity()) {\n $playbackUrl = $team->getPartner()->getPlaybackUrl($activity);\n $description .= '<p><span style=\"font-size: 13.3333px; line-height: 16px;\"><a href=\"'\n . $playbackUrl\n . '\" target=\"_blank\">Review in Jiminny</a> ▶️</span></p>';\n }\n\n return $description;\n }\n\n private function formatNotes(Activity $activity): string\n {\n $description = '';\n if ($activity->getNotes()->isEmpty()) {\n return $description;\n }\n\n $description .= '<p><strong>Notes</strong></p>';\n foreach ($activity->getNotes() as $note) {\n $time = ($note->getTime() > 3600)\n ? gmdate('H:i:s', (int) $note->getTime())\n : gmdate('i:s', (int) $note->getTime());\n\n $description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';\n }\n\n return $description . '</p>';\n }\n\n private function formatMessages(Activity $activity): string\n {\n $description = '';\n $messageRepository = app(ActivityMessageRepository::class);\n\n // Get all private messages.\n $privateMessages = $messageRepository->getPrivateMessages($activity);\n if ($privateMessages->isNotEmpty()) {\n $description .= '<p><strong>Coaching Chat</strong></p>';\n $description .= $this->getMessagesAsString($privateMessages);\n $description .= '</p>';\n }\n\n // Get all public messages\n $publicMessages = $messageRepository->getPublicMessages($activity);\n if ($publicMessages->isNotEmpty()) {\n $description .= '<p><strong>Customer Chat</strong></p>';\n $description .= $this->getMessagesAsString($publicMessages);\n $description .= '</p>';\n }\n\n return $description;\n }\n\n private function getMessagesAsString(Collection $messages): string\n {\n $description = '';\n\n /** @var Activity\\Message $message */\n foreach ($messages as $message) {\n $description .= '<p>' . $message->participant->getName()\n . ': ' . $message->getAttribute('message') . '</p>';\n }\n\n return $description;\n }\n\n private function formatSummary(Activity $activity): string\n {\n $description = '';\n if ($activity->getSummary() !== null) {\n $description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';\n }\n\n return $description;\n }\n\n private function formatSmsDescription(Activity $activity): string\n {\n // Use Rich-text formatting.\n $description = '<p><span style=\"font-size: 16px; line-height: 19.2px;\"><strong>' . $activity->getTitle() . '</strong></span></p>';\n $description .= '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $activity->getDescription() . '</span></p>';\n\n return $description;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"bounds":{"left":0.8645833,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.8854167,"top":0.34444445,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"bounds":{"left":0.9048611,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.92569447,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.9458333,"top":0.3422222,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.9611111,"top":0.3422222,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.025,"top":0.06666667,"width":0.050694443,"height":0.034444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6902378850207333842
|
9001456016336028185
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
2
15
12
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot;
use Illuminate\Support\Collection;
use Jiminny\Models\Activity;
use Jiminny\Repositories\ActivityMessageRepository;
use Jiminny\Repositories\ParticipantRepository;
use Jiminny\Services\Crm\DecorateActivity\BaseDecorateActivity;
class DecorateActivity extends BaseDecorateActivity
{
public const string JIMINNY_MARKER = 'Jiminny Summary:';
public function generateTitle(Activity $activity): ?string
{
if ($activity->hasTitle()) {
$title = $activity->getTitle();
} elseif ($activity->hasActivityType()) {
$title = $activity->getActivityType()->getName();
} else {
$title = 'Conference Call';
}
return $title;
}
public function convertMeetingOutcome(Activity $activity): ?string
{
switch ($activity->getStatus()) {
case Activity::STATUS_SCHEDULED:
return 'SCHEDULED';
case Activity::STATUS_CANCELLED:
return 'CANCELED';
case Activity::STATUS_COMPLETED:
return 'COMPLETED';
//case Activity::STATUS_NO_SHOW:
// return 'NO_SHOW';
default:
return null;
}
}
public function convertCallStatus(Activity $activity): string
{
switch ($activity->getStatus()) {
case Activity::STATUS_NO_ANSWER:
return 'NO_ANSWER';
default:
return 'COMPLETED';
}
}
public function generateDescription(Activity $activity): ?string
{
if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {
return $this->formatSmsDescription($activity);
}
$description = $this->baseDescription();
if ($activity->hasTitle() && $activity->hasActivityType()) {
$description .= $this->formatActivityType($activity->getActivityType()->getName());
}
if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {
$description .= $this->formatSoftphoneDetails($activity);
}
$description .= $this->formatReasonOrPreview($activity);
if ($activity->isTypeConference()) {
$description .= $this->formatAttendeesList($activity);
}
return $description
. $this->formatNotes($activity)
. $this->formatMessages($activity)
. $this->formatSummary($activity);
}
public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string
{
if (empty($existingCrmDescription)) {
return $jiminnyDescription;
}
if (! $this->isJiminnyDescription($existingCrmDescription)) {
return $existingCrmDescription . '<hr>' . $jiminnyDescription;
}
$existingSections = $this->parseHtmlSections($existingCrmDescription);
$newSections = $this->parseHtmlSections($jiminnyDescription);
return $this->mergeHtmlSections($newSections, $existingSections);
}
private function parseHtmlSections(string $html): array
{
$sections = [
'beforeJiminny' => '',
'header' => '',
];
foreach (self::SECTION_HEADERS as $name) {
$sections[$name] = '';
}
$headerStartPos = $this->findHeaderStartPosition($html);
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($headerStartPos !== false && $headerStartPos > 0) {
$sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));
}
if ($headerStartPos !== false) {
$jiminnyStart = $headerStartPos;
} elseif ($markerPos !== false) {
$jiminnyStart = $markerPos;
} else {
$jiminnyStart = 0;
}
$firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);
if ($firstSectionPos === false) {
$sections['header'] = substr($html, $jiminnyStart);
} else {
$sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);
}
$sections['header'] = trim($sections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);
}
return $sections;
}
private function findHeaderStartPosition(string $html): int|false
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*<span[^>]*>\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
return $matches[0][1];
}
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($markerPos === false) {
return false;
}
$beforeMarker = substr($html, 0, $markerPos);
$lastPTagPos = strrpos($beforeMarker, '<p');
return $lastPTagPos !== false ? $lastPTagPos : $markerPos;
}
private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false
{
$firstPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($firstPos === false || $pos < $firstPos) {
$firstPos = $pos;
}
}
}
return $firstPos;
}
private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
return '';
}
$headerMatch = $matches[0][0];
$headerPos = $matches[0][1];
$contentStart = $headerPos + strlen($headerMatch);
$nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);
if ($nextSectionPos === false) {
$content = substr($html, $contentStart);
} else {
$content = substr($html, $contentStart, $nextSectionPos - $contentStart);
}
return trim($content);
}
private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false
{
$nextPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($nextPos === false || $pos < $nextPos) {
$nextPos = $pos;
}
}
}
return $nextPos;
}
private function mergeHtmlSections(array $newSections, array $existingSections): string
{
$result = '';
if (! empty($existingSections['beforeJiminny'])) {
$result .= $existingSections['beforeJiminny'];
}
$result .= $this->wrapHeader($newSections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$existingContent = $existingSections[$sectionName] ?? '';
$newContent = $newSections[$sectionName] ?? '';
$content = ! empty($existingContent) ? $existingContent : $newContent;
if (! empty($content)) {
$result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;
}
}
return $result;
}
private function wrapHeader(string $header): string
{
$header = trim($header);
if (str_starts_with($header, '<p>')) {
return $header;
}
if (str_starts_with($header, self::JIMINNY_MARKER)) {
return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));
}
return $header;
}
private function baseDescription(): string
{
return sprintf(
'<p><strong><span style="font-size: 15px; line-height: 30px;">%s</span></strong></p>',
'Jiminny Summary:'
);
}
private function formatSoftphoneDetails(Activity $activity): string
{
$isOutbound = $activity->isTypeSoftPhone();
$isInbound = $activity->isTypeSoftphoneInbound();
if (! $isOutbound && ! $isInbound) {
return '';
}
$output = $this->formatTitle($activity->getTitle());
$output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));
$phone = $isOutbound
? $activity->to?->phone_number
: $activity->from?->phone_number;
if ($phone) {
$output .= $isOutbound
? $this->formatDialedNumber($phone)
: $this->formatCallerNumber($phone);
}
return $output . '<p></p>';
}
private function formatReasonOrPreview(Activity $activity): string
{
if ($activity->hasReasonCodeBotKicked()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker removed from this meeting'
. '</span></p>';
}
if ($activity->hasReasonCodeNotCompliant()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker did not join due to recording consent not being provided by attendees'
. '</span></p>';
}
return $this->formatPreviewUrl($activity);
}
public function formatStartTime(Activity $activity): int
{
return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatEndTime(Activity $activity): int
{
return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCreatedAt(Activity $activity): int
{
return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCallToParticipant(Activity $activity): ?string
{
$callToParticipant = $activity->getToParticipant()?->getPhoneNumber();
if ($callToParticipant && $activity->hasContact()) {
return $activity->getContact()->getName() . ' ' . $callToParticipant;
}
return null;
}
private function formatActivityType(string $activityType): string
{
return '<p><strong><span style="font-size: 18.6667px; line-height: 22.4px;">' . $activityType . '</span></strong></p>';
}
private function formatTitle(?string $title): string
{
return $title ? '<p><span style="font-size: 16px; line-height: 19.2px;">' . $title . '</span></p>' : '';
}
private function formatCallDuration(string $duration): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Call Duration: ' . $duration . '</span></p>';
}
private function formatDialedNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Dialed: ' . $phoneNumber . '</span></p>';
}
private function formatCallerNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Caller: ' . $phoneNumber . '</span></p>';
}
private function formatAttendeesList(Activity $activity): string
{
$attendeesList = '<p><strong>Attendees</strong></p><ul>';
$participantsRepository = app(ParticipantRepository::class);
// Only include participants that joined.
$participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);
foreach ($participants as $participant) {
$attendee = '<li>';
if ($participant->hasName()) {
$attendee .= $participant->getName();
if ($participant->hasPhoneNumber()) {
$attendee .= ' (' . $participant->getPhoneNumber() . ')';
} elseif ($participant->hasEmailAddress()) {
$attendee .= ' (' . $participant->getEmailAddress() . ')';
}
} else {
$attendee .= $participant->getPhoneNumber();
}
if ($participant->isCoach()) {
$attendee .= ' <strong>coach</strong>';
}
if ($participant->getTitle()) {
$attendee .= ', ' . $participant->getTitle();
}
$attendeesList .= $attendee . '</li>';
}
return $attendeesList . '</ul>';
}
private function formatPreviewUrl(Activity $activity): string
{
$description = '';
$team = $activity->getUser()->getTeam();
if ($activity->canReviewActivity()) {
$playbackUrl = $team->getPartner()->getPlaybackUrl($activity);
$description .= '<p><span style="font-size: 13.3333px; line-height: 16px;"><a href="'
. $playbackUrl
. '" target="_blank">Review in Jiminny</a> ▶️</span></p>';
}
return $description;
}
private function formatNotes(Activity $activity): string
{
$description = '';
if ($activity->getNotes()->isEmpty()) {
return $description;
}
$description .= '<p><strong>Notes</strong></p>';
foreach ($activity->getNotes() as $note) {
$time = ($note->getTime() > 3600)
? gmdate('H:i:s', (int) $note->getTime())
: gmdate('i:s', (int) $note->getTime());
$description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';
}
return $description . '</p>';
}
private function formatMessages(Activity $activity): string
{
$description = '';
$messageRepository = app(ActivityMessageRepository::class);
// Get all private messages.
$privateMessages = $messageRepository->getPrivateMessages($activity);
if ($privateMessages->isNotEmpty()) {
$description .= '<p><strong>Coaching Chat</strong></p>';
$description .= $this->getMessagesAsString($privateMessages);
$description .= '</p>';
}
// Get all public messages
$publicMessages = $messageRepository->getPublicMessages($activity);
if ($publicMessages->isNotEmpty()) {
$description .= '<p><strong>Customer Chat</strong></p>';
$description .= $this->getMessagesAsString($publicMessages);
$description .= '</p>';
}
return $description;
}
private function getMessagesAsString(Collection $messages): string
{
$description = '';
/** @var Activity\Message $message */
foreach ($messages as $message) {
$description .= '<p>' . $message->participant->getName()
. ': ' . $message->getAttribute('message') . '</p>';
}
return $description;
}
private function formatSummary(Activity $activity): string
{
$description = '';
if ($activity->getSummary() !== null) {
$description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';
}
return $description;
}
private function formatSmsDescription(Activity $activity): string
{
// Use Rich-text formatting.
$description = '<p><span style="font-size: 16px; line-height: 19.2px;"><strong>' . $activity->getTitle() . '</strong></span></p>';
$description .= '<p><span style="font-size: 16px; line-height: 19.2px;">' . $activity->getDescription() . '</span></p>';
return $description;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45459
|
1628
|
7
|
2026-05-14T14:38:06.971488+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769486971_m2.jpg...
|
PhpStorm
|
faVsco.js – DecorateActivity.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
2
15
12
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot;
use Illuminate\Support\Collection;
use Jiminny\Models\Activity;
use Jiminny\Repositories\ActivityMessageRepository;
use Jiminny\Repositories\ParticipantRepository;
use Jiminny\Services\Crm\DecorateActivity\BaseDecorateActivity;
class DecorateActivity extends BaseDecorateActivity
{
public const string JIMINNY_MARKER = 'Jiminny Summary:';
public function generateTitle(Activity $activity): ?string
{
if ($activity->hasTitle()) {
$title = $activity->getTitle();
} elseif ($activity->hasActivityType()) {
$title = $activity->getActivityType()->getName();
} else {
$title = 'Conference Call';
}
return $title;
}
public function convertMeetingOutcome(Activity $activity): ?string
{
switch ($activity->getStatus()) {
case Activity::STATUS_SCHEDULED:
return 'SCHEDULED';
case Activity::STATUS_CANCELLED:
return 'CANCELED';
case Activity::STATUS_COMPLETED:
return 'COMPLETED';
//case Activity::STATUS_NO_SHOW:
// return 'NO_SHOW';
default:
return null;
}
}
public function convertCallStatus(Activity $activity): string
{
switch ($activity->getStatus()) {
case Activity::STATUS_NO_ANSWER:
return 'NO_ANSWER';
default:
return 'COMPLETED';
}
}
public function generateDescription(Activity $activity): ?string
{
if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {
return $this->formatSmsDescription($activity);
}
$description = $this->baseDescription();
if ($activity->hasTitle() && $activity->hasActivityType()) {
$description .= $this->formatActivityType($activity->getActivityType()->getName());
}
if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {
$description .= $this->formatSoftphoneDetails($activity);
}
$description .= $this->formatReasonOrPreview($activity);
if ($activity->isTypeConference()) {
$description .= $this->formatAttendeesList($activity);
}
return $description
. $this->formatNotes($activity)
. $this->formatMessages($activity)
. $this->formatSummary($activity);
}
public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string
{
if (empty($existingCrmDescription)) {
return $jiminnyDescription;
}
if (! $this->isJiminnyDescription($existingCrmDescription)) {
return $existingCrmDescription . '<hr>' . $jiminnyDescription;
}
$existingSections = $this->parseHtmlSections($existingCrmDescription);
$newSections = $this->parseHtmlSections($jiminnyDescription);
return $this->mergeHtmlSections($newSections, $existingSections);
}
private function parseHtmlSections(string $html): array
{
$sections = [
'beforeJiminny' => '',
'header' => '',
];
foreach (self::SECTION_HEADERS as $name) {
$sections[$name] = '';
}
$headerStartPos = $this->findHeaderStartPosition($html);
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($headerStartPos !== false && $headerStartPos > 0) {
$sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));
}
if ($headerStartPos !== false) {
$jiminnyStart = $headerStartPos;
} elseif ($markerPos !== false) {
$jiminnyStart = $markerPos;
} else {
$jiminnyStart = 0;
}
$firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);
if ($firstSectionPos === false) {
$sections['header'] = substr($html, $jiminnyStart);
} else {
$sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);
}
$sections['header'] = trim($sections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);
}
return $sections;
}
private function findHeaderStartPosition(string $html): int|false
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*<span[^>]*>\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
return $matches[0][1];
}
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($markerPos === false) {
return false;
}
$beforeMarker = substr($html, 0, $markerPos);
$lastPTagPos = strrpos($beforeMarker, '<p');
return $lastPTagPos !== false ? $lastPTagPos : $markerPos;
}
private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false
{
$firstPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($firstPos === false || $pos < $firstPos) {
$firstPos = $pos;
}
}
}
return $firstPos;
}
private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
return '';
}
$headerMatch = $matches[0][0];
$headerPos = $matches[0][1];
$contentStart = $headerPos + strlen($headerMatch);
$nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);
if ($nextSectionPos === false) {
$content = substr($html, $contentStart);
} else {
$content = substr($html, $contentStart, $nextSectionPos - $contentStart);
}
return trim($content);
}
private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false
{
$nextPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($nextPos === false || $pos < $nextPos) {
$nextPos = $pos;
}
}
}
return $nextPos;
}
private function mergeHtmlSections(array $newSections, array $existingSections): string
{
$result = '';
if (! empty($existingSections['beforeJiminny'])) {
$result .= $existingSections['beforeJiminny'];
}
$result .= $this->wrapHeader($newSections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$existingContent = $existingSections[$sectionName] ?? '';
$newContent = $newSections[$sectionName] ?? '';
$content = ! empty($existingContent) ? $existingContent : $newContent;
if (! empty($content)) {
$result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;
}
}
return $result;
}
private function wrapHeader(string $header): string
{
$header = trim($header);
if (str_starts_with($header, '<p>')) {
return $header;
}
if (str_starts_with($header, self::JIMINNY_MARKER)) {
return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));
}
return $header;
}
private function baseDescription(): string
{
return sprintf(
'<p><strong><span style="font-size: 15px; line-height: 30px;">%s</span></strong></p>',
'Jiminny Summary:'
);
}
private function formatSoftphoneDetails(Activity $activity): string
{
$isOutbound = $activity->isTypeSoftPhone();
$isInbound = $activity->isTypeSoftphoneInbound();
if (! $isOutbound && ! $isInbound) {
return '';
}
$output = $this->formatTitle($activity->getTitle());
$output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));
$phone = $isOutbound
? $activity->to?->phone_number
: $activity->from?->phone_number;
if ($phone) {
$output .= $isOutbound
? $this->formatDialedNumber($phone)
: $this->formatCallerNumber($phone);
}
return $output . '<p></p>';
}
private function formatReasonOrPreview(Activity $activity): string
{
if ($activity->hasReasonCodeBotKicked()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker removed from this meeting'
. '</span></p>';
}
if ($activity->hasReasonCodeNotCompliant()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker did not join due to recording consent not being provided by attendees'
. '</span></p>';
}
return $this->formatPreviewUrl($activity);
}
public function formatStartTime(Activity $activity): int
{
return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatEndTime(Activity $activity): int
{
return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCreatedAt(Activity $activity): int
{
return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCallToParticipant(Activity $activity): ?string
{
$callToParticipant = $activity->getToParticipant()?->getPhoneNumber();
if ($callToParticipant && $activity->hasContact()) {
return $activity->getContact()->getName() . ' ' . $callToParticipant;
}
return null;
}
private function formatActivityType(string $activityType): string
{
return '<p><strong><span style="font-size: 18.6667px; line-height: 22.4px;">' . $activityType . '</span></strong></p>';
}
private function formatTitle(?string $title): string
{
return $title ? '<p><span style="font-size: 16px; line-height: 19.2px;">' . $title . '</span></p>' : '';
}
private function formatCallDuration(string $duration): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Call Duration: ' . $duration . '</span></p>';
}
private function formatDialedNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Dialed: ' . $phoneNumber . '</span></p>';
}
private function formatCallerNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Caller: ' . $phoneNumber . '</span></p>';
}
private function formatAttendeesList(Activity $activity): string
{
$attendeesList = '<p><strong>Attendees</strong></p><ul>';
$participantsRepository = app(ParticipantRepository::class);
// Only include participants that joined.
$participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);
foreach ($participants as $participant) {
$attendee = '<li>';
if ($participant->hasName()) {
$attendee .= $participant->getName();
if ($participant->hasPhoneNumber()) {
$attendee .= ' (' . $participant->getPhoneNumber() . ')';
} elseif ($participant->hasEmailAddress()) {
$attendee .= ' (' . $participant->getEmailAddress() . ')';
}
} else {
$attendee .= $participant->getPhoneNumber();
}
if ($participant->isCoach()) {
$attendee .= ' <strong>coach</strong>';
}
if ($participant->getTitle()) {
$attendee .= ', ' . $participant->getTitle();
}
$attendeesList .= $attendee . '</li>';
}
return $attendeesList . '</ul>';
}
private function formatPreviewUrl(Activity $activity): string
{
$description = '';
$team = $activity->getUser()->getTeam();
if ($activity->canReviewActivity()) {
$playbackUrl = $team->getPartner()->getPlaybackUrl($activity);
$description .= '<p><span style="font-size: 13.3333px; line-height: 16px;"><a href="'
. $playbackUrl
. '" target="_blank">Review in Jiminny</a> ▶️</span></p>';
}
return $description;
}
private function formatNotes(Activity $activity): string
{
$description = '';
if ($activity->getNotes()->isEmpty()) {
return $description;
}
$description .= '<p><strong>Notes</strong></p>';
foreach ($activity->getNotes() as $note) {
$time = ($note->getTime() > 3600)
? gmdate('H:i:s', (int) $note->getTime())
: gmdate('i:s', (int) $note->getTime());
$description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';
}
return $description . '</p>';
}
private function formatMessages(Activity $activity): string
{
$description = '';
$messageRepository = app(ActivityMessageRepository::class);
// Get all private messages.
$privateMessages = $messageRepository->getPrivateMessages($activity);
if ($privateMessages->isNotEmpty()) {
$description .= '<p><strong>Coaching Chat</strong></p>';
$description .= $this->getMessagesAsString($privateMessages);
$description .= '</p>';
}
// Get all public messages
$publicMessages = $messageRepository->getPublicMessages($activity);
if ($publicMessages->isNotEmpty()) {
$description .= '<p><strong>Customer Chat</strong></p>';
$description .= $this->getMessagesAsString($publicMessages);
$description .= '</p>';
}
return $description;
}
private function getMessagesAsString(Collection $messages): string
{
$description = '';
/** @var Activity\Message $message */
foreach ($messages as $message) {
$description .= '<p>' . $message->participant->getName()
. ': ' . $message->getAttribute('message') . '</p>';
}
return $description;
}
private function formatSummary(Activity $activity): string
{
$description = '';
if ($activity->getSummary() !== null) {
$description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';
}
return $description;
}
private function formatSmsDescription(Activity $activity): string
{
// Use Rich-text formatting.
$description = '<p><span style="font-size: 16px; line-height: 19.2px;"><strong>' . $activity->getTitle() . '</strong></span></p>';
$description .= '<p><span style="font-size: 16px; line-height: 19.2px;">' . $activity->getDescription() . '</span></p>';
return $description;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"12","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Repositories\\ActivityMessageRepository;\nuse Jiminny\\Repositories\\ParticipantRepository;\nuse Jiminny\\Services\\Crm\\DecorateActivity\\BaseDecorateActivity;\n\nclass DecorateActivity extends BaseDecorateActivity\n{\n public const string JIMINNY_MARKER = 'Jiminny Summary:';\n\n public function generateTitle(Activity $activity): ?string\n {\n if ($activity->hasTitle()) {\n $title = $activity->getTitle();\n } elseif ($activity->hasActivityType()) {\n $title = $activity->getActivityType()->getName();\n } else {\n $title = 'Conference Call';\n }\n\n return $title;\n }\n\n public function convertMeetingOutcome(Activity $activity): ?string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_SCHEDULED:\n return 'SCHEDULED';\n case Activity::STATUS_CANCELLED:\n return 'CANCELED';\n case Activity::STATUS_COMPLETED:\n return 'COMPLETED';\n //case Activity::STATUS_NO_SHOW:\n // return 'NO_SHOW';\n default:\n return null;\n }\n }\n\n public function convertCallStatus(Activity $activity): string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_NO_ANSWER:\n return 'NO_ANSWER';\n default:\n return 'COMPLETED';\n }\n }\n\n public function generateDescription(Activity $activity): ?string\n {\n if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {\n return $this->formatSmsDescription($activity);\n }\n\n $description = $this->baseDescription();\n\n if ($activity->hasTitle() && $activity->hasActivityType()) {\n $description .= $this->formatActivityType($activity->getActivityType()->getName());\n }\n\n if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {\n $description .= $this->formatSoftphoneDetails($activity);\n }\n\n $description .= $this->formatReasonOrPreview($activity);\n\n if ($activity->isTypeConference()) {\n $description .= $this->formatAttendeesList($activity);\n }\n\n return $description\n . $this->formatNotes($activity)\n . $this->formatMessages($activity)\n . $this->formatSummary($activity);\n }\n\n public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string\n {\n if (empty($existingCrmDescription)) {\n return $jiminnyDescription;\n }\n\n if (! $this->isJiminnyDescription($existingCrmDescription)) {\n return $existingCrmDescription . '<hr>' . $jiminnyDescription;\n }\n\n $existingSections = $this->parseHtmlSections($existingCrmDescription);\n $newSections = $this->parseHtmlSections($jiminnyDescription);\n\n return $this->mergeHtmlSections($newSections, $existingSections);\n }\n\n private function parseHtmlSections(string $html): array\n {\n $sections = [\n 'beforeJiminny' => '',\n 'header' => '',\n ];\n\n foreach (self::SECTION_HEADERS as $name) {\n $sections[$name] = '';\n }\n\n $headerStartPos = $this->findHeaderStartPosition($html);\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n\n if ($headerStartPos !== false && $headerStartPos > 0) {\n $sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));\n }\n\n if ($headerStartPos !== false) {\n $jiminnyStart = $headerStartPos;\n } elseif ($markerPos !== false) {\n $jiminnyStart = $markerPos;\n } else {\n $jiminnyStart = 0;\n }\n\n $firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);\n\n if ($firstSectionPos === false) {\n $sections['header'] = substr($html, $jiminnyStart);\n } else {\n $sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);\n }\n\n $sections['header'] = trim($sections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);\n }\n\n return $sections;\n }\n\n private function findHeaderStartPosition(string $html): int|false\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*<span[^>]*>\\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';\n\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {\n return $matches[0][1];\n }\n\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n if ($markerPos === false) {\n return false;\n }\n\n $beforeMarker = substr($html, 0, $markerPos);\n $lastPTagPos = strrpos($beforeMarker, '<p');\n\n return $lastPTagPos !== false ? $lastPTagPos : $markerPos;\n }\n\n private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false\n {\n $firstPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($firstPos === false || $pos < $firstPos) {\n $firstPos = $pos;\n }\n }\n }\n\n return $firstPos;\n }\n\n private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n\n if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n return '';\n }\n\n $headerMatch = $matches[0][0];\n $headerPos = $matches[0][1];\n $contentStart = $headerPos + strlen($headerMatch);\n\n $nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);\n\n if ($nextSectionPos === false) {\n $content = substr($html, $contentStart);\n } else {\n $content = substr($html, $contentStart, $nextSectionPos - $contentStart);\n }\n\n return trim($content);\n }\n\n private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false\n {\n $nextPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($nextPos === false || $pos < $nextPos) {\n $nextPos = $pos;\n }\n }\n }\n\n return $nextPos;\n }\n\n private function mergeHtmlSections(array $newSections, array $existingSections): string\n {\n $result = '';\n\n if (! empty($existingSections['beforeJiminny'])) {\n $result .= $existingSections['beforeJiminny'];\n }\n\n $result .= $this->wrapHeader($newSections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $existingContent = $existingSections[$sectionName] ?? '';\n $newContent = $newSections[$sectionName] ?? '';\n\n $content = ! empty($existingContent) ? $existingContent : $newContent;\n\n if (! empty($content)) {\n $result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;\n }\n }\n\n return $result;\n }\n\n private function wrapHeader(string $header): string\n {\n $header = trim($header);\n\n if (str_starts_with($header, '<p>')) {\n return $header;\n }\n\n if (str_starts_with($header, self::JIMINNY_MARKER)) {\n return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));\n }\n\n return $header;\n }\n\n private function baseDescription(): string\n {\n return sprintf(\n '<p><strong><span style=\"font-size: 15px; line-height: 30px;\">%s</span></strong></p>',\n 'Jiminny Summary:'\n );\n }\n\n private function formatSoftphoneDetails(Activity $activity): string\n {\n $isOutbound = $activity->isTypeSoftPhone();\n $isInbound = $activity->isTypeSoftphoneInbound();\n\n if (! $isOutbound && ! $isInbound) {\n return '';\n }\n\n $output = $this->formatTitle($activity->getTitle());\n $output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));\n\n $phone = $isOutbound\n ? $activity->to?->phone_number\n : $activity->from?->phone_number;\n\n if ($phone) {\n $output .= $isOutbound\n ? $this->formatDialedNumber($phone)\n : $this->formatCallerNumber($phone);\n }\n\n return $output . '<p></p>';\n }\n\n private function formatReasonOrPreview(Activity $activity): string\n {\n if ($activity->hasReasonCodeBotKicked()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker removed from this meeting'\n . '</span></p>';\n }\n\n if ($activity->hasReasonCodeNotCompliant()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker did not join due to recording consent not being provided by attendees'\n . '</span></p>';\n }\n\n return $this->formatPreviewUrl($activity);\n }\n\n\n public function formatStartTime(Activity $activity): int\n {\n return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatEndTime(Activity $activity): int\n {\n return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCreatedAt(Activity $activity): int\n {\n return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCallToParticipant(Activity $activity): ?string\n {\n $callToParticipant = $activity->getToParticipant()?->getPhoneNumber();\n if ($callToParticipant && $activity->hasContact()) {\n return $activity->getContact()->getName() . ' ' . $callToParticipant;\n }\n\n return null;\n }\n\n private function formatActivityType(string $activityType): string\n {\n return '<p><strong><span style=\"font-size: 18.6667px; line-height: 22.4px;\">' . $activityType . '</span></strong></p>';\n }\n\n private function formatTitle(?string $title): string\n {\n return $title ? '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $title . '</span></p>' : '';\n }\n\n private function formatCallDuration(string $duration): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Call Duration: ' . $duration . '</span></p>';\n }\n\n private function formatDialedNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Dialed: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatCallerNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Caller: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatAttendeesList(Activity $activity): string\n {\n $attendeesList = '<p><strong>Attendees</strong></p><ul>';\n\n $participantsRepository = app(ParticipantRepository::class);\n // Only include participants that joined.\n $participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);\n foreach ($participants as $participant) {\n $attendee = '<li>';\n if ($participant->hasName()) {\n $attendee .= $participant->getName();\n if ($participant->hasPhoneNumber()) {\n $attendee .= ' (' . $participant->getPhoneNumber() . ')';\n } elseif ($participant->hasEmailAddress()) {\n $attendee .= ' (' . $participant->getEmailAddress() . ')';\n }\n } else {\n $attendee .= $participant->getPhoneNumber();\n }\n\n if ($participant->isCoach()) {\n $attendee .= ' <strong>coach</strong>';\n }\n\n if ($participant->getTitle()) {\n $attendee .= ', ' . $participant->getTitle();\n }\n\n $attendeesList .= $attendee . '</li>';\n }\n\n return $attendeesList . '</ul>';\n }\n\n private function formatPreviewUrl(Activity $activity): string\n {\n $description = '';\n $team = $activity->getUser()->getTeam();\n\n if ($activity->canReviewActivity()) {\n $playbackUrl = $team->getPartner()->getPlaybackUrl($activity);\n $description .= '<p><span style=\"font-size: 13.3333px; line-height: 16px;\"><a href=\"'\n . $playbackUrl\n . '\" target=\"_blank\">Review in Jiminny</a> ▶️</span></p>';\n }\n\n return $description;\n }\n\n private function formatNotes(Activity $activity): string\n {\n $description = '';\n if ($activity->getNotes()->isEmpty()) {\n return $description;\n }\n\n $description .= '<p><strong>Notes</strong></p>';\n foreach ($activity->getNotes() as $note) {\n $time = ($note->getTime() > 3600)\n ? gmdate('H:i:s', (int) $note->getTime())\n : gmdate('i:s', (int) $note->getTime());\n\n $description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';\n }\n\n return $description . '</p>';\n }\n\n private function formatMessages(Activity $activity): string\n {\n $description = '';\n $messageRepository = app(ActivityMessageRepository::class);\n\n // Get all private messages.\n $privateMessages = $messageRepository->getPrivateMessages($activity);\n if ($privateMessages->isNotEmpty()) {\n $description .= '<p><strong>Coaching Chat</strong></p>';\n $description .= $this->getMessagesAsString($privateMessages);\n $description .= '</p>';\n }\n\n // Get all public messages\n $publicMessages = $messageRepository->getPublicMessages($activity);\n if ($publicMessages->isNotEmpty()) {\n $description .= '<p><strong>Customer Chat</strong></p>';\n $description .= $this->getMessagesAsString($publicMessages);\n $description .= '</p>';\n }\n\n return $description;\n }\n\n private function getMessagesAsString(Collection $messages): string\n {\n $description = '';\n\n /** @var Activity\\Message $message */\n foreach ($messages as $message) {\n $description .= '<p>' . $message->participant->getName()\n . ': ' . $message->getAttribute('message') . '</p>';\n }\n\n return $description;\n }\n\n private function formatSummary(Activity $activity): string\n {\n $description = '';\n if ($activity->getSummary() !== null) {\n $description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';\n }\n\n return $description;\n }\n\n private function formatSmsDescription(Activity $activity): string\n {\n // Use Rich-text formatting.\n $description = '<p><span style=\"font-size: 16px; line-height: 19.2px;\"><strong>' . $activity->getTitle() . '</strong></span></p>';\n $description .= '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $activity->getDescription() . '</span></p>';\n\n return $description;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Repositories\\ActivityMessageRepository;\nuse Jiminny\\Repositories\\ParticipantRepository;\nuse Jiminny\\Services\\Crm\\DecorateActivity\\BaseDecorateActivity;\n\nclass DecorateActivity extends BaseDecorateActivity\n{\n public const string JIMINNY_MARKER = 'Jiminny Summary:';\n\n public function generateTitle(Activity $activity): ?string\n {\n if ($activity->hasTitle()) {\n $title = $activity->getTitle();\n } elseif ($activity->hasActivityType()) {\n $title = $activity->getActivityType()->getName();\n } else {\n $title = 'Conference Call';\n }\n\n return $title;\n }\n\n public function convertMeetingOutcome(Activity $activity): ?string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_SCHEDULED:\n return 'SCHEDULED';\n case Activity::STATUS_CANCELLED:\n return 'CANCELED';\n case Activity::STATUS_COMPLETED:\n return 'COMPLETED';\n //case Activity::STATUS_NO_SHOW:\n // return 'NO_SHOW';\n default:\n return null;\n }\n }\n\n public function convertCallStatus(Activity $activity): string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_NO_ANSWER:\n return 'NO_ANSWER';\n default:\n return 'COMPLETED';\n }\n }\n\n public function generateDescription(Activity $activity): ?string\n {\n if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {\n return $this->formatSmsDescription($activity);\n }\n\n $description = $this->baseDescription();\n\n if ($activity->hasTitle() && $activity->hasActivityType()) {\n $description .= $this->formatActivityType($activity->getActivityType()->getName());\n }\n\n if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {\n $description .= $this->formatSoftphoneDetails($activity);\n }\n\n $description .= $this->formatReasonOrPreview($activity);\n\n if ($activity->isTypeConference()) {\n $description .= $this->formatAttendeesList($activity);\n }\n\n return $description\n . $this->formatNotes($activity)\n . $this->formatMessages($activity)\n . $this->formatSummary($activity);\n }\n\n public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string\n {\n if (empty($existingCrmDescription)) {\n return $jiminnyDescription;\n }\n\n if (! $this->isJiminnyDescription($existingCrmDescription)) {\n return $existingCrmDescription . '<hr>' . $jiminnyDescription;\n }\n\n $existingSections = $this->parseHtmlSections($existingCrmDescription);\n $newSections = $this->parseHtmlSections($jiminnyDescription);\n\n return $this->mergeHtmlSections($newSections, $existingSections);\n }\n\n private function parseHtmlSections(string $html): array\n {\n $sections = [\n 'beforeJiminny' => '',\n 'header' => '',\n ];\n\n foreach (self::SECTION_HEADERS as $name) {\n $sections[$name] = '';\n }\n\n $headerStartPos = $this->findHeaderStartPosition($html);\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n\n if ($headerStartPos !== false && $headerStartPos > 0) {\n $sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));\n }\n\n if ($headerStartPos !== false) {\n $jiminnyStart = $headerStartPos;\n } elseif ($markerPos !== false) {\n $jiminnyStart = $markerPos;\n } else {\n $jiminnyStart = 0;\n }\n\n $firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);\n\n if ($firstSectionPos === false) {\n $sections['header'] = substr($html, $jiminnyStart);\n } else {\n $sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);\n }\n\n $sections['header'] = trim($sections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);\n }\n\n return $sections;\n }\n\n private function findHeaderStartPosition(string $html): int|false\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*<span[^>]*>\\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';\n\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {\n return $matches[0][1];\n }\n\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n if ($markerPos === false) {\n return false;\n }\n\n $beforeMarker = substr($html, 0, $markerPos);\n $lastPTagPos = strrpos($beforeMarker, '<p');\n\n return $lastPTagPos !== false ? $lastPTagPos : $markerPos;\n }\n\n private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false\n {\n $firstPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($firstPos === false || $pos < $firstPos) {\n $firstPos = $pos;\n }\n }\n }\n\n return $firstPos;\n }\n\n private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n\n if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n return '';\n }\n\n $headerMatch = $matches[0][0];\n $headerPos = $matches[0][1];\n $contentStart = $headerPos + strlen($headerMatch);\n\n $nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);\n\n if ($nextSectionPos === false) {\n $content = substr($html, $contentStart);\n } else {\n $content = substr($html, $contentStart, $nextSectionPos - $contentStart);\n }\n\n return trim($content);\n }\n\n private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false\n {\n $nextPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($nextPos === false || $pos < $nextPos) {\n $nextPos = $pos;\n }\n }\n }\n\n return $nextPos;\n }\n\n private function mergeHtmlSections(array $newSections, array $existingSections): string\n {\n $result = '';\n\n if (! empty($existingSections['beforeJiminny'])) {\n $result .= $existingSections['beforeJiminny'];\n }\n\n $result .= $this->wrapHeader($newSections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $existingContent = $existingSections[$sectionName] ?? '';\n $newContent = $newSections[$sectionName] ?? '';\n\n $content = ! empty($existingContent) ? $existingContent : $newContent;\n\n if (! empty($content)) {\n $result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;\n }\n }\n\n return $result;\n }\n\n private function wrapHeader(string $header): string\n {\n $header = trim($header);\n\n if (str_starts_with($header, '<p>')) {\n return $header;\n }\n\n if (str_starts_with($header, self::JIMINNY_MARKER)) {\n return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));\n }\n\n return $header;\n }\n\n private function baseDescription(): string\n {\n return sprintf(\n '<p><strong><span style=\"font-size: 15px; line-height: 30px;\">%s</span></strong></p>',\n 'Jiminny Summary:'\n );\n }\n\n private function formatSoftphoneDetails(Activity $activity): string\n {\n $isOutbound = $activity->isTypeSoftPhone();\n $isInbound = $activity->isTypeSoftphoneInbound();\n\n if (! $isOutbound && ! $isInbound) {\n return '';\n }\n\n $output = $this->formatTitle($activity->getTitle());\n $output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));\n\n $phone = $isOutbound\n ? $activity->to?->phone_number\n : $activity->from?->phone_number;\n\n if ($phone) {\n $output .= $isOutbound\n ? $this->formatDialedNumber($phone)\n : $this->formatCallerNumber($phone);\n }\n\n return $output . '<p></p>';\n }\n\n private function formatReasonOrPreview(Activity $activity): string\n {\n if ($activity->hasReasonCodeBotKicked()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker removed from this meeting'\n . '</span></p>';\n }\n\n if ($activity->hasReasonCodeNotCompliant()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker did not join due to recording consent not being provided by attendees'\n . '</span></p>';\n }\n\n return $this->formatPreviewUrl($activity);\n }\n\n\n public function formatStartTime(Activity $activity): int\n {\n return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatEndTime(Activity $activity): int\n {\n return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCreatedAt(Activity $activity): int\n {\n return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCallToParticipant(Activity $activity): ?string\n {\n $callToParticipant = $activity->getToParticipant()?->getPhoneNumber();\n if ($callToParticipant && $activity->hasContact()) {\n return $activity->getContact()->getName() . ' ' . $callToParticipant;\n }\n\n return null;\n }\n\n private function formatActivityType(string $activityType): string\n {\n return '<p><strong><span style=\"font-size: 18.6667px; line-height: 22.4px;\">' . $activityType . '</span></strong></p>';\n }\n\n private function formatTitle(?string $title): string\n {\n return $title ? '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $title . '</span></p>' : '';\n }\n\n private function formatCallDuration(string $duration): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Call Duration: ' . $duration . '</span></p>';\n }\n\n private function formatDialedNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Dialed: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatCallerNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Caller: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatAttendeesList(Activity $activity): string\n {\n $attendeesList = '<p><strong>Attendees</strong></p><ul>';\n\n $participantsRepository = app(ParticipantRepository::class);\n // Only include participants that joined.\n $participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);\n foreach ($participants as $participant) {\n $attendee = '<li>';\n if ($participant->hasName()) {\n $attendee .= $participant->getName();\n if ($participant->hasPhoneNumber()) {\n $attendee .= ' (' . $participant->getPhoneNumber() . ')';\n } elseif ($participant->hasEmailAddress()) {\n $attendee .= ' (' . $participant->getEmailAddress() . ')';\n }\n } else {\n $attendee .= $participant->getPhoneNumber();\n }\n\n if ($participant->isCoach()) {\n $attendee .= ' <strong>coach</strong>';\n }\n\n if ($participant->getTitle()) {\n $attendee .= ', ' . $participant->getTitle();\n }\n\n $attendeesList .= $attendee . '</li>';\n }\n\n return $attendeesList . '</ul>';\n }\n\n private function formatPreviewUrl(Activity $activity): string\n {\n $description = '';\n $team = $activity->getUser()->getTeam();\n\n if ($activity->canReviewActivity()) {\n $playbackUrl = $team->getPartner()->getPlaybackUrl($activity);\n $description .= '<p><span style=\"font-size: 13.3333px; line-height: 16px;\"><a href=\"'\n . $playbackUrl\n . '\" target=\"_blank\">Review in Jiminny</a> ▶️</span></p>';\n }\n\n return $description;\n }\n\n private function formatNotes(Activity $activity): string\n {\n $description = '';\n if ($activity->getNotes()->isEmpty()) {\n return $description;\n }\n\n $description .= '<p><strong>Notes</strong></p>';\n foreach ($activity->getNotes() as $note) {\n $time = ($note->getTime() > 3600)\n ? gmdate('H:i:s', (int) $note->getTime())\n : gmdate('i:s', (int) $note->getTime());\n\n $description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';\n }\n\n return $description . '</p>';\n }\n\n private function formatMessages(Activity $activity): string\n {\n $description = '';\n $messageRepository = app(ActivityMessageRepository::class);\n\n // Get all private messages.\n $privateMessages = $messageRepository->getPrivateMessages($activity);\n if ($privateMessages->isNotEmpty()) {\n $description .= '<p><strong>Coaching Chat</strong></p>';\n $description .= $this->getMessagesAsString($privateMessages);\n $description .= '</p>';\n }\n\n // Get all public messages\n $publicMessages = $messageRepository->getPublicMessages($activity);\n if ($publicMessages->isNotEmpty()) {\n $description .= '<p><strong>Customer Chat</strong></p>';\n $description .= $this->getMessagesAsString($publicMessages);\n $description .= '</p>';\n }\n\n return $description;\n }\n\n private function getMessagesAsString(Collection $messages): string\n {\n $description = '';\n\n /** @var Activity\\Message $message */\n foreach ($messages as $message) {\n $description .= '<p>' . $message->participant->getName()\n . ': ' . $message->getAttribute('message') . '</p>';\n }\n\n return $description;\n }\n\n private function formatSummary(Activity $activity): string\n {\n $description = '';\n if ($activity->getSummary() !== null) {\n $description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';\n }\n\n return $description;\n }\n\n private function formatSmsDescription(Activity $activity): string\n {\n // Use Rich-text formatting.\n $description = '<p><span style=\"font-size: 16px; line-height: 19.2px;\"><strong>' . $activity->getTitle() . '</strong></span></p>';\n $description .= '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $activity->getDescription() . '</span></p>';\n\n return $description;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.28224733,"top":1.0,"width":0.024268618,"height":-0.04788506},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6902378850207333842
|
9001456016336028185
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
2
15
12
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot;
use Illuminate\Support\Collection;
use Jiminny\Models\Activity;
use Jiminny\Repositories\ActivityMessageRepository;
use Jiminny\Repositories\ParticipantRepository;
use Jiminny\Services\Crm\DecorateActivity\BaseDecorateActivity;
class DecorateActivity extends BaseDecorateActivity
{
public const string JIMINNY_MARKER = 'Jiminny Summary:';
public function generateTitle(Activity $activity): ?string
{
if ($activity->hasTitle()) {
$title = $activity->getTitle();
} elseif ($activity->hasActivityType()) {
$title = $activity->getActivityType()->getName();
} else {
$title = 'Conference Call';
}
return $title;
}
public function convertMeetingOutcome(Activity $activity): ?string
{
switch ($activity->getStatus()) {
case Activity::STATUS_SCHEDULED:
return 'SCHEDULED';
case Activity::STATUS_CANCELLED:
return 'CANCELED';
case Activity::STATUS_COMPLETED:
return 'COMPLETED';
//case Activity::STATUS_NO_SHOW:
// return 'NO_SHOW';
default:
return null;
}
}
public function convertCallStatus(Activity $activity): string
{
switch ($activity->getStatus()) {
case Activity::STATUS_NO_ANSWER:
return 'NO_ANSWER';
default:
return 'COMPLETED';
}
}
public function generateDescription(Activity $activity): ?string
{
if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {
return $this->formatSmsDescription($activity);
}
$description = $this->baseDescription();
if ($activity->hasTitle() && $activity->hasActivityType()) {
$description .= $this->formatActivityType($activity->getActivityType()->getName());
}
if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {
$description .= $this->formatSoftphoneDetails($activity);
}
$description .= $this->formatReasonOrPreview($activity);
if ($activity->isTypeConference()) {
$description .= $this->formatAttendeesList($activity);
}
return $description
. $this->formatNotes($activity)
. $this->formatMessages($activity)
. $this->formatSummary($activity);
}
public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string
{
if (empty($existingCrmDescription)) {
return $jiminnyDescription;
}
if (! $this->isJiminnyDescription($existingCrmDescription)) {
return $existingCrmDescription . '<hr>' . $jiminnyDescription;
}
$existingSections = $this->parseHtmlSections($existingCrmDescription);
$newSections = $this->parseHtmlSections($jiminnyDescription);
return $this->mergeHtmlSections($newSections, $existingSections);
}
private function parseHtmlSections(string $html): array
{
$sections = [
'beforeJiminny' => '',
'header' => '',
];
foreach (self::SECTION_HEADERS as $name) {
$sections[$name] = '';
}
$headerStartPos = $this->findHeaderStartPosition($html);
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($headerStartPos !== false && $headerStartPos > 0) {
$sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));
}
if ($headerStartPos !== false) {
$jiminnyStart = $headerStartPos;
} elseif ($markerPos !== false) {
$jiminnyStart = $markerPos;
} else {
$jiminnyStart = 0;
}
$firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);
if ($firstSectionPos === false) {
$sections['header'] = substr($html, $jiminnyStart);
} else {
$sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);
}
$sections['header'] = trim($sections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);
}
return $sections;
}
private function findHeaderStartPosition(string $html): int|false
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*<span[^>]*>\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
return $matches[0][1];
}
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($markerPos === false) {
return false;
}
$beforeMarker = substr($html, 0, $markerPos);
$lastPTagPos = strrpos($beforeMarker, '<p');
return $lastPTagPos !== false ? $lastPTagPos : $markerPos;
}
private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false
{
$firstPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($firstPos === false || $pos < $firstPos) {
$firstPos = $pos;
}
}
}
return $firstPos;
}
private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
return '';
}
$headerMatch = $matches[0][0];
$headerPos = $matches[0][1];
$contentStart = $headerPos + strlen($headerMatch);
$nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);
if ($nextSectionPos === false) {
$content = substr($html, $contentStart);
} else {
$content = substr($html, $contentStart, $nextSectionPos - $contentStart);
}
return trim($content);
}
private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false
{
$nextPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($nextPos === false || $pos < $nextPos) {
$nextPos = $pos;
}
}
}
return $nextPos;
}
private function mergeHtmlSections(array $newSections, array $existingSections): string
{
$result = '';
if (! empty($existingSections['beforeJiminny'])) {
$result .= $existingSections['beforeJiminny'];
}
$result .= $this->wrapHeader($newSections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$existingContent = $existingSections[$sectionName] ?? '';
$newContent = $newSections[$sectionName] ?? '';
$content = ! empty($existingContent) ? $existingContent : $newContent;
if (! empty($content)) {
$result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;
}
}
return $result;
}
private function wrapHeader(string $header): string
{
$header = trim($header);
if (str_starts_with($header, '<p>')) {
return $header;
}
if (str_starts_with($header, self::JIMINNY_MARKER)) {
return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));
}
return $header;
}
private function baseDescription(): string
{
return sprintf(
'<p><strong><span style="font-size: 15px; line-height: 30px;">%s</span></strong></p>',
'Jiminny Summary:'
);
}
private function formatSoftphoneDetails(Activity $activity): string
{
$isOutbound = $activity->isTypeSoftPhone();
$isInbound = $activity->isTypeSoftphoneInbound();
if (! $isOutbound && ! $isInbound) {
return '';
}
$output = $this->formatTitle($activity->getTitle());
$output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));
$phone = $isOutbound
? $activity->to?->phone_number
: $activity->from?->phone_number;
if ($phone) {
$output .= $isOutbound
? $this->formatDialedNumber($phone)
: $this->formatCallerNumber($phone);
}
return $output . '<p></p>';
}
private function formatReasonOrPreview(Activity $activity): string
{
if ($activity->hasReasonCodeBotKicked()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker removed from this meeting'
. '</span></p>';
}
if ($activity->hasReasonCodeNotCompliant()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker did not join due to recording consent not being provided by attendees'
. '</span></p>';
}
return $this->formatPreviewUrl($activity);
}
public function formatStartTime(Activity $activity): int
{
return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatEndTime(Activity $activity): int
{
return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCreatedAt(Activity $activity): int
{
return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCallToParticipant(Activity $activity): ?string
{
$callToParticipant = $activity->getToParticipant()?->getPhoneNumber();
if ($callToParticipant && $activity->hasContact()) {
return $activity->getContact()->getName() . ' ' . $callToParticipant;
}
return null;
}
private function formatActivityType(string $activityType): string
{
return '<p><strong><span style="font-size: 18.6667px; line-height: 22.4px;">' . $activityType . '</span></strong></p>';
}
private function formatTitle(?string $title): string
{
return $title ? '<p><span style="font-size: 16px; line-height: 19.2px;">' . $title . '</span></p>' : '';
}
private function formatCallDuration(string $duration): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Call Duration: ' . $duration . '</span></p>';
}
private function formatDialedNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Dialed: ' . $phoneNumber . '</span></p>';
}
private function formatCallerNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Caller: ' . $phoneNumber . '</span></p>';
}
private function formatAttendeesList(Activity $activity): string
{
$attendeesList = '<p><strong>Attendees</strong></p><ul>';
$participantsRepository = app(ParticipantRepository::class);
// Only include participants that joined.
$participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);
foreach ($participants as $participant) {
$attendee = '<li>';
if ($participant->hasName()) {
$attendee .= $participant->getName();
if ($participant->hasPhoneNumber()) {
$attendee .= ' (' . $participant->getPhoneNumber() . ')';
} elseif ($participant->hasEmailAddress()) {
$attendee .= ' (' . $participant->getEmailAddress() . ')';
}
} else {
$attendee .= $participant->getPhoneNumber();
}
if ($participant->isCoach()) {
$attendee .= ' <strong>coach</strong>';
}
if ($participant->getTitle()) {
$attendee .= ', ' . $participant->getTitle();
}
$attendeesList .= $attendee . '</li>';
}
return $attendeesList . '</ul>';
}
private function formatPreviewUrl(Activity $activity): string
{
$description = '';
$team = $activity->getUser()->getTeam();
if ($activity->canReviewActivity()) {
$playbackUrl = $team->getPartner()->getPlaybackUrl($activity);
$description .= '<p><span style="font-size: 13.3333px; line-height: 16px;"><a href="'
. $playbackUrl
. '" target="_blank">Review in Jiminny</a> ▶️</span></p>';
}
return $description;
}
private function formatNotes(Activity $activity): string
{
$description = '';
if ($activity->getNotes()->isEmpty()) {
return $description;
}
$description .= '<p><strong>Notes</strong></p>';
foreach ($activity->getNotes() as $note) {
$time = ($note->getTime() > 3600)
? gmdate('H:i:s', (int) $note->getTime())
: gmdate('i:s', (int) $note->getTime());
$description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';
}
return $description . '</p>';
}
private function formatMessages(Activity $activity): string
{
$description = '';
$messageRepository = app(ActivityMessageRepository::class);
// Get all private messages.
$privateMessages = $messageRepository->getPrivateMessages($activity);
if ($privateMessages->isNotEmpty()) {
$description .= '<p><strong>Coaching Chat</strong></p>';
$description .= $this->getMessagesAsString($privateMessages);
$description .= '</p>';
}
// Get all public messages
$publicMessages = $messageRepository->getPublicMessages($activity);
if ($publicMessages->isNotEmpty()) {
$description .= '<p><strong>Customer Chat</strong></p>';
$description .= $this->getMessagesAsString($publicMessages);
$description .= '</p>';
}
return $description;
}
private function getMessagesAsString(Collection $messages): string
{
$description = '';
/** @var Activity\Message $message */
foreach ($messages as $message) {
$description .= '<p>' . $message->participant->getName()
. ': ' . $message->getAttribute('message') . '</p>';
}
return $description;
}
private function formatSummary(Activity $activity): string
{
$description = '';
if ($activity->getSummary() !== null) {
$description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';
}
return $description;
}
private function formatSmsDescription(Activity $activity): string
{
// Use Rich-text formatting.
$description = '<p><span style="font-size: 16px; line-height: 19.2px;"><strong>' . $activity->getTitle() . '</strong></span></p>';
$description .= '<p><span style="font-size: 16px; line-height: 19.2px;">' . $activity->getDescription() . '</span></p>';
return $description;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
45458
|
NULL
|
NULL
|
NULL
|
|
45462
|
1628
|
8
|
2026-05-14T14:38:34.742566+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769514742_m2.jpg...
|
PhpStorm
|
faVsco.js – DecorateActivity.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.39Yesterday at 13:39Yesterday at 13.38Yesterdav at 13:37Yesterday at 13:37resterday at 15:30Yesterdav at 13:36Yesterday at 13:35Yesterday at 13.34Yecterdav at 13:34resterday at 15.3sYesterdav at 13:37Yesterday at 13:32Yesterday at 13:31Yesterday at 13:31Yesterday at 13:30resterday at 13.4yYesterdav at 13:29Yesterday at 13:28Testerady dl 15.40Yesterday at 13:27Yesterday at 13:27Yesterday at 13.26Yesterdav at 13:25Yesterdav at 13:25Yesterday at 13:24Yesterday at 13:23Yesterday at 13.21Yecterdav at 12:21Yesterdav at 13:20Yesterday at 13:20Yesterday at 13:19Yesterday at 13:18Yactordav at 12:17Yesterday at 13:16Yecterdav at 12:16Yesterday at 13:15Yesterday at 13:14Yoctordau at 12:11Yesterday at 13.13Yecterdav at 12:12Yesterdav at 13:12Yesterdav at 13:1143 K:MPEG-4 movie50 KB100 KB88 Kb62 KB71 KB23 KB9 K:MPEG-4 movieMPEG-4 movieMPEG-4 movieMPEO"4 movieMPEG-4 movie13 KBMDSG-A movie16 KE1/ K8MPEG-4 movie29 KBMPEG-A movid12 KB9 KEMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB37 K:MPEG-4 movie10 KRI7 KBO KbMPEG-1 movieMPEG-4 movie9 KEMPEG-4 movie8 KB MPEG-4 movie72 KB14 KB|MPEG-4 movie13 KBMDEC.A movic18 KBMPEG-4 movie12 KE10 KBMPEG-4 movieMPEG-4 movie16 KBMPEG-4 movie16 K:MPEG-4 movieMDEC A movid12 KB23 KBMPEG-4 movieЯ KP6 KB6 KBMDEG-A movie11 KBI11 KB20 KB34 KBMPEG-4 movieMDEC.A moviaMPEG-4 movie10KR7 KB5 KBMDSG-A moviaMPEG-4 movie11 KRIMPSG-A movie26 KB MPEG-4 movie111 KB102 KB1g9 kpMPEG-4 movieMDEG.A movio59 KB98 KBMPEG-4 movie07 KрMDEG-A movie66 KBMPEG-4 movie44 KB03 K8MPEG-4 movieAl Notes: OffLeaveFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zipreport(2).xmlAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence hettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentPDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archive5KRMarkdo…..umentWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.45 GB availabold• Inu 14 May 1/•30.34Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
8342324305069557853
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.39Yesterday at 13:39Yesterday at 13.38Yesterdav at 13:37Yesterday at 13:37resterday at 15:30Yesterdav at 13:36Yesterday at 13:35Yesterday at 13.34Yecterdav at 13:34resterday at 15.3sYesterdav at 13:37Yesterday at 13:32Yesterday at 13:31Yesterday at 13:31Yesterday at 13:30resterday at 13.4yYesterdav at 13:29Yesterday at 13:28Testerady dl 15.40Yesterday at 13:27Yesterday at 13:27Yesterday at 13.26Yesterdav at 13:25Yesterdav at 13:25Yesterday at 13:24Yesterday at 13:23Yesterday at 13.21Yecterdav at 12:21Yesterdav at 13:20Yesterday at 13:20Yesterday at 13:19Yesterday at 13:18Yactordav at 12:17Yesterday at 13:16Yecterdav at 12:16Yesterday at 13:15Yesterday at 13:14Yoctordau at 12:11Yesterday at 13.13Yecterdav at 12:12Yesterdav at 13:12Yesterdav at 13:1143 K:MPEG-4 movie50 KB100 KB88 Kb62 KB71 KB23 KB9 K:MPEG-4 movieMPEG-4 movieMPEG-4 movieMPEO"4 movieMPEG-4 movie13 KBMDSG-A movie16 KE1/ K8MPEG-4 movie29 KBMPEG-A movid12 KB9 KEMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB37 K:MPEG-4 movie10 KRI7 KBO KbMPEG-1 movieMPEG-4 movie9 KEMPEG-4 movie8 KB MPEG-4 movie72 KB14 KB|MPEG-4 movie13 KBMDEC.A movic18 KBMPEG-4 movie12 KE10 KBMPEG-4 movieMPEG-4 movie16 KBMPEG-4 movie16 K:MPEG-4 movieMDEC A movid12 KB23 KBMPEG-4 movieЯ KP6 KB6 KBMDEG-A movie11 KBI11 KB20 KB34 KBMPEG-4 movieMDEC.A moviaMPEG-4 movie10KR7 KB5 KBMDSG-A moviaMPEG-4 movie11 KRIMPSG-A movie26 KB MPEG-4 movie111 KB102 KB1g9 kpMPEG-4 movieMDEG.A movio59 KB98 KBMPEG-4 movie07 KрMDEG-A movie66 KBMPEG-4 movie44 KB03 K8MPEG-4 movieAl Notes: OffLeaveFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zipreport(2).xmlAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence hettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentPDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archive5KRMarkdo…..umentWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.45 GB availabold• Inu 14 May 1/•30.34Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45460
|
1627
|
8
|
2026-05-14T14:38:34.747494+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769514747_m1.jpg...
|
PhpStorm
|
faVsco.js – DecorateActivity.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest100% <8• Thu 14 May 17:38:34* :QProject vAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.php:=custom.log+ SyncCrmEntitiesTrait.phpPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.phpT SyncFieldsTrait.php+ WriteCrmTrait.php© ImportActivityTypes.phpT WriteCrmTrait.phpDecorateActivity.php x© Salesforce/Service.phpT LogActivityTrait.php> D Utils© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpD WebhookT ActivityPlaybookTrait.php18.••© BatchSyncCollector.php© BatchSyncRedisService.php© DetachActivityObject.php© Client.php© ClosedDealStagesService.php© PlainTextDecorateActivity.php-env© HubspotPaginationService.php© HandleHubspotRateLimit.php5namespace Jiminny (Services\Crm Hubspot;© CrmHelperRepository.phpAccountController.php=.env.stagingRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php01 A2 A15 X12 ^G DealFieldsService.php© DecorateActivity.phpuse© FieldDefinitions.php© FieldTypeConverter.php© HubspotClientinterface.php121314classDecorateActivity extends BaseDecorateActivity© HubspotTokenManager.php5 usages© PayloadBuilder.php© RemoteCrmObjectManipulatoi© ResponseNormalize.php© Service.php© SyncFieldAction.php© SyncRelatedActivityManager.|© WebhookSyncBatchProcessolv D IntegrationApp• AccessorsD ApiD ConfigDDTOD Filters→ Jobs• ProspectSearchStrategy• ServiceTraits© DataClient.php15 C1617 C181920|2122232425262728293045public const string JIMINNY_MARKER = 'Jiminny Summary:';public function generateTitle(Activity $activity): ?string{if ($activity->hasTitle()) {$title = $activity->getTitle();} elseif ($activity->hasActivityTypeO)) {Stitle =Sactivity->getActivityType() ->getName();Cascade & TlCommand 81} else {$title = 'Conference Call':return $title;}-public function convertMeetingOutcome(Activity Sactivity): ?stringf...}© DecorateActivity.php2 usages© LocalSearch.php46public function convertCallStatus(Activity $activity): string{...}© LocalSearchlnterface.php55DamntaCaornhnhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)=laravel.logSF [jiminny@localhost]A HS_local [jiminny@localho:W4 console [QAI PROD] X4 console [PROD]A console (EU]DGo jiminny084143 ×4 л215•m_layout_id =2162,1661,66799,662172181 219id = 33;1 22281— 221|-222=223— 224|id THEN '(own225226_227228229230hubspot':-=231— 232233V= 11512582;_234-W Windsurf Teams22:48 (15 chars)UTF-8Ca 4 spaces...
|
NULL
|
-1163304622492390733
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest100% <8• Thu 14 May 17:38:34* :QProject vAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.php:=custom.log+ SyncCrmEntitiesTrait.phpPlanhatService.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.phpT SyncFieldsTrait.php+ WriteCrmTrait.php© ImportActivityTypes.phpT WriteCrmTrait.phpDecorateActivity.php x© Salesforce/Service.phpT LogActivityTrait.php> D Utils© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpD WebhookT ActivityPlaybookTrait.php18.••© BatchSyncCollector.php© BatchSyncRedisService.php© DetachActivityObject.php© Client.php© ClosedDealStagesService.php© PlainTextDecorateActivity.php-env© HubspotPaginationService.php© HandleHubspotRateLimit.php5namespace Jiminny (Services\Crm Hubspot;© CrmHelperRepository.phpAccountController.php=.env.stagingRematchActivityOnCrmObjectDetach.php© MatchActivityCrmData.phpClient.php01 A2 A15 X12 ^G DealFieldsService.php© DecorateActivity.phpuse© FieldDefinitions.php© FieldTypeConverter.php© HubspotClientinterface.php121314classDecorateActivity extends BaseDecorateActivity© HubspotTokenManager.php5 usages© PayloadBuilder.php© RemoteCrmObjectManipulatoi© ResponseNormalize.php© Service.php© SyncFieldAction.php© SyncRelatedActivityManager.|© WebhookSyncBatchProcessolv D IntegrationApp• AccessorsD ApiD ConfigDDTOD Filters→ Jobs• ProspectSearchStrategy• ServiceTraits© DataClient.php15 C1617 C181920|2122232425262728293045public const string JIMINNY_MARKER = 'Jiminny Summary:';public function generateTitle(Activity $activity): ?string{if ($activity->hasTitle()) {$title = $activity->getTitle();} elseif ($activity->hasActivityTypeO)) {Stitle =Sactivity->getActivityType() ->getName();Cascade & TlCommand 81} else {$title = 'Conference Call':return $title;}-public function convertMeetingOutcome(Activity Sactivity): ?stringf...}© DecorateActivity.php2 usages© LocalSearch.php46public function convertCallStatus(Activity $activity): string{...}© LocalSearchlnterface.php55DamntaCaornhnhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)=laravel.logSF [jiminny@localhost]A HS_local [jiminny@localho:W4 console [QAI PROD] X4 console [PROD]A console (EU]DGo jiminny084143 ×4 л215•m_layout_id =2162,1661,66799,662172181 219id = 33;1 22281— 221|-222=223— 224|id THEN '(own225226_227228229230hubspot':-=231— 232233V= 11512582;_234-W Windsurf Teams22:48 (15 chars)UTF-8Ca 4 spaces...
|
45457
|
NULL
|
NULL
|
NULL
|
|
45461
|
1627
|
9
|
2026-05-14T14:38:37.911194+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769517911_m1.jpg...
|
PhpStorm
|
faVsco.js – DecorateActivity.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
2
15
12
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot;
use Illuminate\Support\Collection;
use Jiminny\Models\Activity;
use Jiminny\Repositories\ActivityMessageRepository;
use Jiminny\Repositories\ParticipantRepository;
use Jiminny\Services\Crm\DecorateActivity\BaseDecorateActivity;
class DecorateActivity extends BaseDecorateActivity
{
public const string JIMINNY_MARKER = 'Jiminny Summary:';
public function generateTitle(Activity $activity): ?string
{
if ($activity->hasTitle()) {
$title = $activity->getTitle();
} elseif ($activity->hasActivityType()) {
$title = $activity->getActivityType()->getName();
} else {
$title = 'Conference Call';
}
return $title;
}
public function convertMeetingOutcome(Activity $activity): ?string
{
switch ($activity->getStatus()) {
case Activity::STATUS_SCHEDULED:
return 'SCHEDULED';
case Activity::STATUS_CANCELLED:
return 'CANCELED';
case Activity::STATUS_COMPLETED:
return 'COMPLETED';
//case Activity::STATUS_NO_SHOW:
// return 'NO_SHOW';
default:
return null;
}
}
public function convertCallStatus(Activity $activity): string
{
switch ($activity->getStatus()) {
case Activity::STATUS_NO_ANSWER:
return 'NO_ANSWER';
default:
return 'COMPLETED';
}
}
public function generateDescription(Activity $activity): ?string
{
if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {
return $this->formatSmsDescription($activity);
}
$description = $this->baseDescription();
if ($activity->hasTitle() && $activity->hasActivityType()) {
$description .= $this->formatActivityType($activity->getActivityType()->getName());
}
if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {
$description .= $this->formatSoftphoneDetails($activity);
}
$description .= $this->formatReasonOrPreview($activity);
if ($activity->isTypeConference()) {
$description .= $this->formatAttendeesList($activity);
}
return $description
. $this->formatNotes($activity)
. $this->formatMessages($activity)
. $this->formatSummary($activity);
}
public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string
{
if (empty($existingCrmDescription)) {
return $jiminnyDescription;
}
if (! $this->isJiminnyDescription($existingCrmDescription)) {
return $existingCrmDescription . '<hr>' . $jiminnyDescription;
}
$existingSections = $this->parseHtmlSections($existingCrmDescription);
$newSections = $this->parseHtmlSections($jiminnyDescription);
return $this->mergeHtmlSections($newSections, $existingSections);
}
private function parseHtmlSections(string $html): array
{
$sections = [
'beforeJiminny' => '',
'header' => '',
];
foreach (self::SECTION_HEADERS as $name) {
$sections[$name] = '';
}
$headerStartPos = $this->findHeaderStartPosition($html);
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($headerStartPos !== false && $headerStartPos > 0) {
$sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));
}
if ($headerStartPos !== false) {
$jiminnyStart = $headerStartPos;
} elseif ($markerPos !== false) {
$jiminnyStart = $markerPos;
} else {
$jiminnyStart = 0;
}
$firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);
if ($firstSectionPos === false) {
$sections['header'] = substr($html, $jiminnyStart);
} else {
$sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);
}
$sections['header'] = trim($sections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);
}
return $sections;
}
private function findHeaderStartPosition(string $html): int|false
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*<span[^>]*>\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
return $matches[0][1];
}
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($markerPos === false) {
return false;
}
$beforeMarker = substr($html, 0, $markerPos);
$lastPTagPos = strrpos($beforeMarker, '<p');
return $lastPTagPos !== false ? $lastPTagPos : $markerPos;
}
private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false
{
$firstPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($firstPos === false || $pos < $firstPos) {
$firstPos = $pos;
}
}
}
return $firstPos;
}
private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
return '';
}
$headerMatch = $matches[0][0];
$headerPos = $matches[0][1];
$contentStart = $headerPos + strlen($headerMatch);
$nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);
if ($nextSectionPos === false) {
$content = substr($html, $contentStart);
} else {
$content = substr($html, $contentStart, $nextSectionPos - $contentStart);
}
return trim($content);
}
private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false
{
$nextPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($nextPos === false || $pos < $nextPos) {
$nextPos = $pos;
}
}
}
return $nextPos;
}
private function mergeHtmlSections(array $newSections, array $existingSections): string
{
$result = '';
if (! empty($existingSections['beforeJiminny'])) {
$result .= $existingSections['beforeJiminny'];
}
$result .= $this->wrapHeader($newSections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$existingContent = $existingSections[$sectionName] ?? '';
$newContent = $newSections[$sectionName] ?? '';
$content = ! empty($existingContent) ? $existingContent : $newContent;
if (! empty($content)) {
$result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;
}
}
return $result;
}
private function wrapHeader(string $header): string
{
$header = trim($header);
if (str_starts_with($header, '<p>')) {
return $header;
}
if (str_starts_with($header, self::JIMINNY_MARKER)) {
return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));
}
return $header;
}
private function baseDescription(): string
{
return sprintf(
'<p><strong><span style="font-size: 15px; line-height: 30px;">%s</span></strong></p>',
'Jiminny Summary:'
);
}
private function formatSoftphoneDetails(Activity $activity): string
{
$isOutbound = $activity->isTypeSoftPhone();
$isInbound = $activity->isTypeSoftphoneInbound();
if (! $isOutbound && ! $isInbound) {
return '';
}
$output = $this->formatTitle($activity->getTitle());
$output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));
$phone = $isOutbound
? $activity->to?->phone_number
: $activity->from?->phone_number;
if ($phone) {
$output .= $isOutbound
? $this->formatDialedNumber($phone)
: $this->formatCallerNumber($phone);
}
return $output . '<p></p>';
}
private function formatReasonOrPreview(Activity $activity): string
{
if ($activity->hasReasonCodeBotKicked()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker removed from this meeting'
. '</span></p>';
}
if ($activity->hasReasonCodeNotCompliant()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker did not join due to recording consent not being provided by attendees'
. '</span></p>';
}
return $this->formatPreviewUrl($activity);
}
public function formatStartTime(Activity $activity): int
{
return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatEndTime(Activity $activity): int
{
return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCreatedAt(Activity $activity): int
{
return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCallToParticipant(Activity $activity): ?string
{
$callToParticipant = $activity->getToParticipant()?->getPhoneNumber();
if ($callToParticipant && $activity->hasContact()) {
return $activity->getContact()->getName() . ' ' . $callToParticipant;
}
return null;
}
private function formatActivityType(string $activityType): string
{
return '<p><strong><span style="font-size: 18.6667px; line-height: 22.4px;">' . $activityType . '</span></strong></p>';
}
private function formatTitle(?string $title): string
{
return $title ? '<p><span style="font-size: 16px; line-height: 19.2px;">' . $title . '</span></p>' : '';
}
private function formatCallDuration(string $duration): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Call Duration: ' . $duration . '</span></p>';
}
private function formatDialedNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Dialed: ' . $phoneNumber . '</span></p>';
}
private function formatCallerNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Caller: ' . $phoneNumber . '</span></p>';
}
private function formatAttendeesList(Activity $activity): string
{
$attendeesList = '<p><strong>Attendees</strong></p><ul>';
$participantsRepository = app(ParticipantRepository::class);
// Only include participants that joined.
$participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);
foreach ($participants as $participant) {
$attendee = '<li>';
if ($participant->hasName()) {
$attendee .= $participant->getName();
if ($participant->hasPhoneNumber()) {
$attendee .= ' (' . $participant->getPhoneNumber() . ')';
} elseif ($participant->hasEmailAddress()) {
$attendee .= ' (' . $participant->getEmailAddress() . ')';
}
} else {
$attendee .= $participant->getPhoneNumber();
}
if ($participant->isCoach()) {
$attendee .= ' <strong>coach</strong>';
}
if ($participant->getTitle()) {
$attendee .= ', ' . $participant->getTitle();
}
$attendeesList .= $attendee . '</li>';
}
return $attendeesList . '</ul>';
}
private function formatPreviewUrl(Activity $activity): string
{
$description = '';
$team = $activity->getUser()->getTeam();
if ($activity->canReviewActivity()) {
$playbackUrl = $team->getPartner()->getPlaybackUrl($activity);
$description .= '<p><span style="font-size: 13.3333px; line-height: 16px;"><a href="'
. $playbackUrl
. '" target="_blank">Review in Jiminny</a> ▶️</span></p>';
}
return $description;
}
private function formatNotes(Activity $activity): string
{
$description = '';
if ($activity->getNotes()->isEmpty()) {
return $description;
}
$description .= '<p><strong>Notes</strong></p>';
foreach ($activity->getNotes() as $note) {
$time = ($note->getTime() > 3600)
? gmdate('H:i:s', (int) $note->getTime())
: gmdate('i:s', (int) $note->getTime());
$description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';
}
return $description . '</p>';
}
private function formatMessages(Activity $activity): string
{
$description = '';
$messageRepository = app(ActivityMessageRepository::class);
// Get all private messages.
$privateMessages = $messageRepository->getPrivateMessages($activity);
if ($privateMessages->isNotEmpty()) {
$description .= '<p><strong>Coaching Chat</strong></p>';
$description .= $this->getMessagesAsString($privateMessages);
$description .= '</p>';
}
// Get all public messages
$publicMessages = $messageRepository->getPublicMessages($activity);
if ($publicMessages->isNotEmpty()) {
$description .= '<p><strong>Customer Chat</strong></p>';
$description .= $this->getMessagesAsString($publicMessages);
$description .= '</p>';
}
return $description;
}
private function getMessagesAsString(Collection $messages): string
{
$description = '';
/** @var Activity\Message $message */
foreach ($messages as $message) {
$description .= '<p>' . $message->participant->getName()
. ': ' . $message->getAttribute('message') . '</p>';
}
return $description;
}
private function formatSummary(Activity $activity): string
{
$description = '';
if ($activity->getSummary() !== null) {
$description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';
}
return $description;
}
private function formatSmsDescription(Activity $activity): string
{
// Use Rich-text formatting.
$description = '<p><span style="font-size: 16px; line-height: 19.2px;"><strong>' . $activity->getTitle() . '</strong></span></p>';
$description .= '<p><span style="font-size: 16px; line-height: 19.2px;">' . $activity->getDescription() . '</span></p>';
return $description;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.73333335,"top":0.3122222,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.75277776,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"15","depth":4,"bounds":{"left":0.7736111,"top":0.3122222,"width":0.02013889,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"12","depth":4,"bounds":{"left":0.79791665,"top":0.3122222,"width":0.02013889,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Repositories\\ActivityMessageRepository;\nuse Jiminny\\Repositories\\ParticipantRepository;\nuse Jiminny\\Services\\Crm\\DecorateActivity\\BaseDecorateActivity;\n\nclass DecorateActivity extends BaseDecorateActivity\n{\n public const string JIMINNY_MARKER = 'Jiminny Summary:';\n\n public function generateTitle(Activity $activity): ?string\n {\n if ($activity->hasTitle()) {\n $title = $activity->getTitle();\n } elseif ($activity->hasActivityType()) {\n $title = $activity->getActivityType()->getName();\n } else {\n $title = 'Conference Call';\n }\n\n return $title;\n }\n\n public function convertMeetingOutcome(Activity $activity): ?string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_SCHEDULED:\n return 'SCHEDULED';\n case Activity::STATUS_CANCELLED:\n return 'CANCELED';\n case Activity::STATUS_COMPLETED:\n return 'COMPLETED';\n //case Activity::STATUS_NO_SHOW:\n // return 'NO_SHOW';\n default:\n return null;\n }\n }\n\n public function convertCallStatus(Activity $activity): string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_NO_ANSWER:\n return 'NO_ANSWER';\n default:\n return 'COMPLETED';\n }\n }\n\n public function generateDescription(Activity $activity): ?string\n {\n if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {\n return $this->formatSmsDescription($activity);\n }\n\n $description = $this->baseDescription();\n\n if ($activity->hasTitle() && $activity->hasActivityType()) {\n $description .= $this->formatActivityType($activity->getActivityType()->getName());\n }\n\n if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {\n $description .= $this->formatSoftphoneDetails($activity);\n }\n\n $description .= $this->formatReasonOrPreview($activity);\n\n if ($activity->isTypeConference()) {\n $description .= $this->formatAttendeesList($activity);\n }\n\n return $description\n . $this->formatNotes($activity)\n . $this->formatMessages($activity)\n . $this->formatSummary($activity);\n }\n\n public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string\n {\n if (empty($existingCrmDescription)) {\n return $jiminnyDescription;\n }\n\n if (! $this->isJiminnyDescription($existingCrmDescription)) {\n return $existingCrmDescription . '<hr>' . $jiminnyDescription;\n }\n\n $existingSections = $this->parseHtmlSections($existingCrmDescription);\n $newSections = $this->parseHtmlSections($jiminnyDescription);\n\n return $this->mergeHtmlSections($newSections, $existingSections);\n }\n\n private function parseHtmlSections(string $html): array\n {\n $sections = [\n 'beforeJiminny' => '',\n 'header' => '',\n ];\n\n foreach (self::SECTION_HEADERS as $name) {\n $sections[$name] = '';\n }\n\n $headerStartPos = $this->findHeaderStartPosition($html);\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n\n if ($headerStartPos !== false && $headerStartPos > 0) {\n $sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));\n }\n\n if ($headerStartPos !== false) {\n $jiminnyStart = $headerStartPos;\n } elseif ($markerPos !== false) {\n $jiminnyStart = $markerPos;\n } else {\n $jiminnyStart = 0;\n }\n\n $firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);\n\n if ($firstSectionPos === false) {\n $sections['header'] = substr($html, $jiminnyStart);\n } else {\n $sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);\n }\n\n $sections['header'] = trim($sections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);\n }\n\n return $sections;\n }\n\n private function findHeaderStartPosition(string $html): int|false\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*<span[^>]*>\\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';\n\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {\n return $matches[0][1];\n }\n\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n if ($markerPos === false) {\n return false;\n }\n\n $beforeMarker = substr($html, 0, $markerPos);\n $lastPTagPos = strrpos($beforeMarker, '<p');\n\n return $lastPTagPos !== false ? $lastPTagPos : $markerPos;\n }\n\n private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false\n {\n $firstPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($firstPos === false || $pos < $firstPos) {\n $firstPos = $pos;\n }\n }\n }\n\n return $firstPos;\n }\n\n private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n\n if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n return '';\n }\n\n $headerMatch = $matches[0][0];\n $headerPos = $matches[0][1];\n $contentStart = $headerPos + strlen($headerMatch);\n\n $nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);\n\n if ($nextSectionPos === false) {\n $content = substr($html, $contentStart);\n } else {\n $content = substr($html, $contentStart, $nextSectionPos - $contentStart);\n }\n\n return trim($content);\n }\n\n private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false\n {\n $nextPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($nextPos === false || $pos < $nextPos) {\n $nextPos = $pos;\n }\n }\n }\n\n return $nextPos;\n }\n\n private function mergeHtmlSections(array $newSections, array $existingSections): string\n {\n $result = '';\n\n if (! empty($existingSections['beforeJiminny'])) {\n $result .= $existingSections['beforeJiminny'];\n }\n\n $result .= $this->wrapHeader($newSections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $existingContent = $existingSections[$sectionName] ?? '';\n $newContent = $newSections[$sectionName] ?? '';\n\n $content = ! empty($existingContent) ? $existingContent : $newContent;\n\n if (! empty($content)) {\n $result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;\n }\n }\n\n return $result;\n }\n\n private function wrapHeader(string $header): string\n {\n $header = trim($header);\n\n if (str_starts_with($header, '<p>')) {\n return $header;\n }\n\n if (str_starts_with($header, self::JIMINNY_MARKER)) {\n return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));\n }\n\n return $header;\n }\n\n private function baseDescription(): string\n {\n return sprintf(\n '<p><strong><span style=\"font-size: 15px; line-height: 30px;\">%s</span></strong></p>',\n 'Jiminny Summary:'\n );\n }\n\n private function formatSoftphoneDetails(Activity $activity): string\n {\n $isOutbound = $activity->isTypeSoftPhone();\n $isInbound = $activity->isTypeSoftphoneInbound();\n\n if (! $isOutbound && ! $isInbound) {\n return '';\n }\n\n $output = $this->formatTitle($activity->getTitle());\n $output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));\n\n $phone = $isOutbound\n ? $activity->to?->phone_number\n : $activity->from?->phone_number;\n\n if ($phone) {\n $output .= $isOutbound\n ? $this->formatDialedNumber($phone)\n : $this->formatCallerNumber($phone);\n }\n\n return $output . '<p></p>';\n }\n\n private function formatReasonOrPreview(Activity $activity): string\n {\n if ($activity->hasReasonCodeBotKicked()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker removed from this meeting'\n . '</span></p>';\n }\n\n if ($activity->hasReasonCodeNotCompliant()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker did not join due to recording consent not being provided by attendees'\n . '</span></p>';\n }\n\n return $this->formatPreviewUrl($activity);\n }\n\n\n public function formatStartTime(Activity $activity): int\n {\n return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatEndTime(Activity $activity): int\n {\n return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCreatedAt(Activity $activity): int\n {\n return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCallToParticipant(Activity $activity): ?string\n {\n $callToParticipant = $activity->getToParticipant()?->getPhoneNumber();\n if ($callToParticipant && $activity->hasContact()) {\n return $activity->getContact()->getName() . ' ' . $callToParticipant;\n }\n\n return null;\n }\n\n private function formatActivityType(string $activityType): string\n {\n return '<p><strong><span style=\"font-size: 18.6667px; line-height: 22.4px;\">' . $activityType . '</span></strong></p>';\n }\n\n private function formatTitle(?string $title): string\n {\n return $title ? '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $title . '</span></p>' : '';\n }\n\n private function formatCallDuration(string $duration): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Call Duration: ' . $duration . '</span></p>';\n }\n\n private function formatDialedNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Dialed: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatCallerNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Caller: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatAttendeesList(Activity $activity): string\n {\n $attendeesList = '<p><strong>Attendees</strong></p><ul>';\n\n $participantsRepository = app(ParticipantRepository::class);\n // Only include participants that joined.\n $participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);\n foreach ($participants as $participant) {\n $attendee = '<li>';\n if ($participant->hasName()) {\n $attendee .= $participant->getName();\n if ($participant->hasPhoneNumber()) {\n $attendee .= ' (' . $participant->getPhoneNumber() . ')';\n } elseif ($participant->hasEmailAddress()) {\n $attendee .= ' (' . $participant->getEmailAddress() . ')';\n }\n } else {\n $attendee .= $participant->getPhoneNumber();\n }\n\n if ($participant->isCoach()) {\n $attendee .= ' <strong>coach</strong>';\n }\n\n if ($participant->getTitle()) {\n $attendee .= ', ' . $participant->getTitle();\n }\n\n $attendeesList .= $attendee . '</li>';\n }\n\n return $attendeesList . '</ul>';\n }\n\n private function formatPreviewUrl(Activity $activity): string\n {\n $description = '';\n $team = $activity->getUser()->getTeam();\n\n if ($activity->canReviewActivity()) {\n $playbackUrl = $team->getPartner()->getPlaybackUrl($activity);\n $description .= '<p><span style=\"font-size: 13.3333px; line-height: 16px;\"><a href=\"'\n . $playbackUrl\n . '\" target=\"_blank\">Review in Jiminny</a> ▶️</span></p>';\n }\n\n return $description;\n }\n\n private function formatNotes(Activity $activity): string\n {\n $description = '';\n if ($activity->getNotes()->isEmpty()) {\n return $description;\n }\n\n $description .= '<p><strong>Notes</strong></p>';\n foreach ($activity->getNotes() as $note) {\n $time = ($note->getTime() > 3600)\n ? gmdate('H:i:s', (int) $note->getTime())\n : gmdate('i:s', (int) $note->getTime());\n\n $description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';\n }\n\n return $description . '</p>';\n }\n\n private function formatMessages(Activity $activity): string\n {\n $description = '';\n $messageRepository = app(ActivityMessageRepository::class);\n\n // Get all private messages.\n $privateMessages = $messageRepository->getPrivateMessages($activity);\n if ($privateMessages->isNotEmpty()) {\n $description .= '<p><strong>Coaching Chat</strong></p>';\n $description .= $this->getMessagesAsString($privateMessages);\n $description .= '</p>';\n }\n\n // Get all public messages\n $publicMessages = $messageRepository->getPublicMessages($activity);\n if ($publicMessages->isNotEmpty()) {\n $description .= '<p><strong>Customer Chat</strong></p>';\n $description .= $this->getMessagesAsString($publicMessages);\n $description .= '</p>';\n }\n\n return $description;\n }\n\n private function getMessagesAsString(Collection $messages): string\n {\n $description = '';\n\n /** @var Activity\\Message $message */\n foreach ($messages as $message) {\n $description .= '<p>' . $message->participant->getName()\n . ': ' . $message->getAttribute('message') . '</p>';\n }\n\n return $description;\n }\n\n private function formatSummary(Activity $activity): string\n {\n $description = '';\n if ($activity->getSummary() !== null) {\n $description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';\n }\n\n return $description;\n }\n\n private function formatSmsDescription(Activity $activity): string\n {\n // Use Rich-text formatting.\n $description = '<p><span style=\"font-size: 16px; line-height: 19.2px;\"><strong>' . $activity->getTitle() . '</strong></span></p>';\n $description .= '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $activity->getDescription() . '</span></p>';\n\n return $description;\n }\n}","depth":4,"bounds":{"left":0.26597223,"top":0.21111111,"width":0.6548611,"height":0.7888889},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\Hubspot;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Repositories\\ActivityMessageRepository;\nuse Jiminny\\Repositories\\ParticipantRepository;\nuse Jiminny\\Services\\Crm\\DecorateActivity\\BaseDecorateActivity;\n\nclass DecorateActivity extends BaseDecorateActivity\n{\n public const string JIMINNY_MARKER = 'Jiminny Summary:';\n\n public function generateTitle(Activity $activity): ?string\n {\n if ($activity->hasTitle()) {\n $title = $activity->getTitle();\n } elseif ($activity->hasActivityType()) {\n $title = $activity->getActivityType()->getName();\n } else {\n $title = 'Conference Call';\n }\n\n return $title;\n }\n\n public function convertMeetingOutcome(Activity $activity): ?string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_SCHEDULED:\n return 'SCHEDULED';\n case Activity::STATUS_CANCELLED:\n return 'CANCELED';\n case Activity::STATUS_COMPLETED:\n return 'COMPLETED';\n //case Activity::STATUS_NO_SHOW:\n // return 'NO_SHOW';\n default:\n return null;\n }\n }\n\n public function convertCallStatus(Activity $activity): string\n {\n switch ($activity->getStatus()) {\n case Activity::STATUS_NO_ANSWER:\n return 'NO_ANSWER';\n default:\n return 'COMPLETED';\n }\n }\n\n public function generateDescription(Activity $activity): ?string\n {\n if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {\n return $this->formatSmsDescription($activity);\n }\n\n $description = $this->baseDescription();\n\n if ($activity->hasTitle() && $activity->hasActivityType()) {\n $description .= $this->formatActivityType($activity->getActivityType()->getName());\n }\n\n if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {\n $description .= $this->formatSoftphoneDetails($activity);\n }\n\n $description .= $this->formatReasonOrPreview($activity);\n\n if ($activity->isTypeConference()) {\n $description .= $this->formatAttendeesList($activity);\n }\n\n return $description\n . $this->formatNotes($activity)\n . $this->formatMessages($activity)\n . $this->formatSummary($activity);\n }\n\n public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string\n {\n if (empty($existingCrmDescription)) {\n return $jiminnyDescription;\n }\n\n if (! $this->isJiminnyDescription($existingCrmDescription)) {\n return $existingCrmDescription . '<hr>' . $jiminnyDescription;\n }\n\n $existingSections = $this->parseHtmlSections($existingCrmDescription);\n $newSections = $this->parseHtmlSections($jiminnyDescription);\n\n return $this->mergeHtmlSections($newSections, $existingSections);\n }\n\n private function parseHtmlSections(string $html): array\n {\n $sections = [\n 'beforeJiminny' => '',\n 'header' => '',\n ];\n\n foreach (self::SECTION_HEADERS as $name) {\n $sections[$name] = '';\n }\n\n $headerStartPos = $this->findHeaderStartPosition($html);\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n\n if ($headerStartPos !== false && $headerStartPos > 0) {\n $sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));\n }\n\n if ($headerStartPos !== false) {\n $jiminnyStart = $headerStartPos;\n } elseif ($markerPos !== false) {\n $jiminnyStart = $markerPos;\n } else {\n $jiminnyStart = 0;\n }\n\n $firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);\n\n if ($firstSectionPos === false) {\n $sections['header'] = substr($html, $jiminnyStart);\n } else {\n $sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);\n }\n\n $sections['header'] = trim($sections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);\n }\n\n return $sections;\n }\n\n private function findHeaderStartPosition(string $html): int|false\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*<span[^>]*>\\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';\n\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {\n return $matches[0][1];\n }\n\n $markerPos = stripos($html, self::JIMINNY_MARKER);\n if ($markerPos === false) {\n return false;\n }\n\n $beforeMarker = substr($html, 0, $markerPos);\n $lastPTagPos = strrpos($beforeMarker, '<p');\n\n return $lastPTagPos !== false ? $lastPTagPos : $markerPos;\n }\n\n private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false\n {\n $firstPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($firstPos === false || $pos < $firstPos) {\n $firstPos = $pos;\n }\n }\n }\n\n return $firstPos;\n }\n\n private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string\n {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n\n if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n return '';\n }\n\n $headerMatch = $matches[0][0];\n $headerPos = $matches[0][1];\n $contentStart = $headerPos + strlen($headerMatch);\n\n $nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);\n\n if ($nextSectionPos === false) {\n $content = substr($html, $contentStart);\n } else {\n $content = substr($html, $contentStart, $nextSectionPos - $contentStart);\n }\n\n return trim($content);\n }\n\n private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false\n {\n $nextPos = false;\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $pattern = '/<p[^>]*>\\s*<strong[^>]*>\\s*' . preg_quote($sectionName, '/') . '\\s*<\\/strong>\\s*<\\/p>/i';\n if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {\n $pos = $matches[0][1];\n if ($nextPos === false || $pos < $nextPos) {\n $nextPos = $pos;\n }\n }\n }\n\n return $nextPos;\n }\n\n private function mergeHtmlSections(array $newSections, array $existingSections): string\n {\n $result = '';\n\n if (! empty($existingSections['beforeJiminny'])) {\n $result .= $existingSections['beforeJiminny'];\n }\n\n $result .= $this->wrapHeader($newSections['header']);\n\n foreach (self::SECTION_HEADERS as $sectionName) {\n $existingContent = $existingSections[$sectionName] ?? '';\n $newContent = $newSections[$sectionName] ?? '';\n\n $content = ! empty($existingContent) ? $existingContent : $newContent;\n\n if (! empty($content)) {\n $result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;\n }\n }\n\n return $result;\n }\n\n private function wrapHeader(string $header): string\n {\n $header = trim($header);\n\n if (str_starts_with($header, '<p>')) {\n return $header;\n }\n\n if (str_starts_with($header, self::JIMINNY_MARKER)) {\n return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));\n }\n\n return $header;\n }\n\n private function baseDescription(): string\n {\n return sprintf(\n '<p><strong><span style=\"font-size: 15px; line-height: 30px;\">%s</span></strong></p>',\n 'Jiminny Summary:'\n );\n }\n\n private function formatSoftphoneDetails(Activity $activity): string\n {\n $isOutbound = $activity->isTypeSoftPhone();\n $isInbound = $activity->isTypeSoftphoneInbound();\n\n if (! $isOutbound && ! $isInbound) {\n return '';\n }\n\n $output = $this->formatTitle($activity->getTitle());\n $output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));\n\n $phone = $isOutbound\n ? $activity->to?->phone_number\n : $activity->from?->phone_number;\n\n if ($phone) {\n $output .= $isOutbound\n ? $this->formatDialedNumber($phone)\n : $this->formatCallerNumber($phone);\n }\n\n return $output . '<p></p>';\n }\n\n private function formatReasonOrPreview(Activity $activity): string\n {\n if ($activity->hasReasonCodeBotKicked()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker removed from this meeting'\n . '</span></p>';\n }\n\n if ($activity->hasReasonCodeNotCompliant()) {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">'\n . 'Notetaker did not join due to recording consent not being provided by attendees'\n . '</span></p>';\n }\n\n return $this->formatPreviewUrl($activity);\n }\n\n\n public function formatStartTime(Activity $activity): int\n {\n return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatEndTime(Activity $activity): int\n {\n return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCreatedAt(Activity $activity): int\n {\n return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;\n }\n\n public function formatCallToParticipant(Activity $activity): ?string\n {\n $callToParticipant = $activity->getToParticipant()?->getPhoneNumber();\n if ($callToParticipant && $activity->hasContact()) {\n return $activity->getContact()->getName() . ' ' . $callToParticipant;\n }\n\n return null;\n }\n\n private function formatActivityType(string $activityType): string\n {\n return '<p><strong><span style=\"font-size: 18.6667px; line-height: 22.4px;\">' . $activityType . '</span></strong></p>';\n }\n\n private function formatTitle(?string $title): string\n {\n return $title ? '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $title . '</span></p>' : '';\n }\n\n private function formatCallDuration(string $duration): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Call Duration: ' . $duration . '</span></p>';\n }\n\n private function formatDialedNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Dialed: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatCallerNumber(string $phoneNumber): string\n {\n return '<p><span style=\"font-size: 13.3333px; line-height: 16px;\">Caller: ' . $phoneNumber . '</span></p>';\n }\n\n private function formatAttendeesList(Activity $activity): string\n {\n $attendeesList = '<p><strong>Attendees</strong></p><ul>';\n\n $participantsRepository = app(ParticipantRepository::class);\n // Only include participants that joined.\n $participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);\n foreach ($participants as $participant) {\n $attendee = '<li>';\n if ($participant->hasName()) {\n $attendee .= $participant->getName();\n if ($participant->hasPhoneNumber()) {\n $attendee .= ' (' . $participant->getPhoneNumber() . ')';\n } elseif ($participant->hasEmailAddress()) {\n $attendee .= ' (' . $participant->getEmailAddress() . ')';\n }\n } else {\n $attendee .= $participant->getPhoneNumber();\n }\n\n if ($participant->isCoach()) {\n $attendee .= ' <strong>coach</strong>';\n }\n\n if ($participant->getTitle()) {\n $attendee .= ', ' . $participant->getTitle();\n }\n\n $attendeesList .= $attendee . '</li>';\n }\n\n return $attendeesList . '</ul>';\n }\n\n private function formatPreviewUrl(Activity $activity): string\n {\n $description = '';\n $team = $activity->getUser()->getTeam();\n\n if ($activity->canReviewActivity()) {\n $playbackUrl = $team->getPartner()->getPlaybackUrl($activity);\n $description .= '<p><span style=\"font-size: 13.3333px; line-height: 16px;\"><a href=\"'\n . $playbackUrl\n . '\" target=\"_blank\">Review in Jiminny</a> ▶️</span></p>';\n }\n\n return $description;\n }\n\n private function formatNotes(Activity $activity): string\n {\n $description = '';\n if ($activity->getNotes()->isEmpty()) {\n return $description;\n }\n\n $description .= '<p><strong>Notes</strong></p>';\n foreach ($activity->getNotes() as $note) {\n $time = ($note->getTime() > 3600)\n ? gmdate('H:i:s', (int) $note->getTime())\n : gmdate('i:s', (int) $note->getTime());\n\n $description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';\n }\n\n return $description . '</p>';\n }\n\n private function formatMessages(Activity $activity): string\n {\n $description = '';\n $messageRepository = app(ActivityMessageRepository::class);\n\n // Get all private messages.\n $privateMessages = $messageRepository->getPrivateMessages($activity);\n if ($privateMessages->isNotEmpty()) {\n $description .= '<p><strong>Coaching Chat</strong></p>';\n $description .= $this->getMessagesAsString($privateMessages);\n $description .= '</p>';\n }\n\n // Get all public messages\n $publicMessages = $messageRepository->getPublicMessages($activity);\n if ($publicMessages->isNotEmpty()) {\n $description .= '<p><strong>Customer Chat</strong></p>';\n $description .= $this->getMessagesAsString($publicMessages);\n $description .= '</p>';\n }\n\n return $description;\n }\n\n private function getMessagesAsString(Collection $messages): string\n {\n $description = '';\n\n /** @var Activity\\Message $message */\n foreach ($messages as $message) {\n $description .= '<p>' . $message->participant->getName()\n . ': ' . $message->getAttribute('message') . '</p>';\n }\n\n return $description;\n }\n\n private function formatSummary(Activity $activity): string\n {\n $description = '';\n if ($activity->getSummary() !== null) {\n $description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';\n }\n\n return $description;\n }\n\n private function formatSmsDescription(Activity $activity): string\n {\n // Use Rich-text formatting.\n $description = '<p><span style=\"font-size: 16px; line-height: 19.2px;\"><strong>' . $activity->getTitle() . '</strong></span></p>';\n $description .= '<p><span style=\"font-size: 16px; line-height: 19.2px;\">' . $activity->getDescription() . '</span></p>';\n\n return $description;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"bounds":{"left":0.8645833,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.8854167,"top":0.34444445,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"bounds":{"left":0.9048611,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.92569447,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.9458333,"top":0.3422222,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.9611111,"top":0.3422222,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.025,"top":0.06666667,"width":0.050694443,"height":0.034444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6902378850207333842
|
9001456016336028185
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
2
15
12
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\Hubspot;
use Illuminate\Support\Collection;
use Jiminny\Models\Activity;
use Jiminny\Repositories\ActivityMessageRepository;
use Jiminny\Repositories\ParticipantRepository;
use Jiminny\Services\Crm\DecorateActivity\BaseDecorateActivity;
class DecorateActivity extends BaseDecorateActivity
{
public const string JIMINNY_MARKER = 'Jiminny Summary:';
public function generateTitle(Activity $activity): ?string
{
if ($activity->hasTitle()) {
$title = $activity->getTitle();
} elseif ($activity->hasActivityType()) {
$title = $activity->getActivityType()->getName();
} else {
$title = 'Conference Call';
}
return $title;
}
public function convertMeetingOutcome(Activity $activity): ?string
{
switch ($activity->getStatus()) {
case Activity::STATUS_SCHEDULED:
return 'SCHEDULED';
case Activity::STATUS_CANCELLED:
return 'CANCELED';
case Activity::STATUS_COMPLETED:
return 'COMPLETED';
//case Activity::STATUS_NO_SHOW:
// return 'NO_SHOW';
default:
return null;
}
}
public function convertCallStatus(Activity $activity): string
{
switch ($activity->getStatus()) {
case Activity::STATUS_NO_ANSWER:
return 'NO_ANSWER';
default:
return 'COMPLETED';
}
}
public function generateDescription(Activity $activity): ?string
{
if (in_array($activity->getType(), [Activity::TYPE_SMS_INBOUND, Activity::TYPE_SMS_OUTBOUND], true)) {
return $this->formatSmsDescription($activity);
}
$description = $this->baseDescription();
if ($activity->hasTitle() && $activity->hasActivityType()) {
$description .= $this->formatActivityType($activity->getActivityType()->getName());
}
if ($activity->getProvider() !== Activity::PROVIDER_UPLOADER) {
$description .= $this->formatSoftphoneDetails($activity);
}
$description .= $this->formatReasonOrPreview($activity);
if ($activity->isTypeConference()) {
$description .= $this->formatAttendeesList($activity);
}
return $description
. $this->formatNotes($activity)
. $this->formatMessages($activity)
. $this->formatSummary($activity);
}
public function mergeDescriptions(string $jiminnyDescription, ?string $existingCrmDescription): string
{
if (empty($existingCrmDescription)) {
return $jiminnyDescription;
}
if (! $this->isJiminnyDescription($existingCrmDescription)) {
return $existingCrmDescription . '<hr>' . $jiminnyDescription;
}
$existingSections = $this->parseHtmlSections($existingCrmDescription);
$newSections = $this->parseHtmlSections($jiminnyDescription);
return $this->mergeHtmlSections($newSections, $existingSections);
}
private function parseHtmlSections(string $html): array
{
$sections = [
'beforeJiminny' => '',
'header' => '',
];
foreach (self::SECTION_HEADERS as $name) {
$sections[$name] = '';
}
$headerStartPos = $this->findHeaderStartPosition($html);
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($headerStartPos !== false && $headerStartPos > 0) {
$sections['beforeJiminny'] = trim(substr($html, 0, $headerStartPos));
}
if ($headerStartPos !== false) {
$jiminnyStart = $headerStartPos;
} elseif ($markerPos !== false) {
$jiminnyStart = $markerPos;
} else {
$jiminnyStart = 0;
}
$firstSectionPos = $this->findFirstHtmlSectionPosition($html, $jiminnyStart);
if ($firstSectionPos === false) {
$sections['header'] = substr($html, $jiminnyStart);
} else {
$sections['header'] = substr($html, $jiminnyStart, $firstSectionPos - $jiminnyStart);
}
$sections['header'] = trim($sections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$sections[$sectionName] = $this->extractHtmlSectionContent($html, $sectionName, $jiminnyStart);
}
return $sections;
}
private function findHeaderStartPosition(string $html): int|false
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*<span[^>]*>\s*' . preg_quote(self::JIMINNY_MARKER, '/') . '/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
return $matches[0][1];
}
$markerPos = stripos($html, self::JIMINNY_MARKER);
if ($markerPos === false) {
return false;
}
$beforeMarker = substr($html, 0, $markerPos);
$lastPTagPos = strrpos($beforeMarker, '<p');
return $lastPTagPos !== false ? $lastPTagPos : $markerPos;
}
private function findFirstHtmlSectionPosition(string $html, int $afterPosition = 0): int|false
{
$firstPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($firstPos === false || $pos < $firstPos) {
$firstPos = $pos;
}
}
}
return $firstPos;
}
private function extractHtmlSectionContent(string $html, string $sectionName, int $afterPosition = 0): string
{
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (! preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
return '';
}
$headerMatch = $matches[0][0];
$headerPos = $matches[0][1];
$contentStart = $headerPos + strlen($headerMatch);
$nextSectionPos = $this->findNextHtmlSectionPosition($html, $contentStart);
if ($nextSectionPos === false) {
$content = substr($html, $contentStart);
} else {
$content = substr($html, $contentStart, $nextSectionPos - $contentStart);
}
return trim($content);
}
private function findNextHtmlSectionPosition(string $html, int $afterPosition): int|false
{
$nextPos = false;
foreach (self::SECTION_HEADERS as $sectionName) {
$pattern = '/<p[^>]*>\s*<strong[^>]*>\s*' . preg_quote($sectionName, '/') . '\s*<\/strong>\s*<\/p>/i';
if (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE, $afterPosition)) {
$pos = $matches[0][1];
if ($nextPos === false || $pos < $nextPos) {
$nextPos = $pos;
}
}
}
return $nextPos;
}
private function mergeHtmlSections(array $newSections, array $existingSections): string
{
$result = '';
if (! empty($existingSections['beforeJiminny'])) {
$result .= $existingSections['beforeJiminny'];
}
$result .= $this->wrapHeader($newSections['header']);
foreach (self::SECTION_HEADERS as $sectionName) {
$existingContent = $existingSections[$sectionName] ?? '';
$newContent = $newSections[$sectionName] ?? '';
$content = ! empty($existingContent) ? $existingContent : $newContent;
if (! empty($content)) {
$result .= '<p><strong>' . $sectionName . '</strong></p>' . $content;
}
}
return $result;
}
private function wrapHeader(string $header): string
{
$header = trim($header);
if (str_starts_with($header, '<p>')) {
return $header;
}
if (str_starts_with($header, self::JIMINNY_MARKER)) {
return $this->baseDescription() . substr($header, strlen(self::JIMINNY_MARKER));
}
return $header;
}
private function baseDescription(): string
{
return sprintf(
'<p><strong><span style="font-size: 15px; line-height: 30px;">%s</span></strong></p>',
'Jiminny Summary:'
);
}
private function formatSoftphoneDetails(Activity $activity): string
{
$isOutbound = $activity->isTypeSoftPhone();
$isInbound = $activity->isTypeSoftphoneInbound();
if (! $isOutbound && ! $isInbound) {
return '';
}
$output = $this->formatTitle($activity->getTitle());
$output .= $this->formatCallDuration($activity->getAttribute('duration_for_humans'));
$phone = $isOutbound
? $activity->to?->phone_number
: $activity->from?->phone_number;
if ($phone) {
$output .= $isOutbound
? $this->formatDialedNumber($phone)
: $this->formatCallerNumber($phone);
}
return $output . '<p></p>';
}
private function formatReasonOrPreview(Activity $activity): string
{
if ($activity->hasReasonCodeBotKicked()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker removed from this meeting'
. '</span></p>';
}
if ($activity->hasReasonCodeNotCompliant()) {
return '<p><span style="font-size: 13.3333px; line-height: 16px;">'
. 'Notetaker did not join due to recording consent not being provided by attendees'
. '</span></p>';
}
return $this->formatPreviewUrl($activity);
}
public function formatStartTime(Activity $activity): int
{
return $activity->getActualStartTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatEndTime(Activity $activity): int
{
return $activity->getActualEndTime()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCreatedAt(Activity $activity): int
{
return $activity->getCreatedAt()->tz($activity->getUser()->timezone)->getTimestamp() * 1000;
}
public function formatCallToParticipant(Activity $activity): ?string
{
$callToParticipant = $activity->getToParticipant()?->getPhoneNumber();
if ($callToParticipant && $activity->hasContact()) {
return $activity->getContact()->getName() . ' ' . $callToParticipant;
}
return null;
}
private function formatActivityType(string $activityType): string
{
return '<p><strong><span style="font-size: 18.6667px; line-height: 22.4px;">' . $activityType . '</span></strong></p>';
}
private function formatTitle(?string $title): string
{
return $title ? '<p><span style="font-size: 16px; line-height: 19.2px;">' . $title . '</span></p>' : '';
}
private function formatCallDuration(string $duration): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Call Duration: ' . $duration . '</span></p>';
}
private function formatDialedNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Dialed: ' . $phoneNumber . '</span></p>';
}
private function formatCallerNumber(string $phoneNumber): string
{
return '<p><span style="font-size: 13.3333px; line-height: 16px;">Caller: ' . $phoneNumber . '</span></p>';
}
private function formatAttendeesList(Activity $activity): string
{
$attendeesList = '<p><strong>Attendees</strong></p><ul>';
$participantsRepository = app(ParticipantRepository::class);
// Only include participants that joined.
$participants = $participantsRepository->getParticipantsWhoEnteredMeeting($activity);
foreach ($participants as $participant) {
$attendee = '<li>';
if ($participant->hasName()) {
$attendee .= $participant->getName();
if ($participant->hasPhoneNumber()) {
$attendee .= ' (' . $participant->getPhoneNumber() . ')';
} elseif ($participant->hasEmailAddress()) {
$attendee .= ' (' . $participant->getEmailAddress() . ')';
}
} else {
$attendee .= $participant->getPhoneNumber();
}
if ($participant->isCoach()) {
$attendee .= ' <strong>coach</strong>';
}
if ($participant->getTitle()) {
$attendee .= ', ' . $participant->getTitle();
}
$attendeesList .= $attendee . '</li>';
}
return $attendeesList . '</ul>';
}
private function formatPreviewUrl(Activity $activity): string
{
$description = '';
$team = $activity->getUser()->getTeam();
if ($activity->canReviewActivity()) {
$playbackUrl = $team->getPartner()->getPlaybackUrl($activity);
$description .= '<p><span style="font-size: 13.3333px; line-height: 16px;"><a href="'
. $playbackUrl
. '" target="_blank">Review in Jiminny</a> ▶️</span></p>';
}
return $description;
}
private function formatNotes(Activity $activity): string
{
$description = '';
if ($activity->getNotes()->isEmpty()) {
return $description;
}
$description .= '<p><strong>Notes</strong></p>';
foreach ($activity->getNotes() as $note) {
$time = ($note->getTime() > 3600)
? gmdate('H:i:s', (int) $note->getTime())
: gmdate('i:s', (int) $note->getTime());
$description .= '<p>' . $time . ' ' . $note->getNote() . '</p>';
}
return $description . '</p>';
}
private function formatMessages(Activity $activity): string
{
$description = '';
$messageRepository = app(ActivityMessageRepository::class);
// Get all private messages.
$privateMessages = $messageRepository->getPrivateMessages($activity);
if ($privateMessages->isNotEmpty()) {
$description .= '<p><strong>Coaching Chat</strong></p>';
$description .= $this->getMessagesAsString($privateMessages);
$description .= '</p>';
}
// Get all public messages
$publicMessages = $messageRepository->getPublicMessages($activity);
if ($publicMessages->isNotEmpty()) {
$description .= '<p><strong>Customer Chat</strong></p>';
$description .= $this->getMessagesAsString($publicMessages);
$description .= '</p>';
}
return $description;
}
private function getMessagesAsString(Collection $messages): string
{
$description = '';
/** @var Activity\Message $message */
foreach ($messages as $message) {
$description .= '<p>' . $message->participant->getName()
. ': ' . $message->getAttribute('message') . '</p>';
}
return $description;
}
private function formatSummary(Activity $activity): string
{
$description = '';
if ($activity->getSummary() !== null) {
$description .= '<p><strong>Summary</strong></p><p>' . nl2br($activity->getSummary()) . '</p><p></p>';
}
return $description;
}
private function formatSmsDescription(Activity $activity): string
{
// Use Rich-text formatting.
$description = '<p><span style="font-size: 16px; line-height: 19.2px;"><strong>' . $activity->getTitle() . '</strong></span></p>';
$description .= '<p><span style="font-size: 16px; line-height: 19.2px;">' . $activity->getDescription() . '</span></p>';
return $description;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45463
|
1627
|
10
|
2026-05-14T14:38:40.959919+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769520959_m1.jpg...
|
PhpStorm
|
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project Files
Preview
Filter
Open in Find Tool Win Project Files
Preview
Filter
Open in Find Tool Window
integrat
IntegrationAppTrait.php .../app/.../Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php
integration-app.php .../config/integration-app.php
IntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.php, final class
IntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php, class
IntegrationAppInterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppInterface.php, interface
IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.php, class
IntegrationClientInterface.php .../app/Services/Activity/BaseService/IntegrationClientInterface.php, interface
IntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessException.php, exception class
IntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.php, class
IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php
IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.php, class
IntegrationClientInterface.php.html build/coverage/Services/Activity/BaseService
… more
IntegrationAppTrait.php .../app/.../Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php
integration-app.php .../config/integration-app.php
IntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.php, final class
IntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php, class
IntegrationAppInterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppInterface.php, interface
IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.php, class
IntegrationClientInterface.php .../app/Services/Activity/BaseService/IntegrationClientInterface.php, interface
IntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessException.php, exception class
IntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.php, class
IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php
IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.php, class
IntegrationClientInterface.php.html build/coverage/Services/Activity/BaseService
… more
Http/Controllers/Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php
Open In Right Split...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project Files","depth":2,"bounds":{"left":0.8298611,"top":0.25,"width":0.07430556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Preview","depth":2,"bounds":{"left":0.90416664,"top":0.25,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Filter","depth":2,"bounds":{"left":0.9222222,"top":0.25,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open in Find Tool Window","depth":2,"bounds":{"left":0.94027776,"top":0.25,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextField","text":"integrat","depth":1,"bounds":{"left":0.50555557,"top":0.29222223,"width":0.45277777,"height":0.032222223},"on_screen":true,"value":"integrat","role_description":"text field","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"IntegrationAppTrait.php .../app/.../Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php","depth":2,"bounds":{"left":0.49930555,"top":0.33666667,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"integration-app.php .../config/integration-app.php","depth":2,"bounds":{"left":0.49930555,"top":0.3611111,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.php, class","depth":2,"bounds":{"left":0.49930555,"top":0.38555557,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.php, class","depth":2,"bounds":{"left":0.49930555,"top":0.41,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.php, class","depth":2,"bounds":{"left":0.49930555,"top":0.43444446,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.php, final class","depth":2,"bounds":{"left":0.49930555,"top":0.4588889,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php, class","depth":2,"bounds":{"left":0.49930555,"top":0.48333332,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppInterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppInterface.php, interface","depth":2,"bounds":{"left":0.49930555,"top":0.50777775,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.php, class","depth":2,"bounds":{"left":0.49930555,"top":0.5322222,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationClientInterface.php .../app/Services/Activity/BaseService/IntegrationClientInterface.php, interface","depth":2,"bounds":{"left":0.49930555,"top":0.5566667,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessException.php, exception class","depth":2,"bounds":{"left":0.49930555,"top":0.58111113,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.php, class","depth":2,"bounds":{"left":0.49930555,"top":0.60555553,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php","depth":2,"bounds":{"left":0.49930555,"top":0.63,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.php, class","depth":2,"bounds":{"left":0.49930555,"top":0.65444446,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationClientInterface.php.html build/coverage/Services/Activity/BaseService","depth":2,"bounds":{"left":0.49930555,"top":0.6788889,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"… more","depth":2,"bounds":{"left":0.49930555,"top":0.7033333,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppTrait.php .../app/.../Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php","depth":4,"bounds":{"left":0.49930555,"top":0.33666667,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"integration-app.php .../config/integration-app.php","depth":4,"bounds":{"left":0.49930555,"top":0.3611111,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.php, class","depth":4,"bounds":{"left":0.49930555,"top":0.38555557,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.php, class","depth":4,"bounds":{"left":0.49930555,"top":0.41,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.php, class","depth":4,"bounds":{"left":0.49930555,"top":0.43444446,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.php, final class","depth":4,"bounds":{"left":0.49930555,"top":0.4588889,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php, class","depth":4,"bounds":{"left":0.49930555,"top":0.48333332,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppInterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppInterface.php, interface","depth":4,"bounds":{"left":0.49930555,"top":0.50777775,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.php, class","depth":4,"bounds":{"left":0.49930555,"top":0.5322222,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationClientInterface.php .../app/Services/Activity/BaseService/IntegrationClientInterface.php, interface","depth":4,"bounds":{"left":0.49930555,"top":0.5566667,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessException.php, exception class","depth":4,"bounds":{"left":0.49930555,"top":0.58111113,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.php, class","depth":4,"bounds":{"left":0.49930555,"top":0.60555553,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php","depth":4,"bounds":{"left":0.49930555,"top":0.63,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.php, class","depth":4,"bounds":{"left":0.49930555,"top":0.65444446,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"IntegrationClientInterface.php.html build/coverage/Services/Activity/BaseService","depth":4,"bounds":{"left":0.49930555,"top":0.6788889,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"… more","depth":4,"bounds":{"left":0.49930555,"top":0.7033333,"width":0.4652778,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Http/Controllers/Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php","depth":1,"bounds":{"left":0.51319444,"top":0.74777776,"width":0.31388888,"height":0.018888889},"on_screen":true,"help_text":"Http/Controllers/Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php","role_description":"text"},{"role":"AXLink","text":"Open In Right Split","depth":1,"bounds":{"left":0.8673611,"top":0.74777776,"width":0.08055556,"height":0.018888889},"on_screen":true,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
5870447939232712614
|
3396885581903289973
|
visual_change
|
accessibility
|
NULL
|
Project Files
Preview
Filter
Open in Find Tool Win Project Files
Preview
Filter
Open in Find Tool Window
integrat
IntegrationAppTrait.php .../app/.../Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php
integration-app.php .../config/integration-app.php
IntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.php, final class
IntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php, class
IntegrationAppInterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppInterface.php, interface
IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.php, class
IntegrationClientInterface.php .../app/Services/Activity/BaseService/IntegrationClientInterface.php, interface
IntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessException.php, exception class
IntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.php, class
IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php
IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.php, class
IntegrationClientInterface.php.html build/coverage/Services/Activity/BaseService
… more
IntegrationAppTrait.php .../app/.../Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php
integration-app.php .../config/integration-app.php
IntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.php, class
IntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.php, final class
IntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php, class
IntegrationAppInterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppInterface.php, interface
IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.php, class
IntegrationClientInterface.php .../app/Services/Activity/BaseService/IntegrationClientInterface.php, interface
IntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessException.php, exception class
IntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.php, class
IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php
IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.php, class
IntegrationClientInterface.php.html build/coverage/Services/Activity/BaseService
… more
Http/Controllers/Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.php
Open In Right Split...
|
45461
|
NULL
|
NULL
|
NULL
|
|
45465
|
1628
|
9
|
2026-05-14T14:38:48.562844+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769528562_m2.jpg...
|
iTerm2
|
NULL
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.45 GB availabold• Inu 14 Mау 1/•30.40Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
-69275824239346483
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.45 GB availabold• Inu 14 Mау 1/•30.40Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
45462
|
NULL
|
NULL
|
NULL
|
|
45464
|
1627
|
11
|
2026-05-14T14:38:48.589487+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769528589_m1.jpg...
|
iTerm2
|
NULL
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest100% C8• Thu 14 May 17:38:48* :QProjectvAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.php:custom.log+ SyncCrmEntitiesTrait.phpPlanhatService.phpAutomatedReportResult.phpT SyncFieldsTrait.php© ImportActivityTypes.phpT WriteCrmTrait.phpSendReportJob.phpDecorateActivity.php xDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.log© Salesforce/Service.phpT LogActivityTrait.phpSF [jiminny@localhost]T WriteCrmTrait.php> D Utils© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:WD WebhookT ActivityPlaybookTrait.php18.••© BatchSyncCollector.php© BatchSyncRedisService.php© DetachActivityObject.phpRematchActivityOnCrt© Client.php© ClosedDealStagesService.php© PlainTextDecorateActivity.php-env© HubspotPaginationService.php© HandleHubspotRateLimit.php5namespace Jiminny (Services\Crm \Hubspot;© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] XAllClassesFilesSymbolsActionsTextProject Files vIntegrG DealFieldsService.php© DecorateActivity.phpuse© FieldDefinitions.php© FieldTypeConverter.php® HubspotClientinterface.php12131466class DecorateActivity extends BaseDecorate© HubspotTokenManager.php5 usages© PayloadBuilder.php© RemoteCrmObjectManipulatoi© ResponseNormalize.php© Service.php© SyncFieldAction.php© SyncRelatedActivityManager.|© WebhookSyncBatchProcessolv D IntegrationApp• AccessorsD ApiD ConfigDDTOD Filters→ Jobs• ProspectSearchStrategy• ServiceTraits© DataClient.php15 C1617 C181920|2122232425262728293045public const string JIMINNY_MARKER = 'public function generateTitle(Activityif (Sactivity->hasTitleO) {$title = $activity->getTitle();} elseif ($activity->hasActivityTyp$title = $activity->getActivity} else {$title = 'Conference Call';IntegrationAppTrait.php .../app/...Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.phpIntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php© IntegrationConfig.php .../app/Services/Activity/TwilioFlex/IntegrationConfig.phpIntegrationAppinterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppinterface.php© IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.ptIntegrationClientinterface.php .../app/Services/Activity/BaseService/IntegrationClientinterface.phpIntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessExceptionIntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.phpT IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php© IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.p<> IntegrationClientinterface.php.html build/coverage/Services/Activity/BaseService... morewnHttp/Controllers/Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.phpOpen In Right Splitreturn Stitle;— 232233 V23411512582;public function convertMeetingOutcome(Activity $activity): ?stringf...}© DecorateActivity.php2 usages© LocalSearch.php46public function convertCallStatus(Activity $activity): string{...}© LocalSearchlnterface.php55DamntaCaornhnhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams18:6UTF-8Co 4 spaces...
|
NULL
|
-8398240544108931728
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhlFV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest100% C8• Thu 14 May 17:38:48* :QProjectvAutomatedReportGenerated.phpTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.php:custom.log+ SyncCrmEntitiesTrait.phpPlanhatService.phpAutomatedReportResult.phpT SyncFieldsTrait.php© ImportActivityTypes.phpT WriteCrmTrait.phpSendReportJob.phpDecorateActivity.php xDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.log© Salesforce/Service.phpT LogActivityTrait.phpSF [jiminny@localhost]T WriteCrmTrait.php> D Utils© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.phpA HS_local [jiminny@localho:WD WebhookT ActivityPlaybookTrait.php18.••© BatchSyncCollector.php© BatchSyncRedisService.php© DetachActivityObject.phpRematchActivityOnCrt© Client.php© ClosedDealStagesService.php© PlainTextDecorateActivity.php-env© HubspotPaginationService.php© HandleHubspotRateLimit.php5namespace Jiminny (Services\Crm \Hubspot;© CrmHelperRepository.phpAccountController.php=.env.staging4 console [QAI PROD] XAllClassesFilesSymbolsActionsTextProject Files vIntegrG DealFieldsService.php© DecorateActivity.phpuse© FieldDefinitions.php© FieldTypeConverter.php® HubspotClientinterface.php12131466class DecorateActivity extends BaseDecorate© HubspotTokenManager.php5 usages© PayloadBuilder.php© RemoteCrmObjectManipulatoi© ResponseNormalize.php© Service.php© SyncFieldAction.php© SyncRelatedActivityManager.|© WebhookSyncBatchProcessolv D IntegrationApp• AccessorsD ApiD ConfigDDTOD Filters→ Jobs• ProspectSearchStrategy• ServiceTraits© DataClient.php15 C1617 C181920|2122232425262728293045public const string JIMINNY_MARKER = 'public function generateTitle(Activityif (Sactivity->hasTitleO) {$title = $activity->getTitle();} elseif ($activity->hasActivityTyp$title = $activity->getActivity} else {$title = 'Conference Call';IntegrationAppTrait.php .../app/...Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.phpIntegrationConfig.php .../app/Services/Activity/AmazonConnect/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/Apollo/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/FiveNine/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/Orum/IntegrationConfig.phpIntegrationConfig.php .../app/Services/Activity/Salesloft/IntegrationConfig.php© IntegrationConfig.php .../app/Services/Activity/TwilioFlex/IntegrationConfig.phpIntegrationAppinterface.php .../app/Contracts/Services/Crm/Provider/IntegrationAppinterface.php© IntegrationAppProviders.php .../app/Services/Crm/IntegrationApp/Config/IntegrationAppProviders.ptIntegrationClientinterface.php .../app/Services/Activity/BaseService/IntegrationClientinterface.phpIntegrationAppAccessException.php .../.../IntegrationApp/Accessors/IntegrationAppAccessExceptionIntegrationAppDefaultStrategy.php .../.../ProspectSearchStrategy/IntegrationAppDefaultStrategy.phpT IntegrationAppServiceTrait.php .../app/.../Crm/IntegrationApp/Jobs/IntegrationAppServiceTrait.php© IntegrationAppCrmGeneratorFactory.php .../app/.../DTO/Utils/IntegrationAppCrmGeneratorFactory.p<> IntegrationClientinterface.php.html build/coverage/Services/Activity/BaseService... morewnHttp/Controllers/Webhook/IntegrationAppSubscriptions/IntegrationAppTrait.phpOpen In Right Splitreturn Stitle;— 232233 V23411512582;public function convertMeetingOutcome(Activity $activity): ?stringf...}© DecorateActivity.php2 usages© LocalSearch.php46public function convertCallStatus(Activity $activity): string{...}© LocalSearchlnterface.php55DamntaCaornhnhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams18:6UTF-8Co 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45466
|
1627
|
12
|
2026-05-14T14:38:51.620433+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769531620_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationAppServiceTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2586234742233688171
|
-7051436856496256053
|
visual_change
|
hybrid
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpabl100% C•FV faVsco.js* #12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest v8• Thu 14 May 17:38:51* :QProjectv+,*.:=TrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.phpPlanhatService.php:+ SyncCrmEntitiesTrait.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.phpT SyncFieldsTrait.php© ImportActivityTypes.php© WriteCrmTrait.php© DecorateActivity.phpIntegrationAppServiceTrait.php x© Salesforce/Service.phpT WriteCrmTrait.php> D UtilsT LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.php© Copper/Service.php> D Webhook© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.php© CrmHelperRepository.php18© BatchSyncCollector.php© BatchSyncRedisService.phpAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php© Client.php© ClosedDealStagesService.php© MatchActivityCrmData.phpk?php© Client.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpA2C DealFieldsService.php© DecorateActivity.phpdeclare(strict_types=1);© FieldDefinitions.php© FieldTypeConverter.phpnamespace Jiminny (Services\Crm\IntegrationApp\Jobs;© HubspotClientinterface.php© HubspotTokenManager.phpUSe© PayloadBuilder.php© RemoteCrmObjectManipulatoi1617 @trait IntegrationAppServiceTrait© ResponseNormalize.php© Service.php1819© SyncFieldAction.php20© SyncRelatedActivityManager.i21© WebhookSyncBatchProcessol/***/no usages* @throws ApplicationExceptionv D IntegrationAppD Accessors• ApiD ConfigDDTO2231323334private function getTeam(TeamRepository $teamRepository): Team{...}D Filters/***/no usages* @throws CrmExceptionD Jobs35private function getPreparedCrmService(Team $team, ProviderRegistry SproviderRegistry): IntegrationAppInter 233 v© CrmEntitiesFullSyncJob.ph53}© DeleteRemoteTeamJob.ph54T IntegrationAppService Trait© SubscribeForEventsJob.ph© TeamInitialSyncJob.php© UnsubscribeForEventsJob.(AlnAotoDrnfiloDalotaNCnti+:Workspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)=custom.log=laravel.logSF [jiminny@localhost]A HS_local [jiminny@localho:W4 console [QAI PROD] X4 console [PROD]A console (EU]DGo jiminny084143 ×4 л215•m_layout_id =2162,1661,66799,66217218219id = 33;220221222223224id THEN •(own225226227228229230hubspot':-231232= 11512582;234W Windsurf Teams1:1UTF-8Ca 4 spaces...
|
45464
|
NULL
|
NULL
|
NULL
|
|
45467
|
1627
|
13
|
2026-05-14T14:38:57.805196+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769537805_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationAppServiceTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8043719072324535154
|
-8628527368849355612
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
PhpStormFileEditViewNavig Project: faVsco.js, menu
PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpabl100% C•FV faVsco.js* #12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest v8• Thu 14 May 17:38:57* :QProject vTrackAutomatedReportGeneratedEvent.php© UserAutomatedReportsController.phpPlanhatService.php:=custom.log© Client.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.phpDeleteAccountJob.php=laravel.log© ClosedDealStagesService.phpC DealFieldsService.php© ImportActivityTypes.phpT WriteCrmTrait.php© DecorateActivity.phpIntegrationAppServiceTrait.php x© Salesforce/Service.phpSF [jiminny@localhost]© DecorateActivity.phpT LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.php© Copper/Service.phpA HS_local [jiminny@localho:W© FieldDefinitions.php© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.php© CrmHelperRepository.php4 console [QAI PROD] X18© FieldTypeConverter.php• HubspotClientinterface.phpAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php4 console [PROD]© HubspotTokenManager.php© PayloadBuilder.php© MatchActivityCrmData.phpk?php© Client.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpA console (EU]A2© RemoteCrmObjectManipulatoiResponseNormalize.phpdeclare(strict_types=1);© Service.php© SyncFieldAction.phpnamespace Jiminny (Services\Crm\IntegrationApp\Jobs;© SyncRelatedActivityManager.i© WebhookSyncBatchProcessolUSev D IntegrationApp> OJ Accessors|› D Api› D ConfigI DTOD Filters1617 @18192021trait IntegrationAppServiceTraitv D Jobs/***/no usages* @throws ApplicationException© CrmEntitiesFullSyncJob.ph22private function getTeam(TeamRepository $teamRepository): Team{...}© DeleteRemoteTeamJob.ph31T IntegrationAppService Trait32© SubscribeForEventsJob.ph33© TeamInitialSyncJob.php34© UnsubscribeForEventsJob./***/no usages* @throws CrmException© UpdateProfileRelatedEntiti35private function getPreparedCrmService(Team $team, ProviderRegistry SproviderRegistry): IntegrationAppInter 233 v© ValidateTeamActiveConne53DGo jiminny084143 ×4 л215•m_layout_id =2162,1661,66799,66217218219id = 33;220221222223224id THEN •(own225226227228229230hubspot':-231232= 11512582;234> C ProspectSearchStrategy54> D ServiceTraits© DataClient.php© DecorateActivity.php© LocalSearch.phpA lnralfaarchintarfara nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams1:1UTF-8Ca 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45468
|
1628
|
10
|
2026-05-14T14:38:57.809098+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769537809_m2.jpg...
|
PhpStorm
|
faVsco.js – IntegrationAppServiceTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-5784594327568142026
|
-7196678489907033719
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 May 1/.30.01Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45469
|
1627
|
14
|
2026-05-14T14:39:02.278989+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769542278_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationAppServiceTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app
.circleci
.cursor
.github
.sonarlint
.vscode
.windsurf
app, sources root
Actions...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.80138886,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","depth":4,"bounds":{"left":0.25,"top":0.3077778,"width":0.66597223,"height":0.6844444},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"bounds":{"left":0.8645833,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.8854167,"top":0.34444445,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"bounds":{"left":0.9048611,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.92569447,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.9458333,"top":0.3422222,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.9611111,"top":0.3422222,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.025,"top":0.06666667,"width":0.050694443,"height":0.034444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.10625,"top":0.07,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.12916666,"top":0.07,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.14722222,"top":0.07,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.16527778,"top":0.07,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.18333334,"top":0.07,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app ~/jiminny/app","depth":6,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".circleci","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".cursor","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".github","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".sonarlint","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".vscode","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".windsurf","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"app, sources root","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Actions","depth":8,"on_screen":false,"role_description":"text"}]...
|
-5036976055473061001
|
6398098426737930845
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app
.circleci
.cursor
.github
.sonarlint
.vscode
.windsurf
app, sources root
Actions...
|
45467
|
NULL
|
NULL
|
NULL
|
|
45470
|
1628
|
11
|
2026-05-14T14:39:02.320521+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769542320_m2.jpg...
|
PhpStorm
|
faVsco.js – IntegrationAppServiceTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app
.circleci
.cursor
.github
.sonarlint
.vscode
.windsurf
app, sources root
Actions
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
AiActivityType
AiAutomation
AiCallScoring
AskAnything
Dtos, folder
Events, folder
AskAnythingPromptService.php
HistoryService.php, class
AskJiminnyAi
AWS
BillingManagement
Cache
CoachingFeedback
Country
CustomerApi
Database
Datadog
Client.php, class
Constants.php, final class
DateTime
DealInsights
DealRisks
ElasticSearch
Eloquent
Encoding
Events, folder
Exceptions, folder
Job, folder
Listeners, folder
Service
CreateM3U8VideoService.php, class
GenerateSpeechFromSilenceService.php, class
ParseSpeechFromSilenceService.php, class
ResetActivityTracksService.php, class
TrackDemuxer.php, class
UploadM3U8MediaToS3Service.php, class
EncodingServiceProvider.php, class
Encryption
ES
Faker
FeatureFlags
FFMpeg
FileSystem
Gecko
Gong
GuzzleHttp
KeyPoints
Kiosk
LanguageDetection
LiveFeed
Locks
Math
MediaPipeline
MeetingBot
MobileSettings
Model
Notification
Nudge
ParagraphBreaker
ParticipantSpeech
PartitionedCookie
PlaybackPage
Playlist
Prophet
ProphetAi
ProsperWorks, folder
Queue, folder
Router, folder
Saml2, folder
SCIM, folder
Seeder, folder
Sentry, folder
Serializer, folder
Settings, folder
Sidekick, folder
Slack, folder
TeamInsights, folder
TimeMemoryMapper, folder
Transcription, folder
TranscriptionSummary, folder...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.28224733,"top":1.0,"width":0.024268618,"height":-0.04788506},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.32114363,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.33211437,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.34075797,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.3494016,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.35804522,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app ~/jiminny/app","depth":6,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".circleci","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".cursor","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".github","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".sonarlint","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".vscode","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".windsurf","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"app, sources root","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Actions","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Component","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Acl","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActionItems","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Activity","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityAnalytics","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivitySearch","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AiActivityType","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AiAutomation","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AiCallScoring","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AskAnything","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Dtos, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Events, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AskAnythingPromptService.php","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"HistoryService.php, class","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AskJiminnyAi","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AWS","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"BillingManagement","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Cache","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CoachingFeedback","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Country","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CustomerApi","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Database","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Datadog","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Client.php, class","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Constants.php, final class","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DateTime","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealInsights","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealRisks","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ElasticSearch","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Eloquent","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Encoding","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Events, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Exceptions, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Job, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Listeners, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Service","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CreateM3U8VideoService.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GenerateSpeechFromSilenceService.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ParseSpeechFromSilenceService.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ResetActivityTracksService.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"TrackDemuxer.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UploadM3U8MediaToS3Service.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"EncodingServiceProvider.php, class","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Encryption","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ES","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Faker","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"FeatureFlags","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"FFMpeg","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"FileSystem","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Gecko","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Gong","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GuzzleHttp","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"KeyPoints","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Kiosk","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LanguageDetection","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LiveFeed","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Locks","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Math","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"MediaPipeline","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"MeetingBot","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"MobileSettings","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Model","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Notification","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Nudge","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ParagraphBreaker","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ParticipantSpeech","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PartitionedCookie","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PlaybackPage","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Playlist","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Prophet","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ProphetAi","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ProsperWorks, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Queue, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Router, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Saml2, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SCIM, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Seeder, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Sentry, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Serializer, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Settings, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Sidekick, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Slack, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"TeamInsights, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"TimeMemoryMapper, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Transcription, folder","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"TranscriptionSummary, folder","depth":9,"on_screen":false,"role_description":"text"}]...
|
5732108575498720068
|
6686328802881245789
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app
.circleci
.cursor
.github
.sonarlint
.vscode
.windsurf
app, sources root
Actions
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
AiActivityType
AiAutomation
AiCallScoring
AskAnything
Dtos, folder
Events, folder
AskAnythingPromptService.php
HistoryService.php, class
AskJiminnyAi
AWS
BillingManagement
Cache
CoachingFeedback
Country
CustomerApi
Database
Datadog
Client.php, class
Constants.php, final class
DateTime
DealInsights
DealRisks
ElasticSearch
Eloquent
Encoding
Events, folder
Exceptions, folder
Job, folder
Listeners, folder
Service
CreateM3U8VideoService.php, class
GenerateSpeechFromSilenceService.php, class
ParseSpeechFromSilenceService.php, class
ResetActivityTracksService.php, class
TrackDemuxer.php, class
UploadM3U8MediaToS3Service.php, class
EncodingServiceProvider.php, class
Encryption
ES
Faker
FeatureFlags
FFMpeg
FileSystem
Gecko
Gong
GuzzleHttp
KeyPoints
Kiosk
LanguageDetection
LiveFeed
Locks
Math
MediaPipeline
MeetingBot
MobileSettings
Model
Notification
Nudge
ParagraphBreaker
ParticipantSpeech
PartitionedCookie
PlaybackPage
Playlist
Prophet
ProphetAi
ProsperWorks, folder
Queue, folder
Router, folder
Saml2, folder
SCIM, folder
Seeder, folder
Sentry, folder
Serializer, folder
Settings, folder
Sidekick, folder
Slack, folder
TeamInsights, folder
TimeMemoryMapper, folder
Transcription, folder
TranscriptionSummary, folder...
|
45468
|
NULL
|
NULL
|
NULL
|
|
45472
|
1628
|
12
|
2026-05-14T14:39:04.081382+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769544081_m2.jpg...
|
PhpStorm
|
faVsco.js – IntegrationAppServiceTrait.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app
.circleci...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.28224733,"top":1.0,"width":0.024268618,"height":-0.04788506},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.32114363,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.33211437,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.34075797,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.3494016,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.35804522,"top":1.0,"width":0.008643617,"height":-0.05027938},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app ~/jiminny/app","depth":6,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".circleci","depth":7}]...
|
4781501936229251464
|
6398098426737865309
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app
.circleci...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45471
|
1627
|
15
|
2026-05-14T14:39:04.081410+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769544081_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationAppServiceTrait.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.80138886,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","depth":4,"bounds":{"left":0.25,"top":0.3077778,"width":0.66597223,"height":0.6844444},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp\\Jobs;\n\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Repositories\\TeamRepository;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Exceptions\\ApplicationException;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Services\\Crm\\ProviderRegistry;\n\ntrait IntegrationAppServiceTrait\n{\n /**\n * @throws ApplicationException\n */\n private function getTeam(TeamRepository $teamRepository): Team\n {\n $team = $teamRepository->find($this->teamId);\n if (! $team instanceof Team) {\n throw new ApplicationException(\"Team not found: {$this->teamId}\");\n }\n\n return $team;\n }\n\n /**\n * @throws CrmException\n */\n private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface\n {\n $configuration = $team->getCrmConfiguration();\n if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {\n // This is unlikely to happen, but better safe than sorry\n throw new CrmException('Trying to bootstrap a non IntegrationApp team');\n }\n\n /** @var IntegrationAppInterface $crmService */\n $crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);\n $owner = $team->getOwner();\n if ($owner === null) {\n throw new RuntimeException('Owner not found');\n }\n $crmService->setUser($owner);\n\n return $crmService;\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
7308277868902124094
|
-2670001233452600439
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp\Jobs;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Team;
use Jiminny\Services\Crm\ProviderRegistry;
trait IntegrationAppServiceTrait
{
/**
* @throws ApplicationException
*/
private function getTeam(TeamRepository $teamRepository): Team
{
$team = $teamRepository->find($this->teamId);
if (! $team instanceof Team) {
throw new ApplicationException("Team not found: {$this->teamId}");
}
return $team;
}
/**
* @throws CrmException
*/
private function getPreparedCrmService(Team $team, ProviderRegistry $providerRegistry): IntegrationAppInterface
{
$configuration = $team->getCrmConfiguration();
if (! Providers::isIntegrationAppProvider($configuration->getProviderName())) {
// This is unlikely to happen, but better safe than sorry
throw new CrmException('Trying to bootstrap a non IntegrationApp team');
}
/** @var IntegrationAppInterface $crmService */
$crmService = $providerRegistry->get(Configuration::PROVIDER_INTEGRATION_APP);
$owner = $team->getOwner();
if ($owner === null) {
throw new RuntimeException('Owner not found');
}
$crmService->setUser($owner);
return $crmService;
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45474
|
1627
|
16
|
2026-05-14T14:39:05.336229+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769545336_m1.jpg...
|
PhpStorm
|
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpFV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vlhlU HandleHubspotRateLimitTest ~100% C8• Thu 14 May 17:39:04* :Q18Project v+.•Х:-© Client.php© ClosedDealStagesService.phpC DealFieldsService.php© DecorateActivity.php© FieldDefinitions.php© FieldTypeConverter.php• HubspotClientinterface.php© HubspotTokenManager.php© PayloadBuilder.php© RemoteCrmObjectManipulatoiResponseNormalize.php© Service.php© SyncFieldAction.php© SyncRelatedActivityManager.|© WebhookSyncBatchProcessolv D IntegrationApp> OJ Accessors|> Api.ConfigI DTO• Filters# JobsD ProspectSearchStrategyServiceTraits© DataClient.php© DecorateActivity.php© LocalSearch.php© LocalSearchinterface.php© RemoteSearch.php© Service.phpv Listeners© ConvertLeadActivities.php© PurgeLookupCache.phpD Metadata• Migrationv M Dinadrivo© TrackAutomatedReportGeneratedEvent.phpUserAutomatedReportsController.phpAutomatedReportResult.php= custom.logSendReportJob.php+ DeleteCrmEntityTrait.phpDeleteAccountJob.phpImportActivityTypes.php© WriteCrmTrait.php=laravel.log© DecorateActivity.phpIntegrationAppServiceTrait.php© IntegrationApp/Service.phpSalesforce/Service.phpSF [jiminny@localhost]T LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpA HS_local [jiminny@localho:W© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.phpCrmHelperRepository.php4 console [QAI PROD] XAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php4 console [PROD]© MatchActivityCrmData.php<?phpClient.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpA console (EU]declare(strict_types=1);namespace Jiminny \Services\Crm\IntegrationApp;754USe5556575859606162636465666768class Service extends BaseService implementsIntegrationAppInterface,SyncCrmEntitiesInterface,SyncCrmMetadataInterface,ImportsBusinessProcessesInterface,RemoteEntityManipulationInterface,LayoutManagementInterface,SettingsInterface,MatchCrmEntitiesInterface,RemoteEntityLookupInterface,RemoteNoteEntityManipulationInterface,SendSummaryToCrmInterface,UrlGeneratorInterface,FetchRelatedActivityInterface69707172use SyncCrmMetadataTrait;use SyncCrmEntitiesTrait;use SystemStateTrait:Workspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DGo jiminny08 4143 ×4 ^215|•m_layout_id =2162,1661,66799,66217218219id = 33;220221222223224id THEN •(own225226227228229230hubspot':-231232233 V= 11512582;234W Windsurf Teams55:7UTF-8Ca 4 spaces...
|
NULL
|
8971716507157371815
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpFV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vlhlU HandleHubspotRateLimitTest ~100% C8• Thu 14 May 17:39:04* :Q18Project v+.•Х:-© Client.php© ClosedDealStagesService.phpC DealFieldsService.php© DecorateActivity.php© FieldDefinitions.php© FieldTypeConverter.php• HubspotClientinterface.php© HubspotTokenManager.php© PayloadBuilder.php© RemoteCrmObjectManipulatoiResponseNormalize.php© Service.php© SyncFieldAction.php© SyncRelatedActivityManager.|© WebhookSyncBatchProcessolv D IntegrationApp> OJ Accessors|> Api.ConfigI DTO• Filters# JobsD ProspectSearchStrategyServiceTraits© DataClient.php© DecorateActivity.php© LocalSearch.php© LocalSearchinterface.php© RemoteSearch.php© Service.phpv Listeners© ConvertLeadActivities.php© PurgeLookupCache.phpD Metadata• Migrationv M Dinadrivo© TrackAutomatedReportGeneratedEvent.phpUserAutomatedReportsController.phpAutomatedReportResult.php= custom.logSendReportJob.php+ DeleteCrmEntityTrait.phpDeleteAccountJob.phpImportActivityTypes.php© WriteCrmTrait.php=laravel.log© DecorateActivity.phpIntegrationAppServiceTrait.php© IntegrationApp/Service.phpSalesforce/Service.phpSF [jiminny@localhost]T LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpA HS_local [jiminny@localho:W© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.phpCrmHelperRepository.php4 console [QAI PROD] XAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php4 console [PROD]© MatchActivityCrmData.php<?phpClient.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpA console (EU]declare(strict_types=1);namespace Jiminny \Services\Crm\IntegrationApp;754USe5556575859606162636465666768class Service extends BaseService implementsIntegrationAppInterface,SyncCrmEntitiesInterface,SyncCrmMetadataInterface,ImportsBusinessProcessesInterface,RemoteEntityManipulationInterface,LayoutManagementInterface,SettingsInterface,MatchCrmEntitiesInterface,RemoteEntityLookupInterface,RemoteNoteEntityManipulationInterface,SendSummaryToCrmInterface,UrlGeneratorInterface,FetchRelatedActivityInterface69707172use SyncCrmMetadataTrait;use SyncCrmEntitiesTrait;use SystemStateTrait:Workspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DGo jiminny08 4143 ×4 ^215|•m_layout_id =2162,1661,66799,66217218219id = 33;220221222223224id THEN •(own225226227228229230hubspot':-231232233 V= 11512582;234W Windsurf Teams55:7UTF-8Ca 4 spaces...
|
45471
|
NULL
|
NULL
|
NULL
|
|
45473
|
1628
|
13
|
2026-05-14T14:39:06.473023+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769546473_m2.jpg...
|
iTerm2
|
NULL
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preview insackt[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 May 1/.39:02Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
-2088217843607816576
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preview insackt[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 May 1/.39:02Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
45472
|
NULL
|
NULL
|
NULL
|
|
45475
|
1627
|
17
|
2026-05-14T14:39:09.902837+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769549902_m1.jpg...
|
PhpStorm
|
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
s
Inherited members (⌘R)
Anonymous Classes (⌘I)
La s
Inherited members (⌘R)
Anonymous Classes (⌘I)
Lambdas (⌘L)
Service, class
CALL_TYPE_INBOUND: string = 'Inbound', public
CALL_TYPE_MISSED: string = 'Missed', public
CALL_TYPE_OUTBOUND: string = 'Outbound', public
RELATIONSHIP_ACCOUNT: string = 'Accounts', public
RELATIONSHIP_LEAD: string = 'Leads', public
RELATIONSHIP_OPPORTUNITY: string = 'Deals', public
invokedUser: User|null = null, protected
__construct(client: DataClient, logger: LoggerInterface) ↑BaseService, public method
attachToProspect(activity: Activity): array|string[], private method
buildBasicPayload(type: string, id: string): string[], private method
fetchAndAssociateRelatedActivity(activity: Activity): Activity|null ↑FetchRelatedActivityInterface, public method
fetchAndAssociateZohoRelatedActivity(activity: Activity): Activity|null, public method
find(name: string, scopes: array): array ↑RemoteEntityLookupInterface, public method
findOpportunities(crmAccountId: null|string, crmContactId: null|string, [userId: int|null = null]): array ↑RemoteEntityLookupInterface, method
generateProviderUrl(providerId: string, objectType: string): null|string ↑GenerateProviderUrlInterface, method
getAccount([crmAccountId: null|string = null], [crmContactId: null|string = null]): Account|null, method
getActivityOwnerId(activity: Activity): null|string, method
getCallType(activity: Activity): string, method
getDisplayName(): string ↑SettingsInterface, method
getFieldMapper(objectType: string): FieldMapperInterface|null, method
getFromToDates(activity: Activity): array, method
getOwnerId([userId: int|null = null]): null|string, method
getRecord(objectType: string, objectId: string, [fields: array = [...]]): array ↑RemoteEntityLookupInterface, method
handleLeadPayload(activity: Activity): array|string[], method
normalizeData(objectType: string, data: array): array, private method
normalizeValue(fieldType: string, fieldValue: string, [internal: bool = false]): string ↑SettingsInterface, public method
saveActivity(activity: Activity): Activity ↑RemoteEntityManipulationInterface, public method
saveCall(activity: Activity): array, public method
saveFollowupActivity(activity: Activity, fields: array): null|string ↑RemoteEntityManipulationInterface, public method
saveMeeting(activity: Activity): array, public method
saveNote(title: string, body: string, objectId: string, [noteObject: NoteObject|null = null]): null|string ↑RemoteNoteEntityManipulationInterface, public method
saveTranscriptionSummaryAsNote(activity: ActivityContract, title: string, body: string, objectId: null|string, [noteObject: NoteObject|null = null]): null|string ↑SendSummaryToCrmInterface, public method
setConfiguration(config: Configuration): void ↑SettingsInterface, public method
setCrmUrlGenerator(config: Configuration): void ↑UrlGeneratorInterface, public method
setEditionConfiguration(provider: string): void, private method
setUser(user: User): void ↑SettingsInterface, public method
subscribeEntityEvents([enableTrigger: bool = true]): void ↑IntegrationAppInterface, public method
supportsNotes(): bool ↑RemoteNoteEntityManipulationInterface, public method
updateRecord(objectType: string, objectId: string, data: array, [headers: array = [...]]): void ↑RemoteEntityManipulationInterface, public method
updateStage(crmObject, stage: Stage): void ↑RemoteEntityManipulationInterface, method
CALL_TYPE_INBOUND: string = 'Inbound', public
CALL_TYPE_MISSED: string = 'Missed', public
CALL_TYPE_OUTBOUND: string = 'Outbound', public
RELATIONSHIP_ACCOUNT: string = 'Accounts', public
RELATIONSHIP_LEAD: string = 'Leads', public
RELATIONSHIP_OPPORTUNITY: string = 'Deals', public
invokedUser: User|null = null, protected
__construct(client: DataClient, logger: LoggerInterface) ↑BaseService, public method
attachToProspect(activity: Activity): array|string[], private method
buildBasicPayload(type: string, id: string): string[], private method
fetchAndAssociateRelatedActivity(activity: Activity): Activity|null ↑FetchRelatedActivityInterface, public method
fetchAndAssociateZohoRelatedActivity(activity: Activity): Activity|null, public method
find(name: string, scopes: array): array ↑RemoteEntityLookupInterface, public method
findOpportunities(crmAccountId: null|string, crmContactId: null|string, [userId: int|null = null]): array ↑RemoteEntityLookupInterface, method
generateProviderUrl(providerId: string, objectType: string): null|string ↑GenerateProviderUrlInterface, method
getAccount([crmAccountId: null|string = null], [crmContactId: null|string = null]): Account|null, method
getActivityOwnerId(activity: Activity): null|string, method
getCallType(activity: Activity): string, method
getDisplayName(): string ↑SettingsInterface, method
getFieldMapper(objectType: string): FieldMapperInterface|null, method
getFromToDates(activity: Activity): array, method
getOwnerId([userId: int|null = null]): null|string, method
getRecord(objectType: string, objectId: string, [fields: array = [...]]): array ↑RemoteEntityLookupInterface, method
handleLeadPayload(activity: Activity): array|string[], method
normalizeData(objectType: string, data: array): array, private method
normalizeValue(fieldType: string, fieldValue: string, [internal: bool = false]): string ↑SettingsInterface, public method
saveActivity(activity: Activity): Activity ↑RemoteEntityManipulationInterface, public method
saveCall(activity: Activity): array, public method
saveFollowupActivity(activity: Activity, fields: array): null|string ↑RemoteEntityManipulationInterface, public method
saveMeeting(activity: Activity): array, public method
saveNote(title: string, body: string, objectId: string, [noteObject: NoteObject|null = null]): null|string ↑RemoteNoteEntityManipulationInterface, public method
saveTranscriptionSummaryAsNote(activity: ActivityContract, title: string, body: string, objectId: null|string, [noteObject: NoteObject|null = null]): null|string ↑SendSummaryToCrmInterface, public method
setConfiguration(config: Configuration): void ↑SettingsInterface, public method
setCrmUrlGenerator(config: Configuration): void ↑UrlGeneratorInterface, public method
setEditionConfiguration(provider: string): void, private method
setUser(user: User): void ↑SettingsInterface, public method
subscribeEntityEvents([enableTrigger: bool = true]): void ↑IntegrationAppInterface, public method
supportsNotes(): bool ↑RemoteNoteEntityManipulationInterface, public method
updateRecord(objectType: string, objectId: string, data: array, [headers: array = [...]]): void ↑RemoteEntityManipulationInterface, public method
updateStage(crmObject, stage: Stage): void ↑RemoteEntityManipulationInterface, method
Service.php...
|
[{"role":"AXTextField","text [{"role":"AXTextField","text":"s","depth":1,"bounds":{"left":0.52152777,"top":0.32,"width":0.06458333,"height":0.031111112},"on_screen":true,"value":"s","role_description":"text field","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Inherited members (⌘R)","depth":1,"bounds":{"left":0.5277778,"top":0.35555556,"width":0.10972222,"height":0.031111112},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Anonymous Classes (⌘I)","depth":1,"bounds":{"left":0.64444447,"top":0.35555556,"width":0.10972222,"height":0.031111112},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Lambdas (⌘L)","depth":1,"bounds":{"left":0.76111114,"top":0.35555556,"width":0.10972222,"height":0.031111112},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Service, class","depth":4,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CALL_TYPE_INBOUND: string = 'Inbound', public","depth":5,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CALL_TYPE_MISSED: string = 'Missed', public","depth":5,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CALL_TYPE_OUTBOUND: string = 'Outbound', public","depth":5,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"RELATIONSHIP_ACCOUNT: string = 'Accounts', public","depth":5,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"RELATIONSHIP_LEAD: string = 'Leads', public","depth":5,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"RELATIONSHIP_OPPORTUNITY: string = 'Deals', public","depth":5,"bounds":{"left":0.55277777,"top":0.0,"width":0.22916667,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"invokedUser: User|null = null, protected","depth":5,"bounds":{"left":0.55277777,"top":0.0,"width":0.15069444,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"__construct(client: DataClient, logger: LoggerInterface) ↑BaseService, public method","depth":5,"bounds":{"left":0.55277777,"top":0.0,"width":0.32708332,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"attachToProspect(activity: Activity): array|string[], private method","depth":5,"bounds":{"left":0.55277777,"top":0.0,"width":0.24027778,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"buildBasicPayload(type: string, id: string): string[], private method","depth":5,"bounds":{"left":0.55277777,"top":0.02111111,"width":0.23888889,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"fetchAndAssociateRelatedActivity(activity: Activity): Activity|null ↑FetchRelatedActivityInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.045555554,"width":0.44236112,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"fetchAndAssociateZohoRelatedActivity(activity: Activity): Activity|null, public method","depth":5,"bounds":{"left":0.55277777,"top":0.07,"width":0.325,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find(name: string, scopes: array): array ↑RemoteEntityLookupInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.094444446,"width":0.33333334,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"findOpportunities(crmAccountId: null|string, crmContactId: null|string, [userId: int|null = null]): array ↑RemoteEntityLookupInterface, method","depth":5,"bounds":{"left":0.55277777,"top":0.11888889,"width":0.44722223,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"generateProviderUrl(providerId: string, objectType: string): null|string ↑GenerateProviderUrlInterface, method","depth":5,"bounds":{"left":0.55277777,"top":0.14333333,"width":0.44722223,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getAccount([crmAccountId: null|string = null], [crmContactId: null|string = null]): Account|null, method","depth":5,"bounds":{"left":0.55277777,"top":0.16777778,"width":0.41319445,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getActivityOwnerId(activity: Activity): null|string, method","depth":5,"bounds":{"left":0.55277777,"top":0.19222222,"width":0.22083333,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getCallType(activity: Activity): string, method","depth":5,"bounds":{"left":0.55277777,"top":0.21666667,"width":0.17222223,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getDisplayName(): string ↑SettingsInterface, method","depth":5,"bounds":{"left":0.55277777,"top":0.24111111,"width":0.20902778,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getFieldMapper(objectType: string): FieldMapperInterface|null, method","depth":5,"bounds":{"left":0.55277777,"top":0.26555556,"width":0.28263888,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getFromToDates(activity: Activity): array, method","depth":5,"bounds":{"left":0.55277777,"top":0.29,"width":0.19027779,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getOwnerId([userId: int|null = null]): null|string, method","depth":5,"bounds":{"left":0.55277777,"top":0.31444445,"width":0.21319444,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"getRecord(objectType: string, objectId: string, [fields: array = [...]]): array ↑RemoteEntityLookupInterface, method","depth":5,"bounds":{"left":0.55277777,"top":0.33888888,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"handleLeadPayload(activity: Activity): array|string[], method","depth":5,"bounds":{"left":0.55277777,"top":0.36333334,"width":0.2361111,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"normalizeData(objectType: string, data: array): array, private method","depth":5,"bounds":{"left":0.55277777,"top":0.38777778,"width":0.25138888,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"normalizeValue(fieldType: string, fieldValue: string, [internal: bool = false]): string ↑SettingsInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.41222224,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveActivity(activity: Activity): Activity ↑RemoteEntityManipulationInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.43666667,"width":0.3548611,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveCall(activity: Activity): array, public method","depth":5,"bounds":{"left":0.55277777,"top":0.4611111,"width":0.16597222,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveFollowupActivity(activity: Activity, fields: array): null|string ↑RemoteEntityManipulationInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.48555556,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveMeeting(activity: Activity): array, public method","depth":5,"bounds":{"left":0.55277777,"top":0.51,"width":0.18472221,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveNote(title: string, body: string, objectId: string, [noteObject: NoteObject|null = null]): null|string ↑RemoteNoteEntityManipulationInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.53444445,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveTranscriptionSummaryAsNote(activity: ActivityContract, title: string, body: string, objectId: null|string, [noteObject: NoteObject|null = null]): null|string ↑SendSummaryToCrmInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.5588889,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setConfiguration(config: Configuration): void ↑SettingsInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.5833333,"width":0.3048611,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setCrmUrlGenerator(config: Configuration): void ↑UrlGeneratorInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.6077778,"width":0.33958334,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setEditionConfiguration(provider: string): void, private method","depth":5,"bounds":{"left":0.55277777,"top":0.63222224,"width":0.22291666,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setUser(user: User): void ↑SettingsInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.6566667,"width":0.22083333,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"subscribeEntityEvents([enableTrigger: bool = true]): void ↑IntegrationAppInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.6811111,"width":0.38541666,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"supportsNotes(): bool ↑RemoteNoteEntityManipulationInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.70555556,"width":0.3048611,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"updateRecord(objectType: string, objectId: string, data: array, [headers: array = [...]]): void ↑RemoteEntityManipulationInterface, public method","depth":5,"bounds":{"left":0.55277777,"top":0.73,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"updateStage(crmObject, stage: Stage): void ↑RemoteEntityManipulationInterface, method","depth":5,"bounds":{"left":0.55277777,"top":0.7544444,"width":0.36805555,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CALL_TYPE_INBOUND: string = 'Inbound', public","depth":4,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CALL_TYPE_MISSED: string = 'Missed', public","depth":4,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CALL_TYPE_OUTBOUND: string = 'Outbound', public","depth":4,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"RELATIONSHIP_ACCOUNT: string = 'Accounts', public","depth":4,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"RELATIONSHIP_LEAD: string = 'Leads', public","depth":4,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"RELATIONSHIP_OPPORTUNITY: string = 'Deals', public","depth":4,"bounds":{"left":0.55277777,"top":0.0,"width":0.22916667,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"invokedUser: User|null = null, protected","depth":4,"bounds":{"left":0.55277777,"top":0.0,"width":0.15069444,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"__construct(client: DataClient, logger: LoggerInterface) ↑BaseService, public method","depth":4,"bounds":{"left":0.55277777,"top":0.0,"width":0.32708332,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"attachToProspect(activity: Activity): array|string[], private method","depth":4,"bounds":{"left":0.55277777,"top":0.0,"width":0.24027778,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"buildBasicPayload(type: string, id: string): string[], private method","depth":4,"bounds":{"left":0.55277777,"top":0.02111111,"width":0.23888889,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"fetchAndAssociateRelatedActivity(activity: Activity): Activity|null ↑FetchRelatedActivityInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.045555554,"width":0.44236112,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"fetchAndAssociateZohoRelatedActivity(activity: Activity): Activity|null, public method","depth":4,"bounds":{"left":0.55277777,"top":0.07,"width":0.325,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find(name: string, scopes: array): array ↑RemoteEntityLookupInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.094444446,"width":0.33333334,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"findOpportunities(crmAccountId: null|string, crmContactId: null|string, [userId: int|null = null]): array ↑RemoteEntityLookupInterface, method","depth":4,"bounds":{"left":0.55277777,"top":0.11888889,"width":0.44722223,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"generateProviderUrl(providerId: string, objectType: string): null|string ↑GenerateProviderUrlInterface, method","depth":4,"bounds":{"left":0.55277777,"top":0.14333333,"width":0.44722223,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getAccount([crmAccountId: null|string = null], [crmContactId: null|string = null]): Account|null, method","depth":4,"bounds":{"left":0.55277777,"top":0.16777778,"width":0.41319445,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getActivityOwnerId(activity: Activity): null|string, method","depth":4,"bounds":{"left":0.55277777,"top":0.19222222,"width":0.22083333,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getCallType(activity: Activity): string, method","depth":4,"bounds":{"left":0.55277777,"top":0.21666667,"width":0.17222223,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getDisplayName(): string ↑SettingsInterface, method","depth":4,"bounds":{"left":0.55277777,"top":0.24111111,"width":0.20902778,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getFieldMapper(objectType: string): FieldMapperInterface|null, method","depth":4,"bounds":{"left":0.55277777,"top":0.26555556,"width":0.28263888,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getFromToDates(activity: Activity): array, method","depth":4,"bounds":{"left":0.55277777,"top":0.29,"width":0.19027779,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"getOwnerId([userId: int|null = null]): null|string, method","depth":4,"bounds":{"left":0.55277777,"top":0.31444445,"width":0.21319444,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"getRecord(objectType: string, objectId: string, [fields: array = [...]]): array ↑RemoteEntityLookupInterface, method","depth":4,"bounds":{"left":0.55277777,"top":0.33888888,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"handleLeadPayload(activity: Activity): array|string[], method","depth":4,"bounds":{"left":0.55277777,"top":0.36333334,"width":0.2361111,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"normalizeData(objectType: string, data: array): array, private method","depth":4,"bounds":{"left":0.55277777,"top":0.38777778,"width":0.25138888,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"normalizeValue(fieldType: string, fieldValue: string, [internal: bool = false]): string ↑SettingsInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.41222224,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveActivity(activity: Activity): Activity ↑RemoteEntityManipulationInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.43666667,"width":0.3548611,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveCall(activity: Activity): array, public method","depth":4,"bounds":{"left":0.55277777,"top":0.4611111,"width":0.16597222,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveFollowupActivity(activity: Activity, fields: array): null|string ↑RemoteEntityManipulationInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.48555556,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveMeeting(activity: Activity): array, public method","depth":4,"bounds":{"left":0.55277777,"top":0.51,"width":0.18472221,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveNote(title: string, body: string, objectId: string, [noteObject: NoteObject|null = null]): null|string ↑RemoteNoteEntityManipulationInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.53444445,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"saveTranscriptionSummaryAsNote(activity: ActivityContract, title: string, body: string, objectId: null|string, [noteObject: NoteObject|null = null]): null|string ↑SendSummaryToCrmInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.5588889,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setConfiguration(config: Configuration): void ↑SettingsInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.5833333,"width":0.3048611,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setCrmUrlGenerator(config: Configuration): void ↑UrlGeneratorInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.6077778,"width":0.33958334,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setEditionConfiguration(provider: string): void, private method","depth":4,"bounds":{"left":0.55277777,"top":0.63222224,"width":0.22291666,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"setUser(user: User): void ↑SettingsInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.6566667,"width":0.22083333,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"subscribeEntityEvents([enableTrigger: bool = true]): void ↑IntegrationAppInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.6811111,"width":0.38541666,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"supportsNotes(): bool ↑RemoteNoteEntityManipulationInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.70555556,"width":0.3048611,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"updateRecord(objectType: string, objectId: string, data: array, [headers: array = [...]]): void ↑RemoteEntityManipulationInterface, public method","depth":4,"bounds":{"left":0.55277777,"top":0.73,"width":0.44722223,"height":0.024444444},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"updateStage(crmObject, stage: Stage): void ↑RemoteEntityManipulationInterface, method","depth":4,"bounds":{"left":0.55277777,"top":0.7544444,"width":0.36805555,"height":0.024444444},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Service.php","depth":1,"bounds":{"left":0.5277778,"top":0.3188889,"width":0.35277778,"height":0.036666665},"on_screen":true,"role_description":"text"}]...
|
-7772749410060340466
|
-2143915371915172665
|
visual_change
|
accessibility
|
NULL
|
s
Inherited members (⌘R)
Anonymous Classes (⌘I)
La s
Inherited members (⌘R)
Anonymous Classes (⌘I)
Lambdas (⌘L)
Service, class
CALL_TYPE_INBOUND: string = 'Inbound', public
CALL_TYPE_MISSED: string = 'Missed', public
CALL_TYPE_OUTBOUND: string = 'Outbound', public
RELATIONSHIP_ACCOUNT: string = 'Accounts', public
RELATIONSHIP_LEAD: string = 'Leads', public
RELATIONSHIP_OPPORTUNITY: string = 'Deals', public
invokedUser: User|null = null, protected
__construct(client: DataClient, logger: LoggerInterface) ↑BaseService, public method
attachToProspect(activity: Activity): array|string[], private method
buildBasicPayload(type: string, id: string): string[], private method
fetchAndAssociateRelatedActivity(activity: Activity): Activity|null ↑FetchRelatedActivityInterface, public method
fetchAndAssociateZohoRelatedActivity(activity: Activity): Activity|null, public method
find(name: string, scopes: array): array ↑RemoteEntityLookupInterface, public method
findOpportunities(crmAccountId: null|string, crmContactId: null|string, [userId: int|null = null]): array ↑RemoteEntityLookupInterface, method
generateProviderUrl(providerId: string, objectType: string): null|string ↑GenerateProviderUrlInterface, method
getAccount([crmAccountId: null|string = null], [crmContactId: null|string = null]): Account|null, method
getActivityOwnerId(activity: Activity): null|string, method
getCallType(activity: Activity): string, method
getDisplayName(): string ↑SettingsInterface, method
getFieldMapper(objectType: string): FieldMapperInterface|null, method
getFromToDates(activity: Activity): array, method
getOwnerId([userId: int|null = null]): null|string, method
getRecord(objectType: string, objectId: string, [fields: array = [...]]): array ↑RemoteEntityLookupInterface, method
handleLeadPayload(activity: Activity): array|string[], method
normalizeData(objectType: string, data: array): array, private method
normalizeValue(fieldType: string, fieldValue: string, [internal: bool = false]): string ↑SettingsInterface, public method
saveActivity(activity: Activity): Activity ↑RemoteEntityManipulationInterface, public method
saveCall(activity: Activity): array, public method
saveFollowupActivity(activity: Activity, fields: array): null|string ↑RemoteEntityManipulationInterface, public method
saveMeeting(activity: Activity): array, public method
saveNote(title: string, body: string, objectId: string, [noteObject: NoteObject|null = null]): null|string ↑RemoteNoteEntityManipulationInterface, public method
saveTranscriptionSummaryAsNote(activity: ActivityContract, title: string, body: string, objectId: null|string, [noteObject: NoteObject|null = null]): null|string ↑SendSummaryToCrmInterface, public method
setConfiguration(config: Configuration): void ↑SettingsInterface, public method
setCrmUrlGenerator(config: Configuration): void ↑UrlGeneratorInterface, public method
setEditionConfiguration(provider: string): void, private method
setUser(user: User): void ↑SettingsInterface, public method
subscribeEntityEvents([enableTrigger: bool = true]): void ↑IntegrationAppInterface, public method
supportsNotes(): bool ↑RemoteNoteEntityManipulationInterface, public method
updateRecord(objectType: string, objectId: string, data: array, [headers: array = [...]]): void ↑RemoteEntityManipulationInterface, public method
updateStage(crmObject, stage: Stage): void ↑RemoteEntityManipulationInterface, method
CALL_TYPE_INBOUND: string = 'Inbound', public
CALL_TYPE_MISSED: string = 'Missed', public
CALL_TYPE_OUTBOUND: string = 'Outbound', public
RELATIONSHIP_ACCOUNT: string = 'Accounts', public
RELATIONSHIP_LEAD: string = 'Leads', public
RELATIONSHIP_OPPORTUNITY: string = 'Deals', public
invokedUser: User|null = null, protected
__construct(client: DataClient, logger: LoggerInterface) ↑BaseService, public method
attachToProspect(activity: Activity): array|string[], private method
buildBasicPayload(type: string, id: string): string[], private method
fetchAndAssociateRelatedActivity(activity: Activity): Activity|null ↑FetchRelatedActivityInterface, public method
fetchAndAssociateZohoRelatedActivity(activity: Activity): Activity|null, public method
find(name: string, scopes: array): array ↑RemoteEntityLookupInterface, public method
findOpportunities(crmAccountId: null|string, crmContactId: null|string, [userId: int|null = null]): array ↑RemoteEntityLookupInterface, method
generateProviderUrl(providerId: string, objectType: string): null|string ↑GenerateProviderUrlInterface, method
getAccount([crmAccountId: null|string = null], [crmContactId: null|string = null]): Account|null, method
getActivityOwnerId(activity: Activity): null|string, method
getCallType(activity: Activity): string, method
getDisplayName(): string ↑SettingsInterface, method
getFieldMapper(objectType: string): FieldMapperInterface|null, method
getFromToDates(activity: Activity): array, method
getOwnerId([userId: int|null = null]): null|string, method
getRecord(objectType: string, objectId: string, [fields: array = [...]]): array ↑RemoteEntityLookupInterface, method
handleLeadPayload(activity: Activity): array|string[], method
normalizeData(objectType: string, data: array): array, private method
normalizeValue(fieldType: string, fieldValue: string, [internal: bool = false]): string ↑SettingsInterface, public method
saveActivity(activity: Activity): Activity ↑RemoteEntityManipulationInterface, public method
saveCall(activity: Activity): array, public method
saveFollowupActivity(activity: Activity, fields: array): null|string ↑RemoteEntityManipulationInterface, public method
saveMeeting(activity: Activity): array, public method
saveNote(title: string, body: string, objectId: string, [noteObject: NoteObject|null = null]): null|string ↑RemoteNoteEntityManipulationInterface, public method
saveTranscriptionSummaryAsNote(activity: ActivityContract, title: string, body: string, objectId: null|string, [noteObject: NoteObject|null = null]): null|string ↑SendSummaryToCrmInterface, public method
setConfiguration(config: Configuration): void ↑SettingsInterface, public method
setCrmUrlGenerator(config: Configuration): void ↑UrlGeneratorInterface, public method
setEditionConfiguration(provider: string): void, private method
setUser(user: User): void ↑SettingsInterface, public method
subscribeEntityEvents([enableTrigger: bool = true]): void ↑IntegrationAppInterface, public method
supportsNotes(): bool ↑RemoteNoteEntityManipulationInterface, public method
updateRecord(objectType: string, objectId: string, data: array, [headers: array = [...]]): void ↑RemoteEntityManipulationInterface, public method
updateStage(crmObject, stage: Stage): void ↑RemoteEntityManipulationInterface, method
Service.php...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45476
|
1627
|
18
|
2026-05-14T14:39:15.928471+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769555928_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationApp/Service.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelp•FV faVsco.js* #12066 on JY-20725-handle-HS-search-rate-limit k vlhlU HandleHubspotRateLimitTest ~100% C8• Thu 14 May 17:39:15* :QProjectvTrackAutomatedReportGeneratedEvent.phpUserAutomatedReportsController.phpAutomatedReportResult.php:=custom.log© Client.phpSendReportJob.php+ DeleteCrmEntityTrait.phpDeleteAccountJob.phpImportActivityTypes.php© WriteCrmTrait.php=laravel.log© ClosedDealStagesService.phpC DealFieldsService.php© DecorateActivity.phpIntegrationAppServiceTrait.php© IntegrationApp/Service.phpSalesforce/Service.phpSF [jiminny@localhost]© DecorateActivity.phpT LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpA HS_local [jiminny@localho:W© FieldDefinitions.php© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.phpCrmHelperRepository.php4 console [QAI PROD] X18© FieldTypeConverter.php• HubspotClientinterface.phpAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php4 console [PROD]© HubspotTokenManager.php© PayloadBuilder.php© RemoteCrmObjectManipulatoi354© MatchActivityCrmData.php© Client.php© HubspotPaginationService.phpclass Service extendsBaseService implements): ?string {...}HandleHubspotRateLimit.phpA console (EU]55ResponseNormalize.php© Service.php378379© SyncFieldAction.php380© SyncRelatedActivityManager.|© WebhookSyncBatchProcessol381382 €v D IntegrationApp383/***/1* @throws CrmException#[\Override] public function saveActivity(Activity $activity): Activityid = 33;> OJ Accessors|> Api.384385ConfigI DTO386$this->logger-›info('[integration-app] saveActivity', ['activity' => $activity->getUvidO,'type' => $activity->getType(),3871):id THEN •(ownFilters388# Jobs389D ProspectSearchStrategy• ServiceTraits390391© DataClient.php© DecorateActivity.php392393© LocalSearch.php© LocalSearchinterface.php394395© RemoteSearch.php© Service.php396397v Listeners© ConvertLeadActivities.php398399DGo jiminny084143 ×4 ^215|•m_layout_id =2162,1661,66799,66217218219220221-222223224— 225if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {226$crmActivity = $this->saveMeeting($activity);.2277 elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUNDI228$crmActivity = $this->saveCall($activity);229} else 1230231232233 V-234=hubspot':throw new CrmException( message:'Unsupported activity type');= 11512582;$crmActivityId = $crmActivity['id'] ?? null;© PurgeLookupCache.php4000 Metadata401if ($crmActivityId |== null) 1$activity->crm_provider_id = $crmActivityId;Sactivity->saveO);• Migration402v M DinadrivoWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams382:34UTF-8Ca 4 spaces...
|
NULL
|
-2982010892637641302
|
NULL
|
visual_change
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelp•FV faVsco.js* #12066 on JY-20725-handle-HS-search-rate-limit k vlhlU HandleHubspotRateLimitTest ~100% C8• Thu 14 May 17:39:15* :QProjectvTrackAutomatedReportGeneratedEvent.phpUserAutomatedReportsController.phpAutomatedReportResult.php:=custom.log© Client.phpSendReportJob.php+ DeleteCrmEntityTrait.phpDeleteAccountJob.phpImportActivityTypes.php© WriteCrmTrait.php=laravel.log© ClosedDealStagesService.phpC DealFieldsService.php© DecorateActivity.phpIntegrationAppServiceTrait.php© IntegrationApp/Service.phpSalesforce/Service.phpSF [jiminny@localhost]© DecorateActivity.phpT LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpA HS_local [jiminny@localho:W© FieldDefinitions.php© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.phpCrmHelperRepository.php4 console [QAI PROD] X18© FieldTypeConverter.php• HubspotClientinterface.phpAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php4 console [PROD]© HubspotTokenManager.php© PayloadBuilder.php© RemoteCrmObjectManipulatoi354© MatchActivityCrmData.php© Client.php© HubspotPaginationService.phpclass Service extendsBaseService implements): ?string {...}HandleHubspotRateLimit.phpA console (EU]55ResponseNormalize.php© Service.php378379© SyncFieldAction.php380© SyncRelatedActivityManager.|© WebhookSyncBatchProcessol381382 €v D IntegrationApp383/***/1* @throws CrmException#[\Override] public function saveActivity(Activity $activity): Activityid = 33;> OJ Accessors|> Api.384385ConfigI DTO386$this->logger-›info('[integration-app] saveActivity', ['activity' => $activity->getUvidO,'type' => $activity->getType(),3871):id THEN •(ownFilters388# Jobs389D ProspectSearchStrategy• ServiceTraits390391© DataClient.php© DecorateActivity.php392393© LocalSearch.php© LocalSearchinterface.php394395© RemoteSearch.php© Service.php396397v Listeners© ConvertLeadActivities.php398399DGo jiminny084143 ×4 ^215|•m_layout_id =2162,1661,66799,66217218219220221-222223224— 225if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {226$crmActivity = $this->saveMeeting($activity);.2277 elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUNDI228$crmActivity = $this->saveCall($activity);229} else 1230231232233 V-234=hubspot':throw new CrmException( message:'Unsupported activity type');= 11512582;$crmActivityId = $crmActivity['id'] ?? null;© PurgeLookupCache.php4000 Metadata401if ($crmActivityId |== null) 1$activity->crm_provider_id = $crmActivityId;Sactivity->saveO);• Migration402v M DinadrivoWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams382:34UTF-8Ca 4 spaces...
|
45475
|
NULL
|
NULL
|
NULL
|
|
45477
|
1628
|
14
|
2026-05-14T14:39:16.275662+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769556275_m2.jpg...
|
PhpStorm
|
faVsco.js – IntegrationApp/Service.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 May 1/.39.10Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
6609475927492902859
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.3Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:35resterday at 15.34Yesterdav at 13:34Yesterday at 13:33Yesterday at 13.32Yesterdav at 13:39resterday at 15.3Yesterdav at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29Yesterday at 13:28resterday at 13-21Yesterdav at 13:27Yesterday at 13:26Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:22Yesterdav at 13:22resterady al 15.clYesterday at 13:20Yesterday at 13.19Yecterdav at 12:10Yesterdav at 13:18Yesterday at 13.10Yesterdav at 13:17Yesterday at 13:17Yesterday at 13:16Yacterdav at 12:15Yesterday at 13.14Yecterdav at 12:14Yesterday at 13:13Yesterday at 13:12Yoctorday at 12:19Yesterday at 13.11Yecterdav at 12:10Yesterdav at 13:10Yesterdav at 13:0962 K:MPEG-4 movie71 KB23 KBMPEG-4 movieMPEG-4 movieMPEG-4 movie13 KE16 KB17 KB29 K:MPE0"4 movie6 KB12 KBMDSG-A movieMP2G-4 movie7 KBI8 KB37 KB10 KВIMPEG-A movieMPEG"4 movieMPEG-4 movie7 KBMPEG-4 movie8 KB9 KB1MPEG-4 movie8 KR72 KB14 KBMPEG-1 movieMPEG-4 movie13 KEMPEG-4 movie9 KB MPEG-4 movie18 KB12 KB|MPEG-4 movie10 KB16 KB6KBMDEG.A movicMPEG-4 movie6KE12 KBMPEG-4 movieMPEG-4 movie23 KBMPEG-4 movie8 K:MPEG-4 movie6 KBMDECA movid11 KBMPEG-4 movie11 KPMDEG-A movie20 KB34 KB10 K:7 KB5 KB11 KBMPEG-4 movieMDEC.A moviaMPEG-4 movieD6KRMDEG-A movia111 KBMPEG-4 movie102 KEMPEG-4 movie88 KBMPEG-A movie59 KB MPEG-4 movie98 KB97 KBMPEG-4 movieMDEG.A movioGAKP44 KB93 KBMPEG-4 movie78 KPMDEG-A movid50 KBMPEG-4 movie58 KB17 KBMPEG-4 movieAl Notes: OffLeave• • CFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 May 1/.39.10Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45478
|
1627
|
19
|
2026-05-14T14:39:19.492715+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769559492_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationApp/Service.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelp•FV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vlhlU HandleHubspotRateLimitTest ~100% C8• Thu 14 May 17:39:19* :QProjectvTrackAutomatedReportGeneratedEvent.phpUserAutomatedReportsController.phpAutomatedReportResult.php:=custom.log© Client.phpSendReportJob.php+ DeleteCrmEntityTrait.phpDeleteAccountJob.phpImportActivityTypes.php© WriteCrmTrait.php=laravel.log© ClosedDealStagesService.phpC DealFieldsService.php© DecorateActivity.phpIntegrationAppServiceTrait.phpIntegrationApp/Service.phpSalesforce/Service.phpSF [jiminny@localhost]© DecorateActivity.phpT LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpA HS_local [jiminny@localho:W© FieldDefinitions.php© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.phpCrmHelperRepository.php4 console [QAI PROD] X18© FieldTypeConverter.php• HubspotClientinterface.phpAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php4 console [PROD]© HubspotTokenManager.php© PayloadBuilder.php© RemoteCrmObjectManipulatoi354© MatchActivityCrmData.php© Client.php© HubspotPaginationService.phpclass Service extendsBaseService implements): ?string {...}HandleHubspotRateLimit.phpA console (EU]55B16 × 2ResponseNormalize.php© Service.php378379© SyncFieldAction.php380© SyncRelatedActivityManager.|© WebhookSyncBatchProcessol381382 €v D IntegrationApp383/***/1* @throws CrmException#[\Override] public function saveActivity(Activity $activity): Activityid = 33;> OJ Accessors|> Api.384385ConfigI DTO386$this->logger-›info('[integration-app] saveActivity', ['activity' => $activity->getUvidO,'type' => $activity->getType(),3871):id THEN •(ownFilters388# JobsD ProspectSearchStrategy389• ServiceTraits390391© DataClient.php© DecorateActivity.php392393© LocalSearch.php© LocalSearchinterface.php394395© RemoteSearch.php© Service.php396397v Listeners© ConvertLeadActivities.php398399DGo jiminny084143 ×4 ^215|•m_layout_id =2162,1661,66799,66217218219220221-222223224— 225if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {226$crmActivity = $this->saveMeeting($activity);.2277 elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUNDI228$crmActivity = $this->saveCall($activity);229} else 1230231232233V-234=hubspot':-throw new CrmException( message:'Unsupported activity type');= 11512582;$crmActivityId = $crmActivity['id'] ?? null;© PurgeLookupCache.php4000 Metadata401if ($crmActivityId |== null) 1$activity->crm_provider_id = $crmActivityId;Sactivity->saveO);• Migration=402v M DinadrivoWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams389:61UTF-8Ca 4 spaces...
|
NULL
|
-903379183547159902
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelp•FV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vlhlU HandleHubspotRateLimitTest ~100% C8• Thu 14 May 17:39:19* :QProjectvTrackAutomatedReportGeneratedEvent.phpUserAutomatedReportsController.phpAutomatedReportResult.php:=custom.log© Client.phpSendReportJob.php+ DeleteCrmEntityTrait.phpDeleteAccountJob.phpImportActivityTypes.php© WriteCrmTrait.php=laravel.log© ClosedDealStagesService.phpC DealFieldsService.php© DecorateActivity.phpIntegrationAppServiceTrait.phpIntegrationApp/Service.phpSalesforce/Service.phpSF [jiminny@localhost]© DecorateActivity.phpT LogActivityTrait.php© Playbook.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpA HS_local [jiminny@localho:W© FieldDefinitions.php© BullhornService.php© PlainTextDecorateActivity.phpT ActivityPlaybookTrait.phpCrmHelperRepository.php4 console [QAI PROD] X18© FieldTypeConverter.php• HubspotClientinterface.phpAccountController.php.env.stagingE.envDetachActivityObject.phpRematchActivityOnCrmObjectDetach.php4 console [PROD]© HubspotTokenManager.php© PayloadBuilder.php© RemoteCrmObjectManipulatoi354© MatchActivityCrmData.php© Client.php© HubspotPaginationService.phpclass Service extendsBaseService implements): ?string {...}HandleHubspotRateLimit.phpA console (EU]55B16 × 2ResponseNormalize.php© Service.php378379© SyncFieldAction.php380© SyncRelatedActivityManager.|© WebhookSyncBatchProcessol381382 €v D IntegrationApp383/***/1* @throws CrmException#[\Override] public function saveActivity(Activity $activity): Activityid = 33;> OJ Accessors|> Api.384385ConfigI DTO386$this->logger-›info('[integration-app] saveActivity', ['activity' => $activity->getUvidO,'type' => $activity->getType(),3871):id THEN •(ownFilters388# JobsD ProspectSearchStrategy389• ServiceTraits390391© DataClient.php© DecorateActivity.php392393© LocalSearch.php© LocalSearchinterface.php394395© RemoteSearch.php© Service.php396397v Listeners© ConvertLeadActivities.php398399DGo jiminny084143 ×4 ^215|•m_layout_id =2162,1661,66799,66217218219220221-222223224— 225if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {226$crmActivity = $this->saveMeeting($activity);.2277 elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUNDI228$crmActivity = $this->saveCall($activity);229} else 1230231232233V-234=hubspot':-throw new CrmException( message:'Unsupported activity type');= 11512582;$crmActivityId = $crmActivity['id'] ?? null;© PurgeLookupCache.php4000 Metadata401if ($crmActivityId |== null) 1$activity->crm_provider_id = $crmActivityId;Sactivity->saveO);• Migration=402v M DinadrivoWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams389:61UTF-8Ca 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45479
|
1628
|
15
|
2026-05-14T14:39:22.381322+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769562381_m2.jpg...
|
PhpStorm
|
faVsco.js – Activity.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.38Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:36resteraay at 15.3oYesterdav at 13:34Yesterday at 13:34Yesterday at 13.33Yesterdav at 13:32resterday at 15.3Yesterdav at 13:31Yesterday at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29resterday at 13.2oYesterdav at 13:27Yesterday at 13:27Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:24Yesterdav at 13:23Yesterday at 13:22Yesterday at 13.20Yecterdav at 12:10Yesterdav at 13:19Yesterday at 13.10Yesterdav at 13:18Yesterday at 13:17Yesterday at 13:16Yacterdav at 12116Yesterdav at 13:15Yesterday at 13.1Yecterdav at 12:14Yesterday at 13:14Yesterday at 13:13Yoctorday at 12:19Yesterdav at 13:12Yesterday at 13.11Yesterdav at 13:10Yesterdav at 13:09v Size88 K:MPEG-4 movie62 KB71 KB23 Kb9 KE13 KB16 KB17 K:MPEG-4 movieMPEG-4 movieMPEG-4 movieMPE0"4 movie29 KB MPEG-4 movie6 KB12KBMP2G-4 movie9 KBI7 KBOKbMPEG-A movieMPEG"4 movie37 KE10 KBMoeeh movio7 KB8 K:MPEG-4 movieO KRI8 KB72 KBMPEG-1 movieMPEG-4 movie14 KEMPEG-4 movie13 KB9 KBMPEG-4 movie18 KB|MPEG-4 movie12 KPMDEG.A movic16 KBMPEG-4 movie6KE6 KBMPEG-4 movieMPEG-4 movie12 KBMPEG-4 movie23 K:MPEG-4 movieMDEC A movid6KBMPEG-4 movie11 KPMDEG-A movie11 KBMPEG-4 movie20 KB34 KB10 KB7 KB5 KBMPEG-4 movieMDEC.A movialMPEG-4 movie11 KPMDEG-A movia26 KB MPEG-4 movie111 KBMPEG-4 movie102 KВMPSG-A movie88 KB MPEG-4 movie59 KB98 KB07 KpMPEG-4 movieMDEG.A movio66 KB44 KBMPEG-4 movie03 KрMDEG-A movid78 KBMPEG-4 movie50 KB58 K8MPEG-4 movieAl Notes: OffLeaveFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfP Kdf-a,k Ffmiv Tree.sebitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenort 2.csviconfig.vmlIteration run Search HS.postman_collection.json--report(1).csvm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.45 GB availabold• Inu 14 May 1/.39.2Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
-2766738438070022614
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIđ 0Pmv Q SearchDate ModifiedYesterdav at 13.38Yesterday at 13:37Yesterday at 13.30Yesterdav at 13:36resteraay at 15.3oYesterdav at 13:34Yesterday at 13:34Yesterday at 13.33Yesterdav at 13:32resterday at 15.3Yesterdav at 13:31Yesterday at 13:30Yesterday at 13:30Yesterday at 13:29Yesterday at 13:29resterday at 13.2oYesterdav at 13:27Yesterday at 13:27Yesterday at 13:26Yesterday at 13:25Yesterday at 13.24Yesterdav at 13:24Yesterdav at 13:23Yesterday at 13:22Yesterday at 13.20Yecterdav at 12:10Yesterdav at 13:19Yesterday at 13.10Yesterdav at 13:18Yesterday at 13:17Yesterday at 13:16Yacterdav at 12116Yesterdav at 13:15Yesterday at 13.1Yecterdav at 12:14Yesterday at 13:14Yesterday at 13:13Yoctorday at 12:19Yesterdav at 13:12Yesterday at 13.11Yesterdav at 13:10Yesterdav at 13:09v Size88 K:MPEG-4 movie62 KB71 KB23 Kb9 KE13 KB16 KB17 K:MPEG-4 movieMPEG-4 movieMPEG-4 movieMPE0"4 movie29 KB MPEG-4 movie6 KB12KBMP2G-4 movie9 KBI7 KBOKbMPEG-A movieMPEG"4 movie37 KE10 KBMoeeh movio7 KB8 K:MPEG-4 movieO KRI8 KB72 KBMPEG-1 movieMPEG-4 movie14 KEMPEG-4 movie13 KB9 KBMPEG-4 movie18 KB|MPEG-4 movie12 KPMDEG.A movic16 KBMPEG-4 movie6KE6 KBMPEG-4 movieMPEG-4 movie12 KBMPEG-4 movie23 K:MPEG-4 movieMDEC A movid6KBMPEG-4 movie11 KPMDEG-A movie11 KBMPEG-4 movie20 KB34 KB10 KB7 KB5 KBMPEG-4 movieMDEC.A movialMPEG-4 movie11 KPMDEG-A movia26 KB MPEG-4 movie111 KBMPEG-4 movie102 KВMPSG-A movie88 KB MPEG-4 movie59 KB98 KB07 KpMPEG-4 movieMDEG.A movio66 KB44 KBMPEG-4 movie03 KрMDEG-A movid78 KBMPEG-4 movie50 KB58 K8MPEG-4 movieAl Notes: OffLeaveFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc toldeLocations0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip• Transcript.pd→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zip• repon 4).XmAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfP Kdf-a,k Ffmiv Tree.sebitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenort 2.csviconfig.vmlIteration run Search HS.postman_collection.json--report(1).csvm licence bettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentK:PDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archiveMarkdo…..ument5KRWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.45 GB availabold• Inu 14 May 1/.39.2Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
45477
|
NULL
|
NULL
|
NULL
|
|
45481
|
1627
|
20
|
2026-05-14T14:39:25.314506+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769565314_m1.jpg...
|
PhpStorm
|
faVsco.js – Activity.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhl•FV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest v100% (C478• Thu 14 May 17:39:25QProject vTrackAutomatedReportGeneratedEvent.phpAutomatedReportResult.phpSendReportJob.php> C WebhookDeleteAccountJob.phpImportActivitylypes.php0 WriteCrmTrait.phpDecorateActivity.php© Account.php© IntegrationApp/Service.phpActivity.php XSalesforce/Service.phpT LogActivityTrait.php© Activity.php© Address.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpBullhornService.php© AiPrompt.php© ActivityPlaybookTrait.phpCrmHelperRepository.php© AccountController.php=.env.staging18© AutomatedReport.php© AutomatedReportResult.php© DetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.php© Calendar.php© CallImport.php303© CoachingFeedback.php© CoachingFeedbackVisibility.php© CoachingSection.php© CoachingSectionCriterion.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpclass Activity extends Model implements2 usagespublic const array SOFT_PHONE_CONFERENCE_STATUSES = [Activity::STATUS_IN_PROGRESS,Activity::STATUS_COMPLETED,© CoachingSectionCriterionFeedback.© CoachingSectionFeedback.php© CommentAbstract.php© Commentinterface.php© Contact.php© Device.php© EmailMessage.php© GenericAiPrompt.php© Group.php© Inbox.php© InboxEmail.php© InboxEmailBatch.php© Invitation.php© JobLog.php© JobTitle.php© Language.php© LanguageDialect.php© Lead.php© MobileSetting.php© Model.php© Moment.php© Nudge.php ];// @todo refactor prefix from 'TYPE_' to "CHANNEL_'public const string TYPE_SOFTPHONE = 'softphone' ;public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound' ;public const string |TYPE_CONFERENCE = 'conference' ;public const string TYPE_SMS_INBOUND = 'sms-inbound';public const string TYPE_SMS_OUTBOUND = 'sms-outbound' ;public const string TYPE_EMAIL_INBOUND = 'email-inbound' ;public const string TYPE_EMAIL_OUTBOUND = 'email-outbound' ;public const array CHANNELS = [self::TYPE_SOFTPHONE,self::TYPE_SOFTPHONE_INBOUND,self::TYPE_CONFERENCE,self::TYPE_SMS_INBOUND,self:: TYPE_SMS_OUTBOUND,self::TYPE_EMAIL_INBOUND,self::TYPE_EMAIL_OUTBOUND,public const array PLAYABLE_CHANNELS = [A MudnaDun nhnaatreiarNAPTAWALInWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DeleteCrmEntityTrait.php= custom.logIntegrationAppServiceTrait.php= laravel.log© Playbook.phpSF [jiminny@localhost]PlainTextDecorateActivity.phpA HS_local [jiminny@localho:=.env4 console [QAI PROD] XClient.php4 console [PROD]B4 A 169M4 м 102 84 ^A console (EU]DGo jiminny4143 ×4 л215•m_layout_id =2162,1661,66799,66217=218-219id = 33;220E221222223224id THEN •(own225226227228229230hubspot':231232233V11512582;234W Windsurf Teams500:25UTF-8Ca 4 spaces...
|
NULL
|
-6812628292453191200
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhl•FV faVsco.jsv#12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest v100% (C478• Thu 14 May 17:39:25QProject vTrackAutomatedReportGeneratedEvent.phpAutomatedReportResult.phpSendReportJob.php> C WebhookDeleteAccountJob.phpImportActivitylypes.php0 WriteCrmTrait.phpDecorateActivity.php© Account.php© IntegrationApp/Service.phpActivity.php XSalesforce/Service.phpT LogActivityTrait.php© Activity.php© Address.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpBullhornService.php© AiPrompt.php© ActivityPlaybookTrait.phpCrmHelperRepository.php© AccountController.php=.env.staging18© AutomatedReport.php© AutomatedReportResult.php© DetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.php© Calendar.php© CallImport.php303© CoachingFeedback.php© CoachingFeedbackVisibility.php© CoachingSection.php© CoachingSectionCriterion.php© HubspotPaginationService.php© HandleHubspotRateLimit.phpclass Activity extends Model implements2 usagespublic const array SOFT_PHONE_CONFERENCE_STATUSES = [Activity::STATUS_IN_PROGRESS,Activity::STATUS_COMPLETED,© CoachingSectionCriterionFeedback.© CoachingSectionFeedback.php© CommentAbstract.php© Commentinterface.php© Contact.php© Device.php© EmailMessage.php© GenericAiPrompt.php© Group.php© Inbox.php© InboxEmail.php© InboxEmailBatch.php© Invitation.php© JobLog.php© JobTitle.php© Language.php© LanguageDialect.php© Lead.php© MobileSetting.php© Model.php© Moment.php© Nudge.php ];// @todo refactor prefix from 'TYPE_' to "CHANNEL_'public const string TYPE_SOFTPHONE = 'softphone' ;public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound' ;public const string |TYPE_CONFERENCE = 'conference' ;public const string TYPE_SMS_INBOUND = 'sms-inbound';public const string TYPE_SMS_OUTBOUND = 'sms-outbound' ;public const string TYPE_EMAIL_INBOUND = 'email-inbound' ;public const string TYPE_EMAIL_OUTBOUND = 'email-outbound' ;public const array CHANNELS = [self::TYPE_SOFTPHONE,self::TYPE_SOFTPHONE_INBOUND,self::TYPE_CONFERENCE,self::TYPE_SMS_INBOUND,self:: TYPE_SMS_OUTBOUND,self::TYPE_EMAIL_INBOUND,self::TYPE_EMAIL_OUTBOUND,public const array PLAYABLE_CHANNELS = [A MudnaDun nhnaatreiarNAPTAWALInWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DeleteCrmEntityTrait.php= custom.logIntegrationAppServiceTrait.php= laravel.log© Playbook.phpSF [jiminny@localhost]PlainTextDecorateActivity.phpA HS_local [jiminny@localho:=.env4 console [QAI PROD] XClient.php4 console [PROD]B4 A 169M4 м 102 84 ^A console (EU]DGo jiminny4143 ×4 л215•m_layout_id =2162,1661,66799,66217=218-219id = 33;220E221222223224id THEN •(own225226227228229230hubspot':231232233V11512582;234W Windsurf Teams500:25UTF-8Ca 4 spaces...
|
45478
|
NULL
|
NULL
|
NULL
|
|
45480
|
1628
|
16
|
2026-05-14T14:39:29.021576+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769569021_m2.jpg...
|
PhpStorm
|
faVsco.js – Activity.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
169
4
102
4
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Models;
use Carbon\Carbon;
use Database\Factories\ActivityFactory;
use DateTimeInterface;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use InvalidArgumentException;
use Jiminny\Component\ElasticSearch;
use Jiminny\Component\MeetingBot;
use Jiminny\Component\Model\BitwiseFlagTrait;
use Jiminny\Component\PlaybackPage\Comments\Services\ActivityCommentService;
use Jiminny\Component\Sidekick\SidekickService;
use Jiminny\Component\Uuid\UuidAwareInterface;
use Jiminny\Component\Workflow;
use Jiminny\Contracts;
use Jiminny\Contracts\Crm\ProspectInterface;
use Jiminny\DTO\ImportCall\Call;
use Jiminny\Events\Activities\ActivityTypeUpdated;
use Jiminny\Events\Activities\ActivityUpdated;
use Jiminny\Events\Activities\ProspectUpdated;
use Jiminny\Events\Activities\StageUpdated;
use Jiminny\Events\Activities\StatusUpdated;
use Jiminny\Events\Activities\TitleUpdated;
use Jiminny\Exceptions\InvalidArgumentException as InvalidArgumentJiminnyException;
use Jiminny\Exceptions\LogicException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models;
use Jiminny\Models\Activity\ActivitySummaryLog;
use Jiminny\Models\Activity\ActivityUploadSetting;
use Jiminny\Models\Activity\AvailabilityNotification;
use Jiminny\Models\Activity\CoachRequest;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\Activity\Log;
use Jiminny\Models\Activity\Message;
use Jiminny\Models\Activity\Moment;
use Jiminny\Models\Activity\Note;
use Jiminny\Models\Activity\ParticipantSpeech;
use Jiminny\Models\Activity\Play;
use Jiminny\Models\Activity\Question;
use Jiminny\Models\Activity\Share;
use Jiminny\Models\Activity\Snapshot;
use Jiminny\Models\Activity\Stats;
use Jiminny\Models\Activity\SubscriptionSet;
use Jiminny\Models\Activity\TopicTrigger;
use Jiminny\Models\Activity\Transcription;
use Jiminny\Models\Calendar\CalendarEvent;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\FieldData;
use Jiminny\Models\ElasticSearch\ActivityElasticSearchTrait;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Participant\Connection;
use Jiminny\Models\Playlist\Activity as PlaylistActivity;
use Jiminny\Services\Activity\ActivityProviderRegistry;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataByStrategy;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverFactory;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverInterface;
use Jiminny\Traits\Enums;
use Jiminny\Traits\RequiresUUID;
use Jiminny\Utils\CurrencyFormatter;
use NumberFormatter;
use function in_array;
/**
* Jiminny\Models\Activity
*
* @property null|int $auto_score filled from ES hydrator, not in DB!
* @property-read Account|null $account
* @property-read CalendarEvent|null $calendarEvent
* @property-read Contact|null $contact
* @property-read Lead|null $lead
* @property-read Opportunity|null $opportunity
* @property-read Stage|null $stage
* @property int $id
* @property mixed|null $uuid
* @property string|null $source
* @property string|null $external_id
* @property string $provider
* @property string|null $location
* @property string|null $telephony_provider_id
* @property int|null $from_participant_id
* @property int|null $to_participant_id
* @property int|null $device_id
* @property string|null $type
* @property int|null $playbook_category_id
* @property int $user_id
* @property int|null $lead_id
* @property int|null $account_id
* @property int|null $contact_id
* @property int|null $opportunity_id
* @property int|null $stage_id
* @property string|null $value
* @property int|null $crm_configuration_id
* @property string|null $crm_provider_id
* @property string|null $language
* @property int|null $transcription_id
* @property int $duration
* @property string $status
* @property int|null $on_air
* @property int|null $calendar_event_id
* @property string $recording_state
* @property bool|null $recording_preference
* @property int $recording_reason_code
* @property int $summary_reminder_sent
* @property \Illuminate\Support\Carbon|null $log_reminder_sent_at
* @property \Illuminate\Support\Carbon|null $organizer_notified_at
* @property bool|null $has_recording_prompt
* @property bool $is_internal
* @property int $is_locked
* @property int $is_recording
* @property bool|null $is_processed
* @property bool $is_private
* @property bool $is_instant_invite
* @property string|null $poster_path
* @property string|null $summary
* @property string|null $title
* @property string|null $description
* @property \Illuminate\Support\Carbon|null $scheduled_start_time
* @property \Illuminate\Support\Carbon|null $scheduled_end_time
* @property \Illuminate\Support\Carbon|null $actual_start_time
* @property \Illuminate\Support\Carbon|null $actual_end_time
* @property int|null $uploaded_by
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $average_score
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $activeParticipants
* @property-read int|null $active_participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers
* @property-read int|null $activity_scorecard_rule_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRule> $activityScorecardRules
* @property-read int|null $activity_scorecard_rules_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, AvailabilityNotification> $availabilityNotifications
* @property-read int|null $availability_notifications_count
* @property-read \Jiminny\Models\PlaybookCategory|null $category
* @property-read \Illuminate\Database\Eloquent\Collection<int, CoachRequest> $coachRequests
* @property-read int|null $coach_requests_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $coachingFeedbacks
* @property-read int|null $coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $coachingMessages
* @property-read int|null $coaching_messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $comments
* @property-read int|null $comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Connection> $connections
* @property-read int|null $connections_count
* @property-read Configuration|null $crm
* @property-read \Illuminate\Database\Eloquent\Collection<int, FieldData> $data
* @property-read int|null $data_count
* @property-read \Jiminny\Models\Device|null $device
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $favoritePlaylists
* @property-read int|null $favorite_playlists_count
* @property-read \Jiminny\Models\Participant|null $from
* @property-read string|null $activity_title
* @property-read mixed $comment_count
* @property-read mixed $duration_for_humans
* @property-read string $duration_for_humans_short
* @property-read int $favorite_count
* @property-read mixed $favorites_count
* @property-read mixed $formatted_value
* @property-read string $id_string
* @property-read \Jiminny\Models\Participant|null $organizer
* @property-read mixed $play_count
* @property-read int|null $plays_count
* @property-read ?ProspectInterface $prospect
* @property-read string|null $prospect_name
* @property-read mixed $prospect_type
* @property-read mixed $share_count
* @property-read int|null $shares_count
* @property-read int|null $tracks_with_telephony_count
* @property-read int|null $visible_comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $latestCoachingFeedbacks
* @property-read int|null $latest_coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Log> $logs
* @property-read int|null $logs_count
* @property-read \Jiminny\Models\Track|null $masterTrack
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $messages
* @property-read int|null $messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Moment> $moments
* @property-read int|null $moments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Note> $notes
* @property-read int|null $notes_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\Share> $participantShares
* @property-read int|null $participant_shares_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, ParticipantSpeech> $participantSpeeches
* @property-read int|null $participant_speeches_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\ParticipantStats> $participantStats
* @property-read int|null $participant_stats_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $participants
* @property-read int|null $participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, PlaylistActivity> $playlistActivities
* @property-read int|null $playlist_activities_count
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $playlists
* @property-read int|null $playlists_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Play> $plays
* @property-read \Illuminate\Database\Eloquent\Collection<int, Question> $questions
* @property-read int|null $questions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Session> $sessions
* @property-read int|null $sessions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Share> $shares
* @property-read \Illuminate\Database\Eloquent\Collection<int, Snapshot> $snapshots
* @property-read int|null $snapshots_count
* @property-read Stats|null $stats
* @property-read \Jiminny\Models\Participant|null $to
* @property-read \Illuminate\Database\Eloquent\Collection<int, TopicTrigger> $topicTriggers
* @property-read int|null $topic_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracks
* @property-read int|null $tracks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracksWithTelephony
* @property-read Transcription|null $transcription
* @property-read \Jiminny\Models\User $user
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $visibleComments
*
* @method static \Illuminate\Database\Eloquent\Collection<int, static> all($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)
* @method static \Database\Factories\ActivityFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Collection<int, static> get($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity heldBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity idOrUuId($idOrUuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity newModelQuery()
* @method static \Jiminny\Component\Eloquent\Builder|Activity newQuery()
* @method static Builder|Activity onlyTrashed()
* @method static \Jiminny\Component\Eloquent\Builder|Activity query()
* @method static \Jiminny\Component\Eloquent\Builder|Activity scheduledBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity inOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity notInOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity forTeam(int $teamId)
* @method static \Jiminny\Component\Eloquent\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity uuid(string $uuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAccountId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAverageScore($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCalendarEventId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereContactId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCreatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmConfigurationId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeletedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDescription($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeviceId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDuration($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereFromParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereHasRecordingPrompt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInstantInvite($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInternal($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsLocked($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsPrivate($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsProcessed($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsRecording($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLanguage($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLeadId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLocation($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLogReminderSentAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOnAir($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOpportunityId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOrganizerNotifiedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePlaybookCategoryId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePosterPath($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereProvider($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingPreference($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingReasonCode($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingState($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSource($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereExternalId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStageId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStatus($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummary($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummaryReminderSent($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTelephonyProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTitle($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereToParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTranscriptionId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereType($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUpdatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUploadedBy($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUserId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUuid($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereValue($value)
* @method static Builder|Activity withTrashed()
* @method static Builder|Activity withoutTrashed()
*
* @mixin \Eloquent
*/
class Activity extends Model implements
ElasticSearch\Contract\Searchable,
Workflow\Workflow\WorkflowAwareInterface,
Models\Contracts\ActivityContract,
Contracts\Model\ActivityInterface,
UuidAwareInterface
{
use HasFactory;
use Enums;
use SoftDeletes;
use RequiresUUID;
use BitwiseFlagTrait;
use ElasticSearch\Model\Searchable;
use ActivityElasticSearchTrait;
use Workflow\Workflow\WorkflowAware {
transitionTo as traitTransitionTo;
}
public const int FLAG_RECORDING_REASON_DEFAULT = 0;
// Recording Prompted but never started
public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;
public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;
// Recording Disabled by Organization
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;
// Recording was restricted to one-side recordings only
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;
// Recording was not started because it was internal and team setting disabled that.
public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;
// Recording was not started because it was internal and user setting disabled that.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;
// Recording was not started because user setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;
// Recording was not started because team setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;
// Recording was not started because user has overriden default.
public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;
// Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;
// Recording was not started because their team setting does excludes the meeting type.
public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;
// Recording was not started because the external provider disabled it (or recording is missing etc).
public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;
// Recording was stopped externally ("exit-meeting" Pusher event)
public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;
// Recording couldn't be started due to Zoom hosting conflict error
public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;
// meeting.failed event with reason code BOT_DENIED_FROM_LOBBY
public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;
// meeting.failed event with reason code LOBBY_TIMEOUT
public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;
// meeting.failed event with reason code BOT_KICKED
public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;
// meeting.failed event with reason code UNKNOWN
public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;
public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;
// Invalid meeting (e.g. URL is invalid, or the meeting is not found)
public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;
// The host stopped the recording.
public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;
// Recording was not started because an alternative vendor disabled it (or overrode it).
public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;
// Login required meeting.failed code
public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;
// Password for meeting was not provided - meeting.failed code
public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;
// meeting.failed - when the meeting is locked
public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;
// max recording duration reached
public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;
// recording size is too small
public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;
// meeting.failed - when bot is redirected to sign in page multiple times
public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;
// meeting.failed event with reason code CONNECTION_LOST
public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;
// recording is corrupted.
public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;
// meeting ended in lobby
public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;
// meeting not started
public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;
// unfinished zoom custom disclaimer
public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;
// recording download failed - server error
public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;
// recording download failed - client code 404
public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;
// recording download failed - client code 401, 403
public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;
// recording download failed - client code 429
public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;
// recording download failed - unknown client error
public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;
// recording download failed - unknown error
public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;
// It has been setup ahead of time through calendar
public const string STATUS_SCHEDULED = 'scheduled';
// It is awaiting audio.
public const string STATUS_PENDING = 'pending';
// Participant(s) dialed in, awaiting organizer.
public const string STATUS_RINGING = 'ringing';
// Call is in progress.
public const string STATUS_IN_PROGRESS = 'in-progress';
// It has ended.
public const string STATUS_COMPLETED = 'completed';
// Cancelled prior to starting.
public const string STATUS_CANCELLED = 'canceled';
public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference
public const string STATUS_STARTING_SOON = 'starting-soon';
public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';
public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';
public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';
// When bot instance is waiting in lobby
public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';
public const string STATUS_BUSY = 'busy';
public const string STATUS_NO_ANSWER = 'no-answer';
public const string STATUS_FAILED = 'failed'; // Used by SMS too
// SMS related
public const string STATUS_ACCEPTED = 'accepted';
public const string STATUS_QUEUED = 'queued';
public const string STATUS_SENDING = 'sending';
public const string STATUS_SENT = 'sent';
public const string STATUS_DELIVERED = 'delivered';
public const string STATUS_UNDELIVERED = 'undelivered';
public const string STATUS_RECEIVING = 'receiving';
public const string STATUS_RECEIVED = 'received';
public const string STATUS_RESENT = 'resent';
public const array SMS_STATUSES = [
Activity::STATUS_RECEIVED,
Activity::STATUS_SENT,
Activity::STATUS_DELIVERED,
];
public const array SOFT_PHONE_CONFERENCE_STATUSES = [
Activity::STATUS_IN_PROGRESS,
Activity::STATUS_COMPLETED,
];
// @todo refactor prefix from `TYPE_` to `CHANNEL_`
public const string TYPE_SOFTPHONE = 'softphone';
public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';
public const string TYPE_CONFERENCE = 'conference';
public const string TYPE_SMS_INBOUND = 'sms-inbound';
public const string TYPE_SMS_OUTBOUND = 'sms-outbound';
public const string TYPE_EMAIL_INBOUND = 'email-inbound';
public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';
public const array CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
public const array PLAYABLE_CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
];
// Recording States
public const string RECORDING_OFF = 'off'; // Default state
public const string RECORDING_IN_PROGRESS = 'in-progress';
public const string RECORDING_PAUSED = 'paused';
public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.
public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.
public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.
// Live Stream States
public const int ON_AIR_DEFAULT = 0;
public const int ON_AIR_READY = 1;
public const int ON_AIR_PREPARING = 2;
public const int ON_AIR_STREAMING = 3;
public const int ON_AIR_FINISHED = 4;
public const int ON_AIR_NOT_STREAMED = 5;
public const int ON_AIR_ERROR = -1;
public const string SOURCE_GONG = 'gong';
public const string SOURCE_CHORUS = 'chorus';
public const string SOURCE_OUTLOOK = 'outlook';
public const string SOURCE_GOOGLE = 'google';
// Activity Providers
public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.
public const string PROVIDER_OUTREACH = 'outreach';
public const string PROVIDER_ZOOM_BOT = 'zoom-bot';
public const string PROVIDER_SALESLOFT = 'salesloft';
public const string PROVIDER_GOOGLE = 'google';
public const string PROVIDER_AIRCALL = 'aircall';
public const string PROVIDER_JUSTCALL = 'justcall';
public const string PROVIDER_GOOGLE_MEET = 'google-meet';
public const string PROVIDER_GONG = 'gong';
public const string PROVIDER_HUBSPOT = 'hubspot';
public const string PROVIDER_CLOSE = 'close';
public const string PROVIDER_TEAMS = 'ms-teams';
public const string PROVIDER_SALESFORCE = 'salesforce';
public const string PROVIDER_GROOVE = 'groove';
public const string PROVIDER_XANT = 'xant';
public const string PROVIDER_OFFICE = 'office';
public const string PROVIDER_NATTERBOX = 'natterbox';
public const string PROVIDER_RINGCENTRAL = 'ringcentral';
public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';
public const string PROVIDER_GOTOMEETING = 'go-to-meeting';
public const string PROVIDER_DEMODESK = 'demo-desk';
public const string PROVIDER_DIALPAD = 'dialpad';
public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';
public const string PROVIDER_CLOUDCALL = 'cloudcall';
public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';
public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // "8x8" UK
public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // "8x8" Canada
public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // "8x8" Australia
public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // "8x8" US East
public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // "8x8" US West
public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';
public const string PROVIDER_CLOUD_TALK = 'cloud-talk';
public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';
public const string PROVIDER_VONAGE = 'vonage';
public const string PROVIDER_MIGRATOR = 'migrator';
public const string PROVIDER_UPLOADER = 'uploader';
public const string PROVIDER_TALKDESK = 'talkdesk';
public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';
public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';
public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';
public const string PROVIDER_AVAYA = 'avaya';
public const string PROVIDER_TELUS = 'telus';
public const string PROVIDER_FIVE_NINE = 'five-nine';
public const string PROVIDER_APOLLO = 'apollo';
public const string PROVIDER_ORUM = 'orum';
public const string PROVIDER_BLOOBIRDS = 'bloobirds';
/**
* @const API_PROVIDERS
* A list of integrations that import calls via API instead of webhooks
*/
public const array API_PROVIDERS = [
self::PROVIDER_OUTREACH,
self::PROVIDER_SALESLOFT,
self::PROVIDER_HUBSPOT,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_NATTERBOX,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
];
public const array FINITE_STATES = [
self::TYPE_SOFTPHONE => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_SOFTPHONE_INBOUND => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,
];
public const array FINITE_STATES_CONFERENCE = [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_CANCELLED,
];
public const array MEETING_BOT_JOIN_ATTEMPTED = [
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_BOT_INSTANCE_STARTED,
];
public static array $enumStatuses = [
self::STATUS_SCHEDULED,
self::STATUS_PENDING,
self::STATUS_RINGING,
self::STATUS_IN_PROGRESS,
self::STATUS_COMPLETED,
self::STATUS_CANCELLED,
self::STATUS_BUSY,
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_ACCEPTED,
self::STATUS_QUEUED,
self::STATUS_SENDING,
self::STATUS_SENT,
self::STATUS_RESENT,
self::STATUS_DELIVERED,
self::STATUS_UNDELIVERED,
self::STATUS_RECEIVING,
self::STATUS_RECEIVED,
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_STARTING_SOON,
self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,
self::STATUS_BOT_INSTANCE_STARTED,
self::STATUS_DUPLICATED,
];
public static array $enumProviders = [
self::PROVIDER_TWILIO,
self::PROVIDER_OUTREACH,
self::PROVIDER_ZOOM_BOT,
self::PROVIDER_SALESLOFT,
self::PROVIDER_AIRCALL,
self::PROVIDER_JUSTCALL,
self::PROVIDER_GOOGLE_MEET,
self::PROVIDER_GONG,
self::PROVIDER_HUBSPOT,
self::PROVIDER_CLOSE,
self::PROVIDER_TEAMS,
self::PROVIDER_SALESFORCE,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_GOOGLE,
self::PROVIDER_OFFICE,
self::PROVIDER_NATTERBOX,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_RINGCENTRAL_VIDEO,
self::PROVIDER_GOTOMEETING,
self::PROVIDER_DEMODESK,
self::PROVIDER_DIALPAD,
self::PROVIDER_ZOOM_PHONE,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
];
public static $enumRecordingStates = [
self::RECORDING_OFF, // Default state
self::RECORDING_IN_PROGRESS,
self::RECORDING_PAUSED,
self::RECORDING_STOPPED,
self::RECORDING_RECORDED,
self::RECORDING_FAILED,
];
// @Important:
// This collection is not used anywhere, and is fully duplicated by the Channels const.
// Validate if it is referred somehow via the enum trait, and if not, remove it entirely.
// An even better strategy will be to move all those constants to a dedicated class
protected array $enumTypes = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
protected static $enumFailedStatuses = [
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_BUSY,
self::STATUS_CANCELLED,
];
protected $table = 'activities';
protected $fillable = [
// Type of activity.
'type', // @todo refactor to `channel`
// The activity type.
'playbook_category_id',
// User who hosts the activity.
'user_id',
// Related Lead record (if applicable)
'lead_id',
// Related Account record (if applicable)
'account_id',
// Related Contact record (if applicable)
'contact_id',
// Related Opportunity record (if applicable)
'opportunity_id',
// Stage of activity.
'stage_id',
// Value of opportunity.
'value',
// If the activity relates to a CRM task.
'crm_provider_id',
// If the activity was created through an external device.
'device_id',
// the activity's language code
'language',
// transcription id
'transcription_id',
// Duration of the call, with microseconds precision.
'duration',
// One of enumStatuses above.
'status',
// Have we reminded them to log the call?
'log_reminder_sent_at',
// If activity is private or inter-org, flagged here.
'is_internal',
// Managers and above can mark a call as private, to exclude it from other team members
'is_private',
'is_processed',
// Boolean for this activity being instant invite handled.
'is_instant_invite',
// If activity is in recording state, flagged here.
'recording_state',
// If activity recording is overidden from default.
'recording_preference',
// if recording did (not) happen, why that is
'recording_reason_code',
// Average score, updated during
'average_score',
// Summary that the organizer has taken after the call.
'summary',
// Subject of the activity, usually taken from calendar event.
'title',
// Description of the activity, usually taken from calendar event.
'description',
// Start time, usually taken from calendar event.
'scheduled_start_time',
// End time, usually taken from calendar event.
'scheduled_end_time',
// When the call actually started.
'actual_start_time',
// When the call actually ended.
'actual_end_time',
// SMS: Message reference
'telephony_provider_id',
// SMS: Participant who sent message
'from_participant_id',
// SMS: Participant who should receive the message
'to_participant_id',
// When an external guest joins an organizers meeting room and the organizer is not present,
// send them an SMS notification that someone has joined.
'organizer_notified_at',
// where was the activity imported from
'source',
// The id in the source system (e.g. the bot id in Recall.ai)
'external_id',
// The provider, by default it is twilio.
'provider',
// Meeting location url
'location',
// The snapshot for displaying a poster image.
'poster_path',
'crm_configuration_id',
// If there is an automated message that the conversation is being recorded
'has_recording_prompt',
// If the activity is being live-streamed
'on_air',
'calendar_event_id',
];
protected $appends = [
'id_string',
'organizer',
];
protected $hidden = [
'uuid',
];
protected $visible = [
'id_string',
'type',
'duration',
'average_score',
'status',
'log_reminder_sent_at',
'title',
'description',
'is_internal',
'scheduled_start_time',
'scheduled_end_time',
'actual_start_time',
'actual_end_time',
'user',
'category',
'account',
'contact',
'opportunity',
'lead',
'stage',
'stats',
'participants',
'playlists',
'tracks',
'comments',
'plays',
'coachingFeedbacks',
'shares',
'favorites',
'language',
'transcription',
'is_private',
'is_instant_invite',
'on_air',
'calendar_event_id',
];
protected function casts(): array
{
return [
'scheduled_start_time' => 'datetime',
'scheduled_end_time' => 'datetime',
'actual_start_time' => 'datetime',
'actual_end_time' => 'datetime',
'organizer_notified_at' => 'datetime',
'log_reminder_sent_at' => 'datetime',
'is_internal' => 'boolean',
'duration' => 'integer',
'average_score' => 'decimal:2',
'is_private' => 'boolean',
'is_processed' => 'boolean',
'is_instant_invite' => 'boolean',
'value' => 'decimal:2',
'recording_preference' => 'boolean',
'recording_reason_code' => 'integer',
'has_recording_prompt' => 'boolean',
'on_air' => 'integer',
];
}
protected static function boot()
{
parent::boot();
static::updated(static function (Activity $activity) {
// If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week
if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||
($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {
if ($activity->isDirty('status')) {
event(new StatusUpdated($activity));
}
if ($activity->isDirty('stage_id')) {
event(new StageUpdated($activity));
}
if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {
event(new ProspectUpdated($activity));
}
if ($activity->isDirty('opportunity_id')) {
event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));
}
if ($activity->isDirty('title')) {
event(new TitleUpdated($activity));
}
}
if ($activity->isDirty('playbook_category_id')) {
event(new ActivityTypeUpdated($activity));
}
});
static::deleted(static function (Activity $activity) {
// Hard delete associated playlistActivities
$activity->playlistActivities()->delete();
});
}
public function getOrganizerAttribute(): ?Participant
{
$participant = $this->participants()->where('user_id', $this->user_id)->first();
if (! $participant instanceof Participant && $participant !== null) {
throw new RuntimeException(sprintf('$participant must be an instance of "%s" or null', Participant::class));
}
return $participant;
}
public function getFormattedValueAttribute()
{
$currencyCode = 'USD';
if ($this->opportunity) {
$currencyCode = $this->opportunity->getCurrencyCode();
}
$formatter = new CurrencyFormatter();
$formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
return $formatter->format($this->value, $currencyCode);
}
public function getProspectNameAttribute(): ?string
{
$prospectName = null;
if ($this->lead_id) {
$prospectName = $this->lead->name;
} elseif ($this->contact_id) {
$prospectName = $this->contact->name;
} elseif ($this->account_id) {
$prospectName = $this->account->name;
}
return $prospectName;
}
public function getProspectName(): ?string
{
/** @var string|null */
return $this->getAttribute('prospect_name');
}
/**
* Get activity title depending on prospect or title
*/
public function getActivityTitleAttribute(): ?string
{
$activityTitle = null;
if ($this->prospect && $this->prospect->getName()) {
if ($this->account_id) {
$activityTitle = $this->account->name;
} elseif ($this->lead_id) {
$activityTitle = $this->lead->company;
} elseif ($this->contact_id) {
$activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;
}
} elseif ($this->title) {
$activityTitle = $this->title;
}
return $activityTitle;
}
public function wasRecentlyCreated(): bool
{
return $this->wasRecentlyCreated;
}
public function getProspectTypeAttribute()
{
$prospectType = null;
if ($this->lead_id) {
$prospectType = 'Lead';
} elseif ($this->contact_id) {
$prospectType = 'Contact';
} elseif ($this->account_id) {
$prospectType = 'Account';
}
return $prospectType;
}
/**
* Return the best match for prospect. Results are in the following order of priority:
* 1. Lead
* 2. Contact
* 3. Account
* 4. NULL
*/
public function getProspectAttribute(): ?ProspectInterface
{
if ($this->hasLead()) {
return $this->getLead();
}
if ($this->hasContact()) {
return $this->getContact();
}
if ($this->hasAccount()) {
return $this->getAccount();
}
return null;
}
public function getTitleAttribute($value): ?string
{
return \getActivityTitleAttribute(
$this->user->name,
$this->getType(),
$value,
$this->prospect->name ?? null,
$this->from->national_phone_number ?? null
);
}
public function getTitle(): ?string
{
return $this->getAttribute('title');
}
public function getSummary(): ?string
{
return $this->getAttribute('summary');
}
public function isInternal(): bool
{
return $this->getAttribute('is_internal');
}
public function getIsPrivate(): bool
{
return $this->getAttribute('is_private');
}
public function getDescription(): ?string
{
return $this->getAttribute('description');
}
public function hasTitle(): bool
{
return $this->getOriginal('title') !== null;
}
public function getPlayCountAttribute()
{
return $this->getPlaysCountAttribute();
}
public function getPlaysCountAttribute()
{
if (! isset($this->attributes['plays_count'])) {
$this->loadCount('plays');
}
return $this->attributes['plays_count'];
}
public function getCommentCountAttribute()
{
return $this->getCommentsCountAttribute();
}
public function getCommentsCountAttribute()
{
if (! isset($this->attributes['comments_count'])) {
$this->loadCount('comments');
}
return $this->attributes['comments_count'];
}
public function getVisibleCommentsCountAttribute()
{
if (! isset($this->attributes['visible_comments_count'])) {
$activityCommentsService = app(ActivityCommentService::class);
$user = Auth::user() instanceof User ? Auth::user() : null;
$this->attributes['visible_comments_count'] = $activityCommentsService
->getVisibleCommentsCount($this, $user);
}
return $this->attributes['visible_comments_count'];
}
public function getShareCountAttribute()
{
return $this->getSharesCountAttribute();
}
public function getSharesCountAttribute()
{
if (! isset($this->attributes['shares_count'])) {
$this->loadCount('shares');
}
return $this->attributes['shares_count'];
}
/**
* Get the count of favorites playlists this activity appears in
*/
public function getFavoriteCountAttribute(): int
{
return $this->getFavoritesCountAttribute();
}
public function getFavoritesCountAttribute()
{
if (! isset($this->attributes['favorites_count'])) {
$this->loadCount('favorites');
}
return $this->attributes['favorites_count'];
}
public function getActiveParticipantsCountAttribute()
{
if (! isset($this->attributes['active_participants_count'])) {
$this->loadCount('activeParticipants');
}
return $this->attributes['active_participants_count'];
}
public function getTracksWithTelephonyCountAttribute()
{
if (! isset($this->attributes['tracks_with_telephony_count'])) {
$this->loadCount('tracksWithTelephony');
}
return $this->attributes['tracks_with_telephony_count'];
}
/**
* @TEMP
* $this->loadCount('tracksWithTelephony') throws null pointer exception
*/
public function countTracksWithTelephony(): int
{
return $this->tracks()->whereNotNull('telephony_provider_id')->count();
}
public function getDuration(): float
{
return $this->getAttribute('duration');
}
public function getDurationForHumansAttribute()
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);
}
public function getDurationForHumansShortAttribute(): string
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);
}
public function has...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"169","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"102","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\nnamespace Jiminny\\Models;\n\nuse Carbon\\Carbon;\nuse Database\\Factories\\ActivityFactory;\nuse DateTimeInterface;\nuse Exception;\nuse Illuminate\\Contracts\\Auth\\Authenticatable;\nuse Illuminate\\Database\\Eloquent;\nuse Illuminate\\Database\\Eloquent\\Attributes\\Scope;\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse Illuminate\\Database\\Eloquent\\Factories\\Factory;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasManyThrough;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasOne;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Auth;\nuse InvalidArgumentException;\nuse Jiminny\\Component\\ElasticSearch;\nuse Jiminny\\Component\\MeetingBot;\nuse Jiminny\\Component\\Model\\BitwiseFlagTrait;\nuse Jiminny\\Component\\PlaybackPage\\Comments\\Services\\ActivityCommentService;\nuse Jiminny\\Component\\Sidekick\\SidekickService;\nuse Jiminny\\Component\\Uuid\\UuidAwareInterface;\nuse Jiminny\\Component\\Workflow;\nuse Jiminny\\Contracts;\nuse Jiminny\\Contracts\\Crm\\ProspectInterface;\nuse Jiminny\\DTO\\ImportCall\\Call;\nuse Jiminny\\Events\\Activities\\ActivityTypeUpdated;\nuse Jiminny\\Events\\Activities\\ActivityUpdated;\nuse Jiminny\\Events\\Activities\\ProspectUpdated;\nuse Jiminny\\Events\\Activities\\StageUpdated;\nuse Jiminny\\Events\\Activities\\StatusUpdated;\nuse Jiminny\\Events\\Activities\\TitleUpdated;\nuse Jiminny\\Exceptions\\InvalidArgumentException as InvalidArgumentJiminnyException;\nuse Jiminny\\Exceptions\\LogicException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Activity\\ActivitySummaryLog;\nuse Jiminny\\Models\\Activity\\ActivityUploadSetting;\nuse Jiminny\\Models\\Activity\\AvailabilityNotification;\nuse Jiminny\\Models\\Activity\\CoachRequest;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\Activity\\Log;\nuse Jiminny\\Models\\Activity\\Message;\nuse Jiminny\\Models\\Activity\\Moment;\nuse Jiminny\\Models\\Activity\\Note;\nuse Jiminny\\Models\\Activity\\ParticipantSpeech;\nuse Jiminny\\Models\\Activity\\Play;\nuse Jiminny\\Models\\Activity\\Question;\nuse Jiminny\\Models\\Activity\\Share;\nuse Jiminny\\Models\\Activity\\Snapshot;\nuse Jiminny\\Models\\Activity\\Stats;\nuse Jiminny\\Models\\Activity\\SubscriptionSet;\nuse Jiminny\\Models\\Activity\\TopicTrigger;\nuse Jiminny\\Models\\Activity\\Transcription;\nuse Jiminny\\Models\\Calendar\\CalendarEvent;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\FieldData;\nuse Jiminny\\Models\\ElasticSearch\\ActivityElasticSearchTrait;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Participant\\Connection;\nuse Jiminny\\Models\\Playlist\\Activity as PlaylistActivity;\nuse Jiminny\\Services\\Activity\\ActivityProviderRegistry;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataByStrategy;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverFactory;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverInterface;\nuse Jiminny\\Traits\\Enums;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Jiminny\\Utils\\CurrencyFormatter;\nuse NumberFormatter;\n\nuse function in_array;\n\n/**\n * Jiminny\\Models\\Activity\n *\n * @property null|int $auto_score filled from ES hydrator, not in DB!\n * @property-read Account|null $account\n * @property-read CalendarEvent|null $calendarEvent\n * @property-read Contact|null $contact\n * @property-read Lead|null $lead\n * @property-read Opportunity|null $opportunity\n * @property-read Stage|null $stage\n * @property int $id\n * @property mixed|null $uuid\n * @property string|null $source\n * @property string|null $external_id\n * @property string $provider\n * @property string|null $location\n * @property string|null $telephony_provider_id\n * @property int|null $from_participant_id\n * @property int|null $to_participant_id\n * @property int|null $device_id\n * @property string|null $type\n * @property int|null $playbook_category_id\n * @property int $user_id\n * @property int|null $lead_id\n * @property int|null $account_id\n * @property int|null $contact_id\n * @property int|null $opportunity_id\n * @property int|null $stage_id\n * @property string|null $value\n * @property int|null $crm_configuration_id\n * @property string|null $crm_provider_id\n * @property string|null $language\n * @property int|null $transcription_id\n * @property int $duration\n * @property string $status\n * @property int|null $on_air\n * @property int|null $calendar_event_id\n * @property string $recording_state\n * @property bool|null $recording_preference\n * @property int $recording_reason_code\n * @property int $summary_reminder_sent\n * @property \\Illuminate\\Support\\Carbon|null $log_reminder_sent_at\n * @property \\Illuminate\\Support\\Carbon|null $organizer_notified_at\n * @property bool|null $has_recording_prompt\n * @property bool $is_internal\n * @property int $is_locked\n * @property int $is_recording\n * @property bool|null $is_processed\n * @property bool $is_private\n * @property bool $is_instant_invite\n * @property string|null $poster_path\n * @property string|null $summary\n * @property string|null $title\n * @property string|null $description\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_start_time\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_end_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_start_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_end_time\n * @property int|null $uploaded_by\n * @property \\Illuminate\\Support\\Carbon|null $deleted_at\n * @property \\Illuminate\\Support\\Carbon|null $created_at\n * @property \\Illuminate\\Support\\Carbon|null $updated_at\n * @property string|null $average_score\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $activeParticipants\n * @property-read int|null $active_participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers\n * @property-read int|null $activity_scorecard_rule_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRule> $activityScorecardRules\n * @property-read int|null $activity_scorecard_rules_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, AvailabilityNotification> $availabilityNotifications\n * @property-read int|null $availability_notifications_count\n * @property-read \\Jiminny\\Models\\PlaybookCategory|null $category\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, CoachRequest> $coachRequests\n * @property-read int|null $coach_requests_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $coachingFeedbacks\n * @property-read int|null $coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $coachingMessages\n * @property-read int|null $coaching_messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $comments\n * @property-read int|null $comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Connection> $connections\n * @property-read int|null $connections_count\n * @property-read Configuration|null $crm\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, FieldData> $data\n * @property-read int|null $data_count\n * @property-read \\Jiminny\\Models\\Device|null $device\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $favoritePlaylists\n * @property-read int|null $favorite_playlists_count\n * @property-read \\Jiminny\\Models\\Participant|null $from\n * @property-read string|null $activity_title\n * @property-read mixed $comment_count\n * @property-read mixed $duration_for_humans\n * @property-read string $duration_for_humans_short\n * @property-read int $favorite_count\n * @property-read mixed $favorites_count\n * @property-read mixed $formatted_value\n * @property-read string $id_string\n * @property-read \\Jiminny\\Models\\Participant|null $organizer\n * @property-read mixed $play_count\n * @property-read int|null $plays_count\n * @property-read ?ProspectInterface $prospect\n * @property-read string|null $prospect_name\n * @property-read mixed $prospect_type\n * @property-read mixed $share_count\n * @property-read int|null $shares_count\n * @property-read int|null $tracks_with_telephony_count\n * @property-read int|null $visible_comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $latestCoachingFeedbacks\n * @property-read int|null $latest_coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Log> $logs\n * @property-read int|null $logs_count\n * @property-read \\Jiminny\\Models\\Track|null $masterTrack\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $messages\n * @property-read int|null $messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Moment> $moments\n * @property-read int|null $moments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Note> $notes\n * @property-read int|null $notes_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\Share> $participantShares\n * @property-read int|null $participant_shares_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, ParticipantSpeech> $participantSpeeches\n * @property-read int|null $participant_speeches_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\ParticipantStats> $participantStats\n * @property-read int|null $participant_stats_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $participants\n * @property-read int|null $participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, PlaylistActivity> $playlistActivities\n * @property-read int|null $playlist_activities_count\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $playlists\n * @property-read int|null $playlists_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Play> $plays\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Question> $questions\n * @property-read int|null $questions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Session> $sessions\n * @property-read int|null $sessions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Share> $shares\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Snapshot> $snapshots\n * @property-read int|null $snapshots_count\n * @property-read Stats|null $stats\n * @property-read \\Jiminny\\Models\\Participant|null $to\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, TopicTrigger> $topicTriggers\n * @property-read int|null $topic_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracks\n * @property-read int|null $tracks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracksWithTelephony\n * @property-read Transcription|null $transcription\n * @property-read \\Jiminny\\Models\\User $user\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $visibleComments\n *\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> all($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)\n * @method static \\Database\\Factories\\ActivityFactory factory(...$parameters)\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> get($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity heldBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity idOrUuId($idOrUuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newModelQuery()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newQuery()\n * @method static Builder|Activity onlyTrashed()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity query()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity scheduledBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity inOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity notInOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity forTeam(int $teamId)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity uuid(string $uuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAccountId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAverageScore($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCalendarEventId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereContactId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCreatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmConfigurationId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeletedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDescription($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeviceId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDuration($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereFromParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereHasRecordingPrompt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInstantInvite($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInternal($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsLocked($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsPrivate($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsProcessed($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsRecording($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLanguage($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLeadId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLocation($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLogReminderSentAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOnAir($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOpportunityId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOrganizerNotifiedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePlaybookCategoryId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePosterPath($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereProvider($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingPreference($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingReasonCode($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingState($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSource($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereExternalId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStageId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStatus($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummary($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummaryReminderSent($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTelephonyProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTitle($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereToParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTranscriptionId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereType($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUpdatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUploadedBy($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUserId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUuid($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereValue($value)\n * @method static Builder|Activity withTrashed()\n * @method static Builder|Activity withoutTrashed()\n *\n * @mixin \\Eloquent\n */\nclass Activity extends Model implements\n ElasticSearch\\Contract\\Searchable,\n Workflow\\Workflow\\WorkflowAwareInterface,\n Models\\Contracts\\ActivityContract,\n Contracts\\Model\\ActivityInterface,\n UuidAwareInterface\n{\n use HasFactory;\n\n use Enums;\n use SoftDeletes;\n use RequiresUUID;\n use BitwiseFlagTrait;\n use ElasticSearch\\Model\\Searchable;\n use ActivityElasticSearchTrait;\n\n use Workflow\\Workflow\\WorkflowAware {\n transitionTo as traitTransitionTo;\n }\n\n public const int FLAG_RECORDING_REASON_DEFAULT = 0;\n\n // Recording Prompted but never started\n public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;\n public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;\n\n // Recording Disabled by Organization\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;\n\n // Recording was restricted to one-side recordings only\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;\n\n // Recording was not started because it was internal and team setting disabled that.\n public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;\n\n // Recording was not started because it was internal and user setting disabled that.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;\n\n // Recording was not started because user setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;\n\n // Recording was not started because team setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;\n\n // Recording was not started because user has overriden default.\n public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;\n\n // Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;\n\n // Recording was not started because their team setting does excludes the meeting type.\n public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;\n\n // Recording was not started because the external provider disabled it (or recording is missing etc).\n public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;\n\n // Recording was stopped externally (\"exit-meeting\" Pusher event)\n public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;\n\n // Recording couldn't be started due to Zoom hosting conflict error\n public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;\n\n // meeting.failed event with reason code BOT_DENIED_FROM_LOBBY\n public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;\n\n // meeting.failed event with reason code LOBBY_TIMEOUT\n public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;\n\n // meeting.failed event with reason code BOT_KICKED\n public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;\n\n // meeting.failed event with reason code UNKNOWN\n public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;\n\n public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;\n\n // Invalid meeting (e.g. URL is invalid, or the meeting is not found)\n public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;\n\n // The host stopped the recording.\n public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;\n\n // Recording was not started because an alternative vendor disabled it (or overrode it).\n public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;\n\n // Login required meeting.failed code\n public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;\n\n // Password for meeting was not provided - meeting.failed code\n public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;\n\n // meeting.failed - when the meeting is locked\n public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;\n\n // max recording duration reached\n public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;\n\n // recording size is too small\n public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;\n\n // meeting.failed - when bot is redirected to sign in page multiple times\n public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;\n\n // meeting.failed event with reason code CONNECTION_LOST\n public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;\n\n // recording is corrupted.\n public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;\n\n // meeting ended in lobby\n public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;\n\n // meeting not started\n public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;\n\n // unfinished zoom custom disclaimer\n public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;\n\n // recording download failed - server error\n public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;\n\n // recording download failed - client code 404\n public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;\n\n // recording download failed - client code 401, 403\n public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;\n\n // recording download failed - client code 429\n public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;\n\n // recording download failed - unknown client error\n public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;\n\n // recording download failed - unknown error\n public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;\n\n // It has been setup ahead of time through calendar\n public const string STATUS_SCHEDULED = 'scheduled';\n\n // It is awaiting audio.\n public const string STATUS_PENDING = 'pending';\n\n // Participant(s) dialed in, awaiting organizer.\n public const string STATUS_RINGING = 'ringing';\n\n // Call is in progress.\n public const string STATUS_IN_PROGRESS = 'in-progress';\n\n // It has ended.\n public const string STATUS_COMPLETED = 'completed';\n\n // Cancelled prior to starting.\n public const string STATUS_CANCELLED = 'canceled';\n\n public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference\n\n public const string STATUS_STARTING_SOON = 'starting-soon';\n\n public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';\n\n public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';\n\n public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';\n\n // When bot instance is waiting in lobby\n public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';\n\n public const string STATUS_BUSY = 'busy';\n public const string STATUS_NO_ANSWER = 'no-answer';\n public const string STATUS_FAILED = 'failed'; // Used by SMS too\n\n // SMS related\n public const string STATUS_ACCEPTED = 'accepted';\n public const string STATUS_QUEUED = 'queued';\n public const string STATUS_SENDING = 'sending';\n public const string STATUS_SENT = 'sent';\n public const string STATUS_DELIVERED = 'delivered';\n public const string STATUS_UNDELIVERED = 'undelivered';\n public const string STATUS_RECEIVING = 'receiving';\n public const string STATUS_RECEIVED = 'received';\n public const string STATUS_RESENT = 'resent';\n\n public const array SMS_STATUSES = [\n Activity::STATUS_RECEIVED,\n Activity::STATUS_SENT,\n Activity::STATUS_DELIVERED,\n ];\n\n public const array SOFT_PHONE_CONFERENCE_STATUSES = [\n Activity::STATUS_IN_PROGRESS,\n Activity::STATUS_COMPLETED,\n ];\n\n // @todo refactor prefix from `TYPE_` to `CHANNEL_`\n public const string TYPE_SOFTPHONE = 'softphone';\n public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';\n public const string TYPE_CONFERENCE = 'conference';\n public const string TYPE_SMS_INBOUND = 'sms-inbound';\n public const string TYPE_SMS_OUTBOUND = 'sms-outbound';\n public const string TYPE_EMAIL_INBOUND = 'email-inbound';\n public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';\n\n public const array CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n public const array PLAYABLE_CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n ];\n\n // Recording States\n public const string RECORDING_OFF = 'off'; // Default state\n public const string RECORDING_IN_PROGRESS = 'in-progress';\n public const string RECORDING_PAUSED = 'paused';\n public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.\n public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.\n public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.\n\n // Live Stream States\n public const int ON_AIR_DEFAULT = 0;\n public const int ON_AIR_READY = 1;\n public const int ON_AIR_PREPARING = 2;\n public const int ON_AIR_STREAMING = 3;\n public const int ON_AIR_FINISHED = 4;\n public const int ON_AIR_NOT_STREAMED = 5;\n public const int ON_AIR_ERROR = -1;\n\n public const string SOURCE_GONG = 'gong';\n public const string SOURCE_CHORUS = 'chorus';\n public const string SOURCE_OUTLOOK = 'outlook';\n public const string SOURCE_GOOGLE = 'google';\n\n // Activity Providers\n public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.\n public const string PROVIDER_OUTREACH = 'outreach';\n public const string PROVIDER_ZOOM_BOT = 'zoom-bot';\n public const string PROVIDER_SALESLOFT = 'salesloft';\n public const string PROVIDER_GOOGLE = 'google';\n public const string PROVIDER_AIRCALL = 'aircall';\n public const string PROVIDER_JUSTCALL = 'justcall';\n public const string PROVIDER_GOOGLE_MEET = 'google-meet';\n public const string PROVIDER_GONG = 'gong';\n public const string PROVIDER_HUBSPOT = 'hubspot';\n public const string PROVIDER_CLOSE = 'close';\n public const string PROVIDER_TEAMS = 'ms-teams';\n public const string PROVIDER_SALESFORCE = 'salesforce';\n public const string PROVIDER_GROOVE = 'groove';\n public const string PROVIDER_XANT = 'xant';\n public const string PROVIDER_OFFICE = 'office';\n public const string PROVIDER_NATTERBOX = 'natterbox';\n public const string PROVIDER_RINGCENTRAL = 'ringcentral';\n public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';\n public const string PROVIDER_GOTOMEETING = 'go-to-meeting';\n public const string PROVIDER_DEMODESK = 'demo-desk';\n public const string PROVIDER_DIALPAD = 'dialpad';\n public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';\n public const string PROVIDER_CLOUDCALL = 'cloudcall';\n public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';\n public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // \"8x8\" UK\n public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // \"8x8\" Canada\n public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // \"8x8\" Australia\n public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // \"8x8\" US East\n public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // \"8x8\" US West\n public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';\n public const string PROVIDER_CLOUD_TALK = 'cloud-talk';\n public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';\n public const string PROVIDER_VONAGE = 'vonage';\n public const string PROVIDER_MIGRATOR = 'migrator';\n public const string PROVIDER_UPLOADER = 'uploader';\n public const string PROVIDER_TALKDESK = 'talkdesk';\n public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';\n public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';\n public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';\n public const string PROVIDER_AVAYA = 'avaya';\n public const string PROVIDER_TELUS = 'telus';\n public const string PROVIDER_FIVE_NINE = 'five-nine';\n public const string PROVIDER_APOLLO = 'apollo';\n public const string PROVIDER_ORUM = 'orum';\n public const string PROVIDER_BLOOBIRDS = 'bloobirds';\n\n /**\n * @const API_PROVIDERS\n * A list of integrations that import calls via API instead of webhooks\n */\n public const array API_PROVIDERS = [\n self::PROVIDER_OUTREACH,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n ];\n\n public const array FINITE_STATES = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,\n ];\n\n public const array FINITE_STATES_CONFERENCE = [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_CANCELLED,\n ];\n\n public const array MEETING_BOT_JOIN_ATTEMPTED = [\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_BOT_INSTANCE_STARTED,\n ];\n\n public static array $enumStatuses = [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_ACCEPTED,\n self::STATUS_QUEUED,\n self::STATUS_SENDING,\n self::STATUS_SENT,\n self::STATUS_RESENT,\n self::STATUS_DELIVERED,\n self::STATUS_UNDELIVERED,\n self::STATUS_RECEIVING,\n self::STATUS_RECEIVED,\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_STARTING_SOON,\n self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,\n self::STATUS_BOT_INSTANCE_STARTED,\n self::STATUS_DUPLICATED,\n ];\n\n public static array $enumProviders = [\n self::PROVIDER_TWILIO,\n self::PROVIDER_OUTREACH,\n self::PROVIDER_ZOOM_BOT,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_AIRCALL,\n self::PROVIDER_JUSTCALL,\n self::PROVIDER_GOOGLE_MEET,\n self::PROVIDER_GONG,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_CLOSE,\n self::PROVIDER_TEAMS,\n self::PROVIDER_SALESFORCE,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_GOOGLE,\n self::PROVIDER_OFFICE,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_RINGCENTRAL_VIDEO,\n self::PROVIDER_GOTOMEETING,\n self::PROVIDER_DEMODESK,\n self::PROVIDER_DIALPAD,\n self::PROVIDER_ZOOM_PHONE,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n ];\n\n public static $enumRecordingStates = [\n self::RECORDING_OFF, // Default state\n self::RECORDING_IN_PROGRESS,\n self::RECORDING_PAUSED,\n self::RECORDING_STOPPED,\n self::RECORDING_RECORDED,\n self::RECORDING_FAILED,\n ];\n\n // @Important:\n // This collection is not used anywhere, and is fully duplicated by the Channels const.\n // Validate if it is referred somehow via the enum trait, and if not, remove it entirely.\n // An even better strategy will be to move all those constants to a dedicated class\n protected array $enumTypes = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n protected static $enumFailedStatuses = [\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n self::STATUS_CANCELLED,\n ];\n\n protected $table = 'activities';\n\n protected $fillable = [\n // Type of activity.\n 'type', // @todo refactor to `channel`\n // The activity type.\n 'playbook_category_id',\n // User who hosts the activity.\n 'user_id',\n // Related Lead record (if applicable)\n 'lead_id',\n // Related Account record (if applicable)\n 'account_id',\n // Related Contact record (if applicable)\n 'contact_id',\n // Related Opportunity record (if applicable)\n 'opportunity_id',\n // Stage of activity.\n 'stage_id',\n // Value of opportunity.\n 'value',\n // If the activity relates to a CRM task.\n 'crm_provider_id',\n // If the activity was created through an external device.\n 'device_id',\n // the activity's language code\n 'language',\n // transcription id\n 'transcription_id',\n // Duration of the call, with microseconds precision.\n 'duration',\n // One of enumStatuses above.\n 'status',\n // Have we reminded them to log the call?\n 'log_reminder_sent_at',\n // If activity is private or inter-org, flagged here.\n 'is_internal',\n // Managers and above can mark a call as private, to exclude it from other team members\n 'is_private',\n 'is_processed',\n // Boolean for this activity being instant invite handled.\n 'is_instant_invite',\n // If activity is in recording state, flagged here.\n 'recording_state',\n // If activity recording is overidden from default.\n 'recording_preference',\n // if recording did (not) happen, why that is\n 'recording_reason_code',\n // Average score, updated during\n 'average_score',\n // Summary that the organizer has taken after the call.\n 'summary',\n // Subject of the activity, usually taken from calendar event.\n 'title',\n // Description of the activity, usually taken from calendar event.\n 'description',\n // Start time, usually taken from calendar event.\n 'scheduled_start_time',\n // End time, usually taken from calendar event.\n 'scheduled_end_time',\n // When the call actually started.\n 'actual_start_time',\n // When the call actually ended.\n 'actual_end_time',\n // SMS: Message reference\n 'telephony_provider_id',\n // SMS: Participant who sent message\n 'from_participant_id',\n // SMS: Participant who should receive the message\n 'to_participant_id',\n // When an external guest joins an organizers meeting room and the organizer is not present,\n // send them an SMS notification that someone has joined.\n 'organizer_notified_at',\n // where was the activity imported from\n 'source',\n // The id in the source system (e.g. the bot id in Recall.ai)\n 'external_id',\n // The provider, by default it is twilio.\n 'provider',\n // Meeting location url\n 'location',\n // The snapshot for displaying a poster image.\n 'poster_path',\n 'crm_configuration_id',\n // If there is an automated message that the conversation is being recorded\n 'has_recording_prompt',\n // If the activity is being live-streamed\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected $appends = [\n 'id_string',\n 'organizer',\n ];\n\n protected $hidden = [\n 'uuid',\n ];\n\n protected $visible = [\n 'id_string',\n 'type',\n 'duration',\n 'average_score',\n 'status',\n 'log_reminder_sent_at',\n 'title',\n 'description',\n 'is_internal',\n 'scheduled_start_time',\n 'scheduled_end_time',\n 'actual_start_time',\n 'actual_end_time',\n 'user',\n 'category',\n 'account',\n 'contact',\n 'opportunity',\n 'lead',\n 'stage',\n 'stats',\n 'participants',\n 'playlists',\n 'tracks',\n 'comments',\n 'plays',\n 'coachingFeedbacks',\n 'shares',\n 'favorites',\n 'language',\n 'transcription',\n 'is_private',\n 'is_instant_invite',\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'scheduled_start_time' => 'datetime',\n 'scheduled_end_time' => 'datetime',\n 'actual_start_time' => 'datetime',\n 'actual_end_time' => 'datetime',\n 'organizer_notified_at' => 'datetime',\n 'log_reminder_sent_at' => 'datetime',\n 'is_internal' => 'boolean',\n 'duration' => 'integer',\n 'average_score' => 'decimal:2',\n 'is_private' => 'boolean',\n 'is_processed' => 'boolean',\n 'is_instant_invite' => 'boolean',\n 'value' => 'decimal:2',\n 'recording_preference' => 'boolean',\n 'recording_reason_code' => 'integer',\n 'has_recording_prompt' => 'boolean',\n 'on_air' => 'integer',\n ];\n }\n\n protected static function boot()\n {\n parent::boot();\n\n static::updated(static function (Activity $activity) {\n // If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week\n if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||\n ($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {\n if ($activity->isDirty('status')) {\n event(new StatusUpdated($activity));\n }\n\n if ($activity->isDirty('stage_id')) {\n event(new StageUpdated($activity));\n }\n\n if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {\n event(new ProspectUpdated($activity));\n }\n\n if ($activity->isDirty('opportunity_id')) {\n event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));\n }\n\n if ($activity->isDirty('title')) {\n event(new TitleUpdated($activity));\n }\n }\n\n if ($activity->isDirty('playbook_category_id')) {\n event(new ActivityTypeUpdated($activity));\n }\n });\n\n static::deleted(static function (Activity $activity) {\n // Hard delete associated playlistActivities\n $activity->playlistActivities()->delete();\n });\n }\n\n public function getOrganizerAttribute(): ?Participant\n {\n $participant = $this->participants()->where('user_id', $this->user_id)->first();\n\n if (! $participant instanceof Participant && $participant !== null) {\n throw new RuntimeException(sprintf('$participant must be an instance of \"%s\" or null', Participant::class));\n }\n\n return $participant;\n }\n\n public function getFormattedValueAttribute()\n {\n $currencyCode = 'USD';\n if ($this->opportunity) {\n $currencyCode = $this->opportunity->getCurrencyCode();\n }\n\n $formatter = new CurrencyFormatter();\n $formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);\n $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);\n\n return $formatter->format($this->value, $currencyCode);\n }\n\n public function getProspectNameAttribute(): ?string\n {\n $prospectName = null;\n\n if ($this->lead_id) {\n $prospectName = $this->lead->name;\n } elseif ($this->contact_id) {\n $prospectName = $this->contact->name;\n } elseif ($this->account_id) {\n $prospectName = $this->account->name;\n }\n\n return $prospectName;\n }\n\n public function getProspectName(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('prospect_name');\n }\n\n /**\n * Get activity title depending on prospect or title\n */\n public function getActivityTitleAttribute(): ?string\n {\n $activityTitle = null;\n if ($this->prospect && $this->prospect->getName()) {\n if ($this->account_id) {\n $activityTitle = $this->account->name;\n } elseif ($this->lead_id) {\n $activityTitle = $this->lead->company;\n } elseif ($this->contact_id) {\n $activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;\n }\n } elseif ($this->title) {\n $activityTitle = $this->title;\n }\n\n return $activityTitle;\n }\n\n public function wasRecentlyCreated(): bool\n {\n return $this->wasRecentlyCreated;\n }\n\n public function getProspectTypeAttribute()\n {\n $prospectType = null;\n\n if ($this->lead_id) {\n $prospectType = 'Lead';\n } elseif ($this->contact_id) {\n $prospectType = 'Contact';\n } elseif ($this->account_id) {\n $prospectType = 'Account';\n }\n\n return $prospectType;\n }\n\n /**\n * Return the best match for prospect. Results are in the following order of priority:\n * 1. Lead\n * 2. Contact\n * 3. Account\n * 4. NULL\n */\n public function getProspectAttribute(): ?ProspectInterface\n {\n if ($this->hasLead()) {\n return $this->getLead();\n }\n\n if ($this->hasContact()) {\n return $this->getContact();\n }\n\n if ($this->hasAccount()) {\n return $this->getAccount();\n }\n\n return null;\n }\n\n public function getTitleAttribute($value): ?string\n {\n return \\getActivityTitleAttribute(\n $this->user->name,\n $this->getType(),\n $value,\n $this->prospect->name ?? null,\n $this->from->national_phone_number ?? null\n );\n }\n\n public function getTitle(): ?string\n {\n return $this->getAttribute('title');\n }\n\n public function getSummary(): ?string\n {\n return $this->getAttribute('summary');\n }\n\n public function isInternal(): bool\n {\n return $this->getAttribute('is_internal');\n }\n\n public function getIsPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n public function getDescription(): ?string\n {\n return $this->getAttribute('description');\n }\n\n public function hasTitle(): bool\n {\n return $this->getOriginal('title') !== null;\n }\n\n public function getPlayCountAttribute()\n {\n return $this->getPlaysCountAttribute();\n }\n\n public function getPlaysCountAttribute()\n {\n if (! isset($this->attributes['plays_count'])) {\n $this->loadCount('plays');\n }\n\n return $this->attributes['plays_count'];\n }\n\n public function getCommentCountAttribute()\n {\n return $this->getCommentsCountAttribute();\n }\n\n public function getCommentsCountAttribute()\n {\n if (! isset($this->attributes['comments_count'])) {\n $this->loadCount('comments');\n }\n\n return $this->attributes['comments_count'];\n }\n\n public function getVisibleCommentsCountAttribute()\n {\n if (! isset($this->attributes['visible_comments_count'])) {\n $activityCommentsService = app(ActivityCommentService::class);\n $user = Auth::user() instanceof User ? Auth::user() : null;\n $this->attributes['visible_comments_count'] = $activityCommentsService\n ->getVisibleCommentsCount($this, $user);\n }\n\n return $this->attributes['visible_comments_count'];\n }\n\n public function getShareCountAttribute()\n {\n return $this->getSharesCountAttribute();\n }\n\n public function getSharesCountAttribute()\n {\n if (! isset($this->attributes['shares_count'])) {\n $this->loadCount('shares');\n }\n\n return $this->attributes['shares_count'];\n }\n\n\n /**\n * Get the count of favorites playlists this activity appears in\n */\n public function getFavoriteCountAttribute(): int\n {\n return $this->getFavoritesCountAttribute();\n }\n\n public function getFavoritesCountAttribute()\n {\n if (! isset($this->attributes['favorites_count'])) {\n $this->loadCount('favorites');\n }\n\n return $this->attributes['favorites_count'];\n }\n\n public function getActiveParticipantsCountAttribute()\n {\n if (! isset($this->attributes['active_participants_count'])) {\n $this->loadCount('activeParticipants');\n }\n\n return $this->attributes['active_participants_count'];\n }\n\n public function getTracksWithTelephonyCountAttribute()\n {\n if (! isset($this->attributes['tracks_with_telephony_count'])) {\n $this->loadCount('tracksWithTelephony');\n }\n\n return $this->attributes['tracks_with_telephony_count'];\n }\n\n /**\n * @TEMP\n * $this->loadCount('tracksWithTelephony') throws null pointer exception\n */\n public function countTracksWithTelephony(): int\n {\n return $this->tracks()->whereNotNull('telephony_provider_id')->count();\n }\n\n public function getDuration(): float\n {\n return $this->getAttribute('duration');\n }\n\n public function getDurationForHumansAttribute()\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);\n }\n\n public function getDurationForHumansShortAttribute(): string\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);\n }\n\n public function hasRecordingPreference(): bool\n {\n return $this->getAttribute('recording_preference') !== null;\n }\n\n public function getRecordingPreference()\n {\n return $this->getAttribute('recording_preference');\n }\n\n /** @return BelongsTo<User, self> */\n public function user(): BelongsTo\n {\n return $this->belongsTo(User::class)->with('group');\n }\n\n public function device()\n {\n return $this->belongsTo(Device::class);\n }\n\n public function category()\n {\n return $this->belongsTo(PlaybookCategory::class, 'playbook_category_id');\n }\n\n public function getCategory(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function getPlaybookCategoryId(): ?int\n {\n return $this->getAttribute('playbook_category_id');\n }\n\n public function hasStats(): bool\n {\n return $this->getAttribute('stats') !== null;\n }\n\n public function getStats(): ?Stats\n {\n return $this->getAttribute('stats');\n }\n\n public function stats(): HasOne\n {\n return $this->hasOne(Stats::class);\n }\n\n public function participantStats(): Eloquent\\Relations\\HasManyThrough\n {\n return $this->hasManyThrough(\n Models\\Participant\\ParticipantStats::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantStats(): Eloquent\\Collection\n {\n return $this->getAttribute('participantStats');\n }\n\n public function account()\n {\n return $this->belongsTo(Account::class);\n }\n\n public function contact()\n {\n return $this->belongsTo(Contact::class)->with(['account']);\n }\n\n public function lead()\n {\n return $this->belongsTo(Lead::class)->with(['stage', 'recordType']);\n }\n\n /**\n * @return BelongsTo<Opportunity, self>\n */\n public function opportunity(): BelongsTo\n {\n /** @var BelongsTo<Opportunity, self> */\n return $this->belongsTo(Opportunity::class);\n }\n\n public function stage()\n {\n return $this->belongsTo(Stage::class);\n }\n\n /**\n * @return HasMany<Session>\n */\n public function sessions(): HasMany\n {\n return $this->hasMany(Session::class);\n }\n\n /**\n * @return HasMany|ParticipantSpeech[]|Eloquent\\Collection\n */\n public function participantSpeeches()\n {\n return $this->hasMany(ParticipantSpeech::class);\n }\n\n public function getParticipantSpeeches(): Eloquent\\Collection\n {\n return $this->getAttribute('participantSpeeches');\n }\n\n /**\n * @return HasMany|Log[]|Eloquent\\Collection\n */\n public function logs()\n {\n return $this->hasMany(Log::class);\n }\n\n /**\n * @return HasMany|Moment[]|Eloquent\\Collection\n */\n public function moments()\n {\n return $this->hasMany(Moment::class);\n }\n\n /**\n * @return HasMany|Note[]|Eloquent\\Collection\n */\n public function notes()\n {\n return $this->hasMany(Note::class);\n }\n\n /**\n * @return Eloquent\\Collection|Note[]\n */\n public function getNotes(): Eloquent\\Collection\n {\n return $this->getAttribute('notes');\n }\n\n /**\n * @return HasMany|Message[]|Eloquent\\Collection\n */\n public function messages()\n {\n return $this->hasMany(Message::class);\n }\n\n public function coachingMessages(): HasMany\n {\n return $this->hasMany(Message::class)\n ->where('is_private', 1);\n }\n\n public function getCoachingMessages(): Eloquent\\Collection\n {\n return $this->getAttribute('coachingMessages');\n }\n\n public function participants(): HasMany\n {\n return $this->hasMany(Participant::class);\n }\n\n public function getSnapshots(): Eloquent\\Collection\n {\n return $this->getAttribute('snapshots');\n }\n\n /** @return HasMany<Track> */\n public function tracks(): HasMany\n {\n return $this->hasMany(Track::class);\n }\n\n public function tracksWithTelephony(): HasMany\n {\n return $this->hasMany(Track::class)->whereNotNull('telephony_provider_id');\n }\n\n public function getTracksWithTelephony(): Eloquent\\Collection\n {\n return $this->getAttribute('tracksWithTelephony');\n }\n\n /** @return Collection|Track[] */\n public function getTracks(): Eloquent\\Collection\n {\n return $this->getAttribute('tracks');\n }\n\n public function masterTrack(): HasOne\n {\n return $this->hasOne(Track::class)->where('is_master', 1)\n ->whereIn('format', [Track::FORMAT_WAV, Track::FORMAT_M3U8])\n ->latest();\n }\n\n public function getMasterTrack(): ?Track\n {\n /** @var Track|null */\n return $this->getAttribute('masterTrack');\n }\n\n public function transcription(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Transcription::class, 'transcription_id');\n }\n\n public function findTranscriptionPromptSummaries(): Collection\n {\n $transcriptionId = $this->getTranscriptionId();\n if (is_null($transcriptionId)) {\n return new Collection();\n }\n\n return Models\\AiPrompt::query()\n ->where('transcription_id', $transcriptionId)\n ->get();\n }\n\n public function getTranscription(): Transcription\n {\n return $this->getAttribute('transcription');\n }\n\n public function hasTranscription(): bool\n {\n return $this->getAttribute('transcription') !== null;\n }\n\n public function setTranscriptionId(int $transcriptionId): Activity\n {\n $this->setAttribute('transcription_id', $transcriptionId);\n\n return $this;\n }\n\n public function unsetTranscriptionId(): self\n {\n $this->setAttribute('transcription_id', null);\n\n return $this;\n }\n\n public function getTranscriptionId(): ?int\n {\n return $this->getAttribute('transcription_id');\n }\n\n /** @deprecated */\n public function hasTranscriptionId(): bool\n {\n return $this->getAttribute('transcription_id') !== null;\n }\n\n public function coachRequests()\n {\n return $this->hasMany(CoachRequest::class);\n }\n\n public function availabilityNotifications()\n {\n return $this->hasMany(AvailabilityNotification::class);\n }\n\n public function processingStates()\n {\n return $this->hasMany(Models\\Activity\\ActivityProcessingState::class);\n }\n\n public function uploadSettings()\n {\n return $this->hasMany(ActivityUploadSetting::class);\n }\n\n public function comments()\n {\n return $this->hasMany(Comment::class);\n }\n\n public function getComments(): Eloquent\\Collection\n {\n return $this->getAttribute('comments');\n }\n\n public function visibleComments()\n {\n $rel = $this->hasMany(Comment::class);\n // Doesn't have auth()->user() in some tests, breaks the build\n if ($user = auth()->user()) {\n return $rel->visibleThreads($user->id);\n }\n\n return $rel;\n }\n\n public function snapshots(): HasMany\n {\n return $this->hasMany(Snapshot::class);\n }\n\n public function calendarEvent()\n {\n return $this->belongsTo(CalendarEvent::class);\n }\n\n public function getCalendarEvent(): ?CalendarEvent\n {\n return $this->getAttribute('calendarEvent');\n }\n\n public function latestCoachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class)->latest();\n }\n\n public function playlists(): BelongsToMany\n {\n return $this->belongsToMany(Playlist::class, 'playlist_activities')\n ->withPivot('id', 'uuid', 'user_id', 'start_time', 'end_time')\n ->using(PlaylistActivity::class)\n ->withTimestamps();\n }\n\n public function coachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class);\n }\n\n /**\n * @return Eloquent\\Collection|CoachingFeedback[]\n */\n public function getCoachingFeedback(?int $visibility = null): Eloquent\\Collection\n {\n $feedbacks = $this->coachingFeedbacks();\n if ($visibility !== null) {\n $feedbacks = $feedbacks->where('visibility', $visibility);\n }\n\n return $feedbacks->get();\n }\n\n /** @return Eloquent\\Collection<int, PlaylistActivity> */\n public function favoritedBy(User $user): Eloquent\\Collection\n {\n return $this->favorites()->where('user_id', $user->getId())->get();\n }\n\n /**\n * Checks whether consumer has added this activity to their favorites playlist\n * In addition a default playlist gets created if not already present\n */\n public function wasFavoritedBy(User $user): bool\n {\n $playlist = $user->favoritePlaylist();\n\n return $playlist\n ->activities()\n ->where('activity_id', '=', $this->getId())\n ->exists();\n }\n\n /**\n * @return HasMany<PlaylistActivity>\n */\n public function playlistActivities(): HasMany\n {\n return $this->hasMany(PlaylistActivity::class);\n }\n\n /**\n * @return HasManyThrough<Playlist>\n */\n public function favoritePlaylists(): HasManyThrough\n {\n return $this->hasManyThrough(\n Playlist::class,\n PlaylistActivity::class,\n 'activity_id',\n 'id',\n 'id',\n 'playlist_id'\n )->where('is_default', 1);\n }\n\n /**\n * @return Eloquent\\Collection<int, Playlist>\n */\n public function getFavoritePlaylists(): Eloquent\\Collection\n {\n return $this->getAttribute('favoritePlaylists');\n }\n\n /**\n * Get activities from the default/favorite playlist\n *\n * @return Eloquent\\Builder|static\n */\n public function favorites()\n {\n return $this->playlistActivities()->whereHas('playlist', function ($query) {\n $query->where('is_default', 1);\n });\n }\n\n /**\n * @return Model|SubscriptionSet|null|object\n */\n public function subscribedBy(User $user)\n {\n if ($this->prospect === null) {\n return null;\n }\n\n return SubscriptionSet::select('activity_subscription_sets.*')\n ->where('user_id', $user->id)\n ->join('activity_subscriptions', function ($join) {\n $join\n ->on('subscription_set_id', '=', 'activity_subscription_sets.id');\n\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $join\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $join\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $join\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $join\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n }\n })\n ->first();\n }\n\n /**\n * @return array|Eloquent\\Builder[]|Eloquent\\Collection|SubscriptionSet[]\n */\n public function subscribers()\n {\n if ($this->prospect === null) {\n return [];\n }\n\n return SubscriptionSet::with(['subscriptions', 'user'])\n ->whereHas('subscriptions', function ($query) {\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $query\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $query\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $query\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $query\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n } else {\n // Nothing to join on?\n // refactor - use Jiminny specific exception\n throw new InvalidArgumentException('Cannot join on a specific customer filter.');\n }\n })\n ->whereHas('user', function ($query) {\n $query\n ->where('team_id', $this->user->team_id)\n ->where('status', User::STATUS_ACTIVE);\n })\n ->get();\n }\n\n /**\n * @return HasMany|Builder|Eloquent\\Collection|Play[]\n */\n public function plays()\n {\n return $this->hasMany(Play::class);\n }\n\n public function getPlays(): Eloquent\\Collection\n {\n return $this->getAttribute('plays');\n }\n\n public function playsBy(User $user)\n {\n /** @var Builder $builder */\n $builder = $this->plays()->where('user_id', $user->id);\n\n return $builder->get();\n }\n\n /**\n * Check if activity was played by a user\n */\n public function wasPlayedBy(User $user): bool\n {\n return $this->plays()->where('user_id', $user->id)->exists();\n }\n\n public function shares()\n {\n return $this->hasMany(Share::class);\n }\n\n /** @return BelongsTo<Participant, self> */\n public function from(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'from_participant_id');\n }\n\n /** @return BelongsTo<Participant, self> */\n public function to(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'to_participant_id');\n }\n\n /**\n * Get all of the connections through the participants.\n */\n public function connections()\n {\n return $this->hasManyThrough(\n Connection::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getConnections(): Eloquent\\Collection\n {\n return $this->getAttribute('connections');\n }\n\n /**\n * Get all of the shares through the participants.\n */\n public function participantShares()\n {\n return $this->hasManyThrough(\n Participant\\Share::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantShares(): Eloquent\\Collection\n {\n return $this->getAttribute('participantShares');\n }\n\n public function topicTriggers(): HasMany\n {\n return $this->hasMany(TopicTrigger::class);\n }\n\n public function activityScorecardRuleTriggers(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRuleTrigger::class);\n }\n\n public function activityScorecardRules(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRule::class);\n }\n\n public function questions(): HasMany\n {\n return $this->hasMany(Question::class);\n }\n\n /**\n * Get all the custom data attached to it.\n */\n public function data(): HasMany\n {\n return $this->hasMany(FieldData::class);\n }\n\n public function getData(): Eloquent\\Collection\n {\n /** @var Eloquent\\Collection */\n return $this->getAttribute('data');\n }\n\n #[Scope]\n protected function heldBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('actual_start_date', '>=', $from)\n ->where('actual_end_date', '<=', $until);\n }\n\n #[Scope]\n protected function scheduledBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('scheduled_start_date', '>=', $from)\n ->where('scheduled_end_date', '<=', $until);\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function forTeam(Builder $query, int $teamId): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas('user', static function (Builder $query) use ($teamId): void {\n $query->where('team_id', $teamId);\n });\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function inOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query\n ->where('is_closed', false)\n ->where('deleted_at', '=', null),\n );\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function notInOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->where(\n static fn (Builder $query): Builder => $query->whereNull('opportunity_id')\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->where('is_closed', true),\n )\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->withTrashed()->where('deleted_at', '!=', null),\n ),\n );\n }\n\n /**\n * Finds a participant and updates it with data. If participant doesn't exist creates a new participant from data.\n *\n * @param array $data participant data used to identify the participant and update it\n * @param bool $enterRoom true if participant is entering the room. false if we just want to update some participant data\n * @param Carbon|null $enterTime if $enterNow is true then this is the join time when the actual enter has occurred\n */\n public function updateOrCreateParticipant(\n array $data,\n bool $enterRoom = true,\n ?Carbon $enterTime = null,\n bool $nameMatching = false,\n ): Participant {\n $search = [];\n $participant = null;\n\n if (isset($data['user_id'])) {\n // Check if they already exist based on their ID.\n $search['user_id'] = $data['user_id'];\n } elseif (isset($data['provider_id'])) {\n $search['provider_id'] = $data['provider_id'];\n } elseif ($nameMatching && isset($data['name'])) {\n $search['name'] = $data['name'];\n }\n\n if (! empty($data['email'])) {\n $search['email'] = $data['email'];\n\n // If we have their email, this should be unique enough to lookup (e.g. calendar event based participant).\n unset($search['provider_id']);\n }\n\n // Search by phone number only in case nothing else is available to search by.\n if (array_key_exists('phone_number', $data) && empty($search)) {\n $search['phone_number'] = $data['phone_number'];\n }\n\n if (! empty($search)) {\n // Do a lookup now to see if we have a match on the provided data.\n $lookup = array_map(static function ($key, $value): array {\n return [$key, $value];\n }, array_keys($search), $search);\n\n $participant = $this->participants()->withTrashed()->where($lookup)->first();\n }\n\n // Do a partial match on the name and search in the team members.\n if (! $participant instanceof Participant && $nameMatching && ! empty($data['name'])) {\n $participantMatcher = app(MeetingBot\\Service\\ParticipantMatcher::class);\n\n if (! $participantMatcher instanceof MeetingBot\\Service\\ParticipantMatcher) {\n throw new LogicException('Expecting ParticipantMatcher service instance');\n }\n\n $participant = $participantMatcher->match($this, $data['name']);\n\n // If we've found good participant, avoid data overwrite in `$participant->fill($data)` below.\n if ($participant instanceof Models\\Participant && $participant->hasName()) {\n unset($data['name']); // Thoughts: should we unset also $data['user_id'] and $data['email'] ?\n }\n }\n\n if (! $participant instanceof Participant) {\n // If no match, create a new participant.\n if (empty($search)) {\n $participant = $this->participants()->create();\n } else {\n // If no match, create a new participant but avoid creating duplicates\n $participant = $this->participants()->withTrashed()->firstOrNew($search);\n }\n }\n\n // If we have just recycled a deleted participant\n if ($participant->trashed()) {\n $participant->deleted_at = null;\n }\n\n // Deal with the case when calendar syncs the event while it's in progress.\n // We should prevent change of the participant name, because speeches mapping will fail.\n if ($enterRoom === false\n && $this->isInProgress()\n && $participant->hasName()\n && isset($data['name'])\n && $data['name'] !== $participant->getName()\n ) {\n unset($data['name']);\n }\n\n // Upsert with new data.\n $participant->fill($data);\n\n if ($enterRoom) {\n if ($enterTime === null) {\n $enterTime = now();\n }\n\n // Participant enters room for the first time\n if ($participant->enter_time === null) {\n $participant->enter_time = $enterTime;\n }\n\n // If there is an exit time and it's prior to new enter_time\n if ($participant->exit_time && $participant->exit_time->lt($enterTime)) {\n // Participant has re-joined\n $participant->exit_time = null;\n }\n }\n\n $participant->save();\n\n return $participant;\n }\n\n /**\n * Updates participant CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n * @param Participant $participant participant the CRM data is associated with\n */\n public function updateParticipantCrmData(array $records, Participant $participant): void\n {\n // Extract the records.\n [$lead, , , $contact] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForParticipant($lead, $contact);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n if (! $participant->hasName()) {\n $participant->name = $lead->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $lead->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $lead->phone;\n }\n\n $participant->lead_id = $lead->id;\n $participant->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n if (! $participant->hasName()) {\n $participant->name = $contact->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $contact->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $contact->phone;\n }\n\n $participant->contact_id = $contact->id;\n $participant->save();\n }\n }\n\n /**\n * Updates activity CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n */\n public function updateActivityCrmData(array $records): void\n {\n // Extract the records.\n [$lead, $account, $opportunity, $contact, $stage] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForActivity($lead, $contact, $account);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n if ($this->account_id === null && $this->contact_id === null && $this->lead_id === null) {\n $this->lead_id = $lead->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n $this->save();\n }\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Don't trust previous matched account_id as it might have been changed in the CRM\n if ($account && $account->id !== $this->account_id) {\n $this->account_id = $account->id;\n }\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($opportunity && $this->opportunity_id !== $opportunity->id) {\n $this->opportunity_id = $opportunity->id;\n }\n\n if ($opportunity && $this->value !== $opportunity->value) {\n $this->value = $opportunity->value;\n }\n\n // Always set contact_id when available, regardless of account_id status\n if ($this->contact_id === null && $contact) {\n $this->contact_id = $contact->id;\n }\n\n $this->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Account && $this->account_id === null) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Update the account and opportunity on the activity record if possible.\n $this->account_id = $account->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($this->opportunity_id === null && $opportunity) {\n $this->opportunity_id = $opportunity->id;\n $this->value = $opportunity->value;\n }\n\n $this->save();\n }\n }\n\n public function getActivityProspectData(): array\n {\n return [\n 'lead' => $this->lead_id,\n 'contact' => $this->contact_id,\n 'account' => $this->account_id,\n 'opportunity' => $this->opportunity_id,\n 'stage' => $this->stage_id,\n ];\n }\n\n public function isOrganizer(User $user): bool\n {\n return $this->user_id && $this->user_id === $user->id;\n }\n\n public function isJoinable(): bool\n {\n return \\in_array($this->status, [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n ], true);\n }\n\n public function isAttemptedForBotJoin(): bool\n {\n return in_array($this->getAttribute('status'), self::MEETING_BOT_JOIN_ATTEMPTED, true);\n }\n\n /**\n * Check if the activity can be saved to CRM (manual or autolog)\n */\n public function isLoggable(): bool\n {\n if ($this->getUser()->getTeam()->hasFeature(FeatureEnum::SIDEKICK_SETTINGS)) {\n $sidekickService = app(SidekickService::class);\n\n if (! $sidekickService->isSidekickEnabledForUser($this->getUser())) {\n return false;\n }\n }\n\n // If we don't know the activity type, don't try to log.\n if ($this->playbook_category_id === null) {\n return false;\n }\n\n if ($this->user->crm_required === false) {\n return false;\n }\n\n // Don't prompt for internal meetings.\n if ($this->is_internal) {\n return false;\n }\n\n // If we don't know who we are trying to log to, don't try to log.\n if ($this->prospect === null) {\n return false;\n }\n\n $validStatus = false;\n switch ($this->type) {\n case self::TYPE_SOFTPHONE:\n case self::TYPE_SOFTPHONE_INBOUND:\n $validStatus = true;\n\n break;\n case self::TYPE_CONFERENCE:\n $validStatus = in_array($this->status, [\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n ], true);\n\n break;\n case self::TYPE_SMS_INBOUND:\n case self::TYPE_SMS_OUTBOUND:\n $validStatus = in_array($this->status, [\n self::STATUS_QUEUED,\n self::STATUS_SENT,\n self::STATUS_UNDELIVERED,\n self::STATUS_DELIVERED,\n self::STATUS_RECEIVED,\n ], true);\n\n break;\n }\n\n // Depending on the activity channel, we should not try to log.\n return $validStatus;\n }\n\n public function isScheduled(): bool\n {\n return $this->status === self::STATUS_SCHEDULED;\n }\n\n public function scheduledDuration(): int\n {\n if ($this->scheduled_start_time && $this->scheduled_end_time) {\n return $this->scheduled_end_time->timestamp - $this->scheduled_start_time->timestamp;\n }\n\n return 0;\n }\n\n public function isPending(): bool\n {\n return $this->status === self::STATUS_PENDING;\n }\n\n public function isCompleted(): bool\n {\n return $this->status === self::STATUS_COMPLETED;\n }\n\n public function isRinging(): bool\n {\n return $this->status === self::STATUS_RINGING;\n }\n\n public function isInProgress(): bool\n {\n return $this->status === self::STATUS_IN_PROGRESS;\n }\n\n public function isBusy(): bool\n {\n return $this->status === self::STATUS_BUSY;\n }\n\n public function isNoAnswer(): bool\n {\n return $this->status === self::STATUS_NO_ANSWER;\n }\n\n public function isFailed(): bool\n {\n return $this->status === self::STATUS_FAILED;\n }\n\n public function isCancelled(): bool\n {\n return $this->status === self::STATUS_CANCELLED;\n }\n\n public function hasEnded(int $gracePeriodMinutes = 15): bool\n {\n if ($this->isCompleted()) {\n return true;\n }\n\n if (($this->isFailed() || $this->isCancelled()) && $this->hasScheduledEndTime()) {\n return $this->getScheduledEndTime()->addMinutes($gracePeriodMinutes)->isPast();\n }\n\n return false;\n }\n\n public function hasStarted(): bool\n {\n return $this->hasActualStartTime();\n }\n\n public function isOngoing(): bool\n {\n return $this->hasActualStartTime() && ! $this->hasActualEndTime();\n }\n\n public function isTypeSmsInbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_INBOUND;\n }\n\n public function isTypeSmsOutbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_OUTBOUND;\n }\n\n public function isTypeSoftPhone(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE;\n }\n\n public function isTypeSoftphoneInbound(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE_INBOUND;\n }\n\n public function isTypeConference(): bool\n {\n return $this->getType() === self::TYPE_CONFERENCE;\n }\n\n /**\n * Get a conference elapsed time in seconds.\n *\n * @return int seconds count\n */\n public function secondsTimeElapsed(): int\n {\n if (empty($this->actual_start_time)) {\n return 0;\n }\n\n // Get number of seconds since conference actual start time\n return (int) abs(Carbon::now()->diffInRealSeconds($this->actual_start_time));\n }\n\n /**\n * Get a conference elapsed time formatted as \"1:30:20\" if more than 1 hour or \"30:20\" otherwise.\n */\n public function formattedTimeElapsed(): string\n {\n // Get number of seconds since conference actual start time.\n $elapsedSeconds = $this->secondsTimeElapsed();\n $elapsedTime = Carbon::createFromTimestampUTC($elapsedSeconds);\n\n // Format conference start time.\n return $elapsedTime->format($elapsedSeconds < 3600 ? 'i:s' : 'G:i:s');\n }\n\n public function wasScheduled(): bool\n {\n return $this->calendarEvent !== null || in_array($this->getSource(), [self::SOURCE_OUTLOOK, self::SOURCE_GOOGLE]);\n }\n\n public function isInstant(): bool\n {\n return ! $this->wasScheduled();\n }\n\n /**\n * GETTERS AND SETTERS FOLLOW BELOW\n */\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getFromParticipantId(): ?int\n {\n return $this->getAttribute('from_participant_id');\n }\n\n public function getFromParticipant(): ?Participant\n {\n return $this->getAttribute('from');\n }\n\n public function getToParticipantId(): ?int\n {\n return $this->getAttribute('to_participant_id');\n }\n\n public function getToParticipant(): ?Participant\n {\n return $this->getAttribute('to');\n }\n\n public function hasScheduledStartTime(): bool\n {\n return $this->getAttribute('scheduled_start_time') !== null;\n }\n\n public function getScheduledStartTime(): ?Carbon\n {\n return $this->getAttribute('scheduled_start_time');\n }\n\n public function setScheduledStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_start_time', $dateTime);\n\n return $this;\n }\n\n public function getScheduledEndTime(): ?DateTimeInterface\n {\n return $this->getAttribute('scheduled_end_time');\n }\n\n public function hasScheduledEndTime(): bool\n {\n return $this->getAttribute('scheduled_end_time') !== null;\n }\n\n public function setScheduledEndTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_end_time', $dateTime);\n\n return $this;\n }\n\n public function getActualStartTime(): ?Carbon\n {\n return $this->getAttribute('actual_start_time');\n }\n\n public function hasActualStartTime(): bool\n {\n return $this->getAttribute('actual_start_time') !== null;\n }\n\n public function getActualEndTime(): ?Carbon\n {\n return $this->getAttribute('actual_end_time');\n }\n\n public function hasActualEndTime(): bool\n {\n return $this->getAttribute('actual_end_time') !== null;\n }\n\n public function getType(): ?string\n {\n return $this->getAttribute('type');\n }\n\n public function getStatus(): string\n {\n return $this->getAttribute('status');\n }\n\n public function setStatus(string $status): self\n {\n $this->setAttribute('status', $status);\n\n return $this;\n }\n\n public function setActualStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('actual_start_time', $dateTime);\n\n return $this;\n }\n\n public function setActualEndTime(DateTimeInterface $dateTime, bool $shouldUpdateDuration = true): self\n {\n $this->setAttribute('actual_end_time', $dateTime);\n\n if (! $shouldUpdateDuration) {\n return $this;\n }\n\n return $this->updateDuration();\n }\n\n public function updateDuration(): self\n {\n if (! $this->hasActualStartTime() || ! $this->hasActualEndTime()) {\n return $this;\n }\n\n return $this->setDuration(\n (int) abs($this->getActualStartTime()->diffInRealSeconds($this->getActualEndTime()))\n );\n }\n\n public function setDuration(int $duration): self\n {\n $this->setAttribute('duration', $duration);\n\n return $this;\n }\n\n public function getRecordingState(): string\n {\n return $this->getAttribute('recording_state');\n }\n\n public function isRecordingState(string $recordingState): bool\n {\n return $this->getRecordingState() === $recordingState;\n }\n\n public function setRecordingState(string $recordingState): self\n {\n $this->setAttribute('recording_state', $recordingState);\n\n return $this;\n }\n\n public function hasActivityType(): bool\n {\n return $this->getAttribute('category') !== null;\n }\n\n public function getActivityType(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function setActivityType(int $playbookCategoryId): self\n {\n $this->setAttribute('playbook_category_id', $playbookCategoryId);\n\n return $this;\n }\n\n public function hasStage(): bool\n {\n return $this->getAttribute('stage') !== null;\n }\n\n public function getStage(): ?Stage\n {\n return $this->getAttribute('stage');\n }\n\n public function getStageId(): ?int\n {\n return $this->getAttribute('stage_id');\n }\n\n public function setStageId(?int $stageId): void\n {\n $this->setAttribute('stage_id', $stageId);\n }\n\n public function hasOpportunity(): bool\n {\n return $this->getAttribute('opportunity') !== null;\n }\n\n public function getOpportunity(): ?Opportunity\n {\n return $this->getAttribute('opportunity');\n }\n\n public function getOpportunityId(): ?int\n {\n return $this->getAttribute('opportunity_id');\n }\n\n public function setOpportunityId(?int $opportunityId): void\n {\n $this->setAttribute('opportunity_id', $opportunityId);\n }\n\n public function hasContact(): bool\n {\n return $this->getAttribute('contact') !== null;\n }\n\n public function getContact(): ?Contact\n {\n return $this->getAttribute('contact');\n }\n\n public function getContactId(): ?int\n {\n return $this->getAttribute('contact_id');\n }\n\n public function setContactId(?int $contactId): void\n {\n $this->setAttribute('contact_id', $contactId);\n }\n\n public function hasLead(): bool\n {\n return $this->getAttribute('lead') !== null;\n }\n\n public function getLead(): ?Lead\n {\n return $this->getAttribute('lead');\n }\n\n public function getLeadId(): ?int\n {\n return $this->getAttribute('lead_id');\n }\n\n public function setLeadId(?int $leadId): void\n {\n $this->setAttribute('lead_id', $leadId);\n }\n\n public function hasAccount(): bool\n {\n return $this->getAttribute('account') !== null;\n }\n\n public function getAccount(): ?Account\n {\n return $this->getAttribute('account');\n }\n\n public function getAccountId(): ?int\n {\n return $this->getAttribute('account_id');\n }\n\n public function setAccountId(?int $accountId): void\n {\n $this->setAttribute('account_id', $accountId);\n }\n\n /**\n * This method exists to avoid confusion using ->participants() or ->participants. Use the getter instead.\n *\n * @return Collection<int, Participant>|Participant[]\n */\n public function getParticipants(): Collection\n {\n return $this->participants;\n }\n\n /**\n * @deprecated use ParticipantRepository::findParticipantRoomOwner() instead\n */\n public function findParticipantRoomOwner(): ?Participant\n {\n $roomOwnerId = $this->getUserId();\n\n return $this->getParticipants()\n ->filter(static fn (Participant $participant): bool => $participant->isSameUserId($roomOwnerId))\n ->first();\n }\n\n public function hasCrmProviderId(): bool\n {\n return $this->getAttribute('crm_provider_id') !== null;\n }\n\n public function getCrmProviderId(): ?string\n {\n return $this->getAttribute('crm_provider_id');\n }\n\n public function setCrmProviderId(?string $crmProviderId): void\n {\n $this->setAttribute('crm_provider_id', $crmProviderId);\n }\n\n public function getUserId(): ?int\n {\n return $this->getAttribute('user_id');\n }\n\n public function hasUser(): bool\n {\n return $this->user()->exists();\n }\n\n public function getUser(): User\n {\n return $this->getAttribute('user');\n }\n\n public function getCreatedAt(): Carbon\n {\n return $this->getAttribute('created_at');\n }\n\n public function isInFiniteState(): bool\n {\n return $this->isFiniteState($this->getStatus());\n }\n\n public function isFiniteState(string $status): bool\n {\n $finiteStates = self::FINITE_STATES[$this->getType()] ?? [];\n\n return in_array($status, $finiteStates, true);\n }\n\n public function getParticipant(Authenticatable $user): Participant\n {\n return $this->findParticipant($user);\n }\n\n public function findParticipant(Authenticatable $user): ?Participant\n {\n if ($user instanceof User) {\n /** @var User $user */\n return $this->participants()->where('user_id', '=', $user->getId())->first();\n }\n\n throw new LogicException(sprintf('Unsupported Authenticatable implementation %s', get_class($user)));\n }\n\n public function hasLanguageCode(): bool\n {\n return $this->getAttribute('language') !== null;\n }\n\n public function getLanguageCode(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('language');\n }\n\n public function getLanguageCodeHyphenated(): string\n {\n return str_replace('_', '-', $this->getLanguageCode() ?? '');\n }\n\n public function getLanguageCodeLocale(): string\n {\n [ $language ] = explode('_', $this->getLanguageCode() ?? '');\n\n return $language;\n }\n\n public function setLanguageCode(string $value): self\n {\n return $this->setAttribute('language', $value);\n }\n\n public function hasSource(): bool\n {\n return $this->getAttribute('source') !== null;\n }\n\n public function setSource(?string $source): self\n {\n return $this->setAttribute('source', $source);\n }\n\n public function isSource(string $source): bool\n {\n return $this->getAttribute('source') === $source;\n }\n\n public function getSource(): ?string\n {\n return $this->getAttribute('source');\n }\n\n public function isSourceGong(): bool\n {\n return $this->isSource(self::SOURCE_GONG);\n }\n\n public function getExternalId(): ?string\n {\n return $this->getAttribute('external_id');\n }\n\n public function setExternalId(?string $externalId): self\n {\n return $this->setAttribute('external_id', $externalId);\n }\n\n public function hasExternalId(): bool\n {\n return $this->getAttribute('external_id') !== null;\n }\n\n public function getProvider(): string\n {\n return $this->getAttribute('provider');\n }\n\n public function hasTelephonyProviderId(): bool\n {\n return $this->getAttribute('telephony_provider_id') !== null;\n }\n\n public function getTelephonyProviderId(): ?string\n {\n return $this->getAttribute('telephony_provider_id');\n }\n\n public function setTelephonyProviderId(?string $telephonyProviderId): self\n {\n return $this->setAttribute('telephony_provider_id', $telephonyProviderId);\n }\n\n public function getLocation(): ?string\n {\n return $this->getAttribute('location');\n }\n\n public function setLocation(?string $location): self\n {\n return $this->setAttribute('location', $location);\n }\n\n public function isDeleted(): bool\n {\n return $this->getAttribute('deleted_at') !== null;\n }\n\n /**\n * Check if activity recording is on and activity status is not one of the failed statuses.\n */\n public function canReviewActivity(): bool\n {\n $failedStatuses = self::$enumFailedStatuses;\n\n return (! in_array($this->recording_state, [self::RECORDING_OFF, self::RECORDING_STOPPED], true) &&\n ! in_array($this->status, $failedStatuses, true));\n }\n\n public function hasReasonCodeBotKicked(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_MEETING_BOT_KICKED);\n }\n\n public function hasReasonCodeNotCompliant(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_CONSENT_DENIED);\n }\n\n public function hasTopicTriggers(): bool\n {\n return $this->topicTriggers()->count() !== 0;\n }\n\n public function getTopicTriggers(): Collection\n {\n return $this->topicTriggers;\n }\n\n public function getTopicTriggersSorted(): Collection\n {\n $this->loadMissing([\n 'topicTriggers.participant',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme',\n ]);\n\n return $this->topicTriggers\n ->sortBy([\n 'playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme.sort',\n 'playbackThemeTopicTrigger.playbackThemeTopic.sort',\n 'playbackThemeTopicTrigger.sort',\n ]);\n }\n\n public function hasQuestions(): bool\n {\n return $this->questions()->exists();\n }\n\n public function getQuestions(): Collection\n {\n return $this->questions;\n }\n\n public function hasValue(): bool\n {\n return $this->getAttribute('value') !== null;\n }\n\n public function getValue(): ?float\n {\n return $this->getAttribute('value');\n }\n\n public function setValue(?float $value): void\n {\n $this->setAttribute('value', $value);\n }\n\n public function transitionTo(string $newState, callable $callback, ?int $timeout = null): self\n {\n $newState = $this->getWorkflowStateFor(\n $this->getType(),\n $newState\n );\n\n return $this->traitTransitionTo($newState, $callback, $timeout);\n }\n\n public function getWorkflowState(): string\n {\n return $this->getWorkflowStateFor(\n $this->getType(),\n $this->getStatus()\n );\n }\n\n public function getActivityProviderDisplayName(): string\n {\n return \\Cache::remember('activity_provider_display_name-' . $this->getProvider(), 60 * 60 * 24, function () {\n $activityProviderRegistry = app()->make(ActivityProviderRegistry::class);\n\n try {\n return $activityProviderRegistry->get($this->getProvider())->getDisplayName();\n } catch (Exception $exception) {\n return ucfirst($this->getProvider());\n }\n });\n }\n\n private function getWorkflowStateFor(string $activityChannel, string $activityStatus): string\n {\n return sprintf(\n '%s::%s',\n $activityChannel,\n $activityStatus\n );\n }\n\n public function getWorkflow(): array\n {\n $map = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_SCHEDULED => [\n self::STATUS_PENDING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_PENDING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_RINGING => [\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_IN_PROGRESS,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_RINGING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_NO_ANSWER,\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n ];\n\n return collect($map)\n ->mapWithKeys(function (array $currentStates, string $activityChannel): array {\n return [\n $activityChannel => collect($currentStates)\n ->mapWithKeys(function (array $possibleStates, $currentState) use ($activityChannel): array {\n $transitionName = $this->getWorkflowStateFor($activityChannel, $currentState);\n\n return [\n $transitionName => array_map(function (string $newState) use ($activityChannel) {\n return $this->getWorkflowStateFor($activityChannel, $newState);\n }, $possibleStates),\n ];\n }),\n ];\n })\n ->reduce(static function (array $carry, Collection $item): array {\n return array_merge($carry, $item->all());\n }, []);\n }\n\n public function hasPosterPath(): bool\n {\n return $this->getAttribute('poster_path') !== null;\n }\n\n public function getPosterPath(): ?string\n {\n return $this->getAttribute('poster_path');\n }\n\n /**\n * Take into account all recording settings and determine if we need to record this activity or not.\n */\n public function shouldRecord(): bool\n {\n return $this->determineRecordingReasonCode() === null;\n }\n\n public function determineRecordingReasonCode(): ?int\n {\n // Conference specific decisions.\n if ($this->isTypeConference()) {\n // If they have manually overridden the recording setting to not record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === false) {\n return self::FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE;\n }\n\n // If they have manually overridden the recording setting to record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === true) {\n return null;\n }\n\n // If their team has disabled recording meetings, don't record.\n if ($this->user->team->isConferenceRecordPreferenceDisabled()) {\n return self::FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED;\n }\n\n // If the host has disabled recording meetings, don't record.\n if ($this->user->checkConferenceRecordPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED;\n }\n\n // If it was marked internal...\n if ($this->is_internal) {\n // and their team has disabled recording internal meetings, don't record.\n if (\n $this->user->team->isConferenceRecordPreferenceEnabled()\n && ! $this->user->team->isConferenceRecordInternalPreferenceEnabled()\n ) {\n return self::FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED;\n }\n\n // and the host has disabled recording internal meetings, don't record.\n if ($this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED;\n }\n }\n\n // If it was not scheduled and they disabled internal meetings, we cannot determine if it was internal.\n if ($this->wasScheduled() === false && $this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED;\n }\n }\n\n return null;\n }\n\n public function getRecordingReasonCode(): int\n {\n return $this->getAttribute('recording_reason_code');\n }\n\n public function setRecordingReasonCode(int $recordingReasonCode): self\n {\n $this->setAttribute('recording_reason_code', $recordingReasonCode);\n\n return $this;\n }\n\n // Not used today.\n public function getRecordingReasonString(): ?string\n {\n if ($this->hasRecordingReasonCompliancePrompted()) {\n return Team::COMPLIANCE_MODE_RECORDING_PROMPT;\n }\n\n if ($this->hasRecordingReasonComplianceRestricted()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT;\n }\n\n if ($this->hasRecordingReasonComplianceRestrictedToOneSideRecording()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT_ONE_SIDE;\n }\n\n return null;\n }\n\n public function hasRecordingReasonComplianceRestricted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT);\n }\n\n public function hasRecordingReasonCompliancePrompted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_PROMPT);\n }\n\n public function hasRecordingReasonComplianceRestrictedToOneSideRecording(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE);\n }\n\n public function getAudioTrack(): ?Track\n {\n /** @var Track|null */\n return $this->tracks()\n ->where('type', '=', Track::TYPE_AUDIO)\n ->first();\n }\n\n public function activeParticipants(): HasMany\n {\n return $this->hasMany(Participant::class)->active();\n }\n\n public function getActiveParticipants(): Eloquent\\Collection\n {\n return $this->getAttribute('activeParticipants');\n }\n\n public function crm(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Configuration::class, 'crm_configuration_id');\n }\n\n public function activitySummaryLogs(): HasMany\n {\n return $this->hasMany(ActivitySummaryLog::class);\n }\n\n public function getCrm(): ?Configuration\n {\n return $this->getAttribute('crm');\n }\n\n public function hasCrmConfiguration(): bool\n {\n return $this->getAttribute('crm') !== null;\n }\n\n public function isProcessed(): ?bool\n {\n return $this->getAttribute('is_processed');\n }\n\n public function hasRecordingPrompt(): bool\n {\n return $this->getAttribute('has_recording_prompt') === true;\n }\n\n public function isOnAir(): bool\n {\n return $this->getAttribute('on_air') === self::ON_AIR_READY || $this->getAttribute('on_air') === self::ON_AIR_STREAMING;\n }\n\n public function setOnAir(int $onAir): self\n {\n $this->setAttribute('on_air', $onAir);\n\n return $this;\n }\n\n public function getOnAir(): ?int\n {\n return $this->getAttribute('on_air');\n }\n\n public function setTitleFromCallData(Call $call): void\n {\n $direction = $call->isOutbound() ? 'to' : 'from';\n\n $party = $this->prospect_name\n ?? $call->getContactName()\n ?? $call->getOtherPartyPhoneNumber()\n ;\n\n $this->update(['title' => sprintf('Call %s %s', $direction, $party)]);\n }\n\n /**\n * @param array{}|array{channels:string|null, format:string|null, type:string|null, status:string|null} $audioParams\n */\n public function createAudioTrack(\n string $telephonyProviderId,\n string $recordingUrl,\n array $audioParams = []\n ): Track {\n return $this->tracks()->updateOrCreate([\n 'telephony_provider_id' => $telephonyProviderId,\n ], [\n 'type' => $audioParams['type'] ?? Track::TYPE_AUDIO,\n 'status' => $audioParams['status'] ?? Track::STATUS_PENDING,\n 'format' => $audioParams['format'] ?? Track::FORMAT_WAV,\n 'provider_content_url' => $recordingUrl,\n 'start_time' => $this->actual_start_time,\n 'end_time' => $this->actual_end_time,\n ]);\n }\n\n public function createTrack(string $telephonyProviderId, array $params): Track\n {\n return $this->tracks()->updateOrCreate(\n [\n 'telephony_provider_id' => $telephonyProviderId,\n ],\n $params\n );\n }\n\n public function createOrganiserParticipant(Call $call): Participant\n {\n $user = $this->getUser();\n\n return $this->updateOrCreateParticipant([\n 'is_ghost' => 0,\n 'name' => $user->name,\n 'email' => $user->email,\n 'phone_number' => phone_e164(null, $call->getUserPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'user_id' => $user->id,\n ], false);\n }\n\n public function createProspectParticipant(Call $call): Participant\n {\n // not null 'name' is mandatory here to create a separate participant with 'nameMatching'\n // in case of the same phone_number with the Organiser\n $useNameMatching = $call->getUserPhoneNumber() === $call->getOtherPartyPhoneNumber();\n $defaultName = $useNameMatching ? '' : null;\n\n return $this->updateOrCreateParticipant(data: [\n 'is_ghost' => 0,\n 'name' => $this->prospect->name ?? $defaultName,\n 'email' => $this->prospect->email ?? null,\n 'phone_number' => phone_e164(null, $call->getOtherPartyPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'contact_id' => $this->contact_id ?? null,\n 'lead_id' => $this->lead_id ?? null,\n ], enterRoom: false, nameMatching: $useNameMatching);\n }\n\n public function updateParticipants(Participant $organiserParticipant, Participant $prospectParticipant): void\n {\n $this->update([\n 'from_participant_id' => $this->isTypeSoftPhone() ? $organiserParticipant->id : $prospectParticipant->id,\n 'to_participant_id' => $this->isTypeSoftPhone() ? $prospectParticipant->id : $organiserParticipant->id,\n ]);\n }\n\n public function hasProspect(): bool\n {\n return $this->getProspectAttribute() !== null;\n }\n\n public function isPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n /** Create a new factory instance for the model. */\n protected static function newFactory(): Factory\n {\n return ActivityFactory::new();\n }\n\n public function getUpdatedAt(): Carbon\n {\n return $this->getAttribute('updated_at');\n }\n\n public function getActivitySummaryLogs(): Eloquent\\Collection\n {\n return $this->getAttribute('activitySummaryLogs');\n }\n\n public function hasProspectActivitySummaryLog(): bool\n {\n return $this->getActivitySummaryLogs()->contains(\n 'relation_type',\n ActivitySummaryLog::RELATION_OBJECT_TYPE_PROSPECT\n );\n }\n\n public function getTeam(): Team\n {\n return $this->getUser()->getTeam();\n }\n\n private function getUpdateCrmDataResolver(): UpdateCrmDataResolverInterface\n {\n $factory = app(UpdateCrmDataResolverFactory::class);\n\n return $factory->create($this);\n }\n\n public function getMeetingTrackProviderId(string $type): string\n {\n $label = match ($type) {\n Track::TYPE_VIDEO => 'v',\n Track::TYPE_AUDIO => 'a',\n default => throw new InvalidArgumentJiminnyException('Invalid track type'),\n };\n\n $startTimestamp = $this->getScheduledStartTime()?->getTimestamp();\n $teamId = $this->getTeam()->getId();\n\n return $this->getTelephonyProviderId() . ':' . $label . ':' . $startTimestamp . ':' . $teamId;\n }\n\n /**\n * Get all consent records associated with this activity\n *\n * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasMany\n */\n public function participantConsents(): HasMany\n {\n return $this->hasMany(Participant\\Consent::class);\n }\n\n public function isDiallerCall(): bool\n {\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return false;\n }\n\n if (! in_array($this->getType(), [self::TYPE_SOFTPHONE, self::TYPE_SOFTPHONE_INBOUND])) {\n return false;\n }\n\n return $this->getProvider() !== self::PROVIDER_TWILIO;\n }\n\n public function getActivityDateWithFallback(): Carbon\n {\n if ($this->getActualStartTime() !== null) {\n return $this->getActualStartTime();\n }\n\n if ($this->getScheduledStartTime() !== null) {\n return $this->getScheduledStartTime();\n }\n\n return $this->getCreatedAt();\n }\n\n public function getCrmType(): ?string\n {\n // Treat uploader activities as conferences\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return Activity::TYPE_CONFERENCE;\n }\n\n return $this->getType();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\nnamespace Jiminny\\Models;\n\nuse Carbon\\Carbon;\nuse Database\\Factories\\ActivityFactory;\nuse DateTimeInterface;\nuse Exception;\nuse Illuminate\\Contracts\\Auth\\Authenticatable;\nuse Illuminate\\Database\\Eloquent;\nuse Illuminate\\Database\\Eloquent\\Attributes\\Scope;\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse Illuminate\\Database\\Eloquent\\Factories\\Factory;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasManyThrough;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasOne;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Auth;\nuse InvalidArgumentException;\nuse Jiminny\\Component\\ElasticSearch;\nuse Jiminny\\Component\\MeetingBot;\nuse Jiminny\\Component\\Model\\BitwiseFlagTrait;\nuse Jiminny\\Component\\PlaybackPage\\Comments\\Services\\ActivityCommentService;\nuse Jiminny\\Component\\Sidekick\\SidekickService;\nuse Jiminny\\Component\\Uuid\\UuidAwareInterface;\nuse Jiminny\\Component\\Workflow;\nuse Jiminny\\Contracts;\nuse Jiminny\\Contracts\\Crm\\ProspectInterface;\nuse Jiminny\\DTO\\ImportCall\\Call;\nuse Jiminny\\Events\\Activities\\ActivityTypeUpdated;\nuse Jiminny\\Events\\Activities\\ActivityUpdated;\nuse Jiminny\\Events\\Activities\\ProspectUpdated;\nuse Jiminny\\Events\\Activities\\StageUpdated;\nuse Jiminny\\Events\\Activities\\StatusUpdated;\nuse Jiminny\\Events\\Activities\\TitleUpdated;\nuse Jiminny\\Exceptions\\InvalidArgumentException as InvalidArgumentJiminnyException;\nuse Jiminny\\Exceptions\\LogicException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Activity\\ActivitySummaryLog;\nuse Jiminny\\Models\\Activity\\ActivityUploadSetting;\nuse Jiminny\\Models\\Activity\\AvailabilityNotification;\nuse Jiminny\\Models\\Activity\\CoachRequest;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\Activity\\Log;\nuse Jiminny\\Models\\Activity\\Message;\nuse Jiminny\\Models\\Activity\\Moment;\nuse Jiminny\\Models\\Activity\\Note;\nuse Jiminny\\Models\\Activity\\ParticipantSpeech;\nuse Jiminny\\Models\\Activity\\Play;\nuse Jiminny\\Models\\Activity\\Question;\nuse Jiminny\\Models\\Activity\\Share;\nuse Jiminny\\Models\\Activity\\Snapshot;\nuse Jiminny\\Models\\Activity\\Stats;\nuse Jiminny\\Models\\Activity\\SubscriptionSet;\nuse Jiminny\\Models\\Activity\\TopicTrigger;\nuse Jiminny\\Models\\Activity\\Transcription;\nuse Jiminny\\Models\\Calendar\\CalendarEvent;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\FieldData;\nuse Jiminny\\Models\\ElasticSearch\\ActivityElasticSearchTrait;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Participant\\Connection;\nuse Jiminny\\Models\\Playlist\\Activity as PlaylistActivity;\nuse Jiminny\\Services\\Activity\\ActivityProviderRegistry;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataByStrategy;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverFactory;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverInterface;\nuse Jiminny\\Traits\\Enums;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Jiminny\\Utils\\CurrencyFormatter;\nuse NumberFormatter;\n\nuse function in_array;\n\n/**\n * Jiminny\\Models\\Activity\n *\n * @property null|int $auto_score filled from ES hydrator, not in DB!\n * @property-read Account|null $account\n * @property-read CalendarEvent|null $calendarEvent\n * @property-read Contact|null $contact\n * @property-read Lead|null $lead\n * @property-read Opportunity|null $opportunity\n * @property-read Stage|null $stage\n * @property int $id\n * @property mixed|null $uuid\n * @property string|null $source\n * @property string|null $external_id\n * @property string $provider\n * @property string|null $location\n * @property string|null $telephony_provider_id\n * @property int|null $from_participant_id\n * @property int|null $to_participant_id\n * @property int|null $device_id\n * @property string|null $type\n * @property int|null $playbook_category_id\n * @property int $user_id\n * @property int|null $lead_id\n * @property int|null $account_id\n * @property int|null $contact_id\n * @property int|null $opportunity_id\n * @property int|null $stage_id\n * @property string|null $value\n * @property int|null $crm_configuration_id\n * @property string|null $crm_provider_id\n * @property string|null $language\n * @property int|null $transcription_id\n * @property int $duration\n * @property string $status\n * @property int|null $on_air\n * @property int|null $calendar_event_id\n * @property string $recording_state\n * @property bool|null $recording_preference\n * @property int $recording_reason_code\n * @property int $summary_reminder_sent\n * @property \\Illuminate\\Support\\Carbon|null $log_reminder_sent_at\n * @property \\Illuminate\\Support\\Carbon|null $organizer_notified_at\n * @property bool|null $has_recording_prompt\n * @property bool $is_internal\n * @property int $is_locked\n * @property int $is_recording\n * @property bool|null $is_processed\n * @property bool $is_private\n * @property bool $is_instant_invite\n * @property string|null $poster_path\n * @property string|null $summary\n * @property string|null $title\n * @property string|null $description\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_start_time\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_end_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_start_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_end_time\n * @property int|null $uploaded_by\n * @property \\Illuminate\\Support\\Carbon|null $deleted_at\n * @property \\Illuminate\\Support\\Carbon|null $created_at\n * @property \\Illuminate\\Support\\Carbon|null $updated_at\n * @property string|null $average_score\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $activeParticipants\n * @property-read int|null $active_participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers\n * @property-read int|null $activity_scorecard_rule_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRule> $activityScorecardRules\n * @property-read int|null $activity_scorecard_rules_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, AvailabilityNotification> $availabilityNotifications\n * @property-read int|null $availability_notifications_count\n * @property-read \\Jiminny\\Models\\PlaybookCategory|null $category\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, CoachRequest> $coachRequests\n * @property-read int|null $coach_requests_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $coachingFeedbacks\n * @property-read int|null $coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $coachingMessages\n * @property-read int|null $coaching_messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $comments\n * @property-read int|null $comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Connection> $connections\n * @property-read int|null $connections_count\n * @property-read Configuration|null $crm\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, FieldData> $data\n * @property-read int|null $data_count\n * @property-read \\Jiminny\\Models\\Device|null $device\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $favoritePlaylists\n * @property-read int|null $favorite_playlists_count\n * @property-read \\Jiminny\\Models\\Participant|null $from\n * @property-read string|null $activity_title\n * @property-read mixed $comment_count\n * @property-read mixed $duration_for_humans\n * @property-read string $duration_for_humans_short\n * @property-read int $favorite_count\n * @property-read mixed $favorites_count\n * @property-read mixed $formatted_value\n * @property-read string $id_string\n * @property-read \\Jiminny\\Models\\Participant|null $organizer\n * @property-read mixed $play_count\n * @property-read int|null $plays_count\n * @property-read ?ProspectInterface $prospect\n * @property-read string|null $prospect_name\n * @property-read mixed $prospect_type\n * @property-read mixed $share_count\n * @property-read int|null $shares_count\n * @property-read int|null $tracks_with_telephony_count\n * @property-read int|null $visible_comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $latestCoachingFeedbacks\n * @property-read int|null $latest_coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Log> $logs\n * @property-read int|null $logs_count\n * @property-read \\Jiminny\\Models\\Track|null $masterTrack\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $messages\n * @property-read int|null $messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Moment> $moments\n * @property-read int|null $moments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Note> $notes\n * @property-read int|null $notes_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\Share> $participantShares\n * @property-read int|null $participant_shares_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, ParticipantSpeech> $participantSpeeches\n * @property-read int|null $participant_speeches_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\ParticipantStats> $participantStats\n * @property-read int|null $participant_stats_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $participants\n * @property-read int|null $participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, PlaylistActivity> $playlistActivities\n * @property-read int|null $playlist_activities_count\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $playlists\n * @property-read int|null $playlists_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Play> $plays\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Question> $questions\n * @property-read int|null $questions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Session> $sessions\n * @property-read int|null $sessions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Share> $shares\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Snapshot> $snapshots\n * @property-read int|null $snapshots_count\n * @property-read Stats|null $stats\n * @property-read \\Jiminny\\Models\\Participant|null $to\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, TopicTrigger> $topicTriggers\n * @property-read int|null $topic_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracks\n * @property-read int|null $tracks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracksWithTelephony\n * @property-read Transcription|null $transcription\n * @property-read \\Jiminny\\Models\\User $user\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $visibleComments\n *\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> all($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)\n * @method static \\Database\\Factories\\ActivityFactory factory(...$parameters)\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> get($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity heldBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity idOrUuId($idOrUuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newModelQuery()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newQuery()\n * @method static Builder|Activity onlyTrashed()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity query()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity scheduledBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity inOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity notInOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity forTeam(int $teamId)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity uuid(string $uuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAccountId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAverageScore($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCalendarEventId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereContactId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCreatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmConfigurationId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeletedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDescription($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeviceId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDuration($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereFromParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereHasRecordingPrompt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInstantInvite($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInternal($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsLocked($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsPrivate($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsProcessed($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsRecording($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLanguage($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLeadId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLocation($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLogReminderSentAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOnAir($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOpportunityId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOrganizerNotifiedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePlaybookCategoryId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePosterPath($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereProvider($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingPreference($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingReasonCode($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingState($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSource($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereExternalId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStageId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStatus($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummary($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummaryReminderSent($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTelephonyProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTitle($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereToParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTranscriptionId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereType($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUpdatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUploadedBy($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUserId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUuid($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereValue($value)\n * @method static Builder|Activity withTrashed()\n * @method static Builder|Activity withoutTrashed()\n *\n * @mixin \\Eloquent\n */\nclass Activity extends Model implements\n ElasticSearch\\Contract\\Searchable,\n Workflow\\Workflow\\WorkflowAwareInterface,\n Models\\Contracts\\ActivityContract,\n Contracts\\Model\\ActivityInterface,\n UuidAwareInterface\n{\n use HasFactory;\n\n use Enums;\n use SoftDeletes;\n use RequiresUUID;\n use BitwiseFlagTrait;\n use ElasticSearch\\Model\\Searchable;\n use ActivityElasticSearchTrait;\n\n use Workflow\\Workflow\\WorkflowAware {\n transitionTo as traitTransitionTo;\n }\n\n public const int FLAG_RECORDING_REASON_DEFAULT = 0;\n\n // Recording Prompted but never started\n public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;\n public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;\n\n // Recording Disabled by Organization\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;\n\n // Recording was restricted to one-side recordings only\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;\n\n // Recording was not started because it was internal and team setting disabled that.\n public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;\n\n // Recording was not started because it was internal and user setting disabled that.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;\n\n // Recording was not started because user setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;\n\n // Recording was not started because team setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;\n\n // Recording was not started because user has overriden default.\n public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;\n\n // Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;\n\n // Recording was not started because their team setting does excludes the meeting type.\n public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;\n\n // Recording was not started because the external provider disabled it (or recording is missing etc).\n public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;\n\n // Recording was stopped externally (\"exit-meeting\" Pusher event)\n public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;\n\n // Recording couldn't be started due to Zoom hosting conflict error\n public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;\n\n // meeting.failed event with reason code BOT_DENIED_FROM_LOBBY\n public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;\n\n // meeting.failed event with reason code LOBBY_TIMEOUT\n public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;\n\n // meeting.failed event with reason code BOT_KICKED\n public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;\n\n // meeting.failed event with reason code UNKNOWN\n public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;\n\n public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;\n\n // Invalid meeting (e.g. URL is invalid, or the meeting is not found)\n public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;\n\n // The host stopped the recording.\n public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;\n\n // Recording was not started because an alternative vendor disabled it (or overrode it).\n public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;\n\n // Login required meeting.failed code\n public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;\n\n // Password for meeting was not provided - meeting.failed code\n public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;\n\n // meeting.failed - when the meeting is locked\n public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;\n\n // max recording duration reached\n public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;\n\n // recording size is too small\n public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;\n\n // meeting.failed - when bot is redirected to sign in page multiple times\n public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;\n\n // meeting.failed event with reason code CONNECTION_LOST\n public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;\n\n // recording is corrupted.\n public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;\n\n // meeting ended in lobby\n public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;\n\n // meeting not started\n public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;\n\n // unfinished zoom custom disclaimer\n public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;\n\n // recording download failed - server error\n public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;\n\n // recording download failed - client code 404\n public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;\n\n // recording download failed - client code 401, 403\n public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;\n\n // recording download failed - client code 429\n public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;\n\n // recording download failed - unknown client error\n public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;\n\n // recording download failed - unknown error\n public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;\n\n // It has been setup ahead of time through calendar\n public const string STATUS_SCHEDULED = 'scheduled';\n\n // It is awaiting audio.\n public const string STATUS_PENDING = 'pending';\n\n // Participant(s) dialed in, awaiting organizer.\n public const string STATUS_RINGING = 'ringing';\n\n // Call is in progress.\n public const string STATUS_IN_PROGRESS = 'in-progress';\n\n // It has ended.\n public const string STATUS_COMPLETED = 'completed';\n\n // Cancelled prior to starting.\n public const string STATUS_CANCELLED = 'canceled';\n\n public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference\n\n public const string STATUS_STARTING_SOON = 'starting-soon';\n\n public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';\n\n public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';\n\n public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';\n\n // When bot instance is waiting in lobby\n public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';\n\n public const string STATUS_BUSY = 'busy';\n public const string STATUS_NO_ANSWER = 'no-answer';\n public const string STATUS_FAILED = 'failed'; // Used by SMS too\n\n // SMS related\n public const string STATUS_ACCEPTED = 'accepted';\n public const string STATUS_QUEUED = 'queued';\n public const string STATUS_SENDING = 'sending';\n public const string STATUS_SENT = 'sent';\n public const string STATUS_DELIVERED = 'delivered';\n public const string STATUS_UNDELIVERED = 'undelivered';\n public const string STATUS_RECEIVING = 'receiving';\n public const string STATUS_RECEIVED = 'received';\n public const string STATUS_RESENT = 'resent';\n\n public const array SMS_STATUSES = [\n Activity::STATUS_RECEIVED,\n Activity::STATUS_SENT,\n Activity::STATUS_DELIVERED,\n ];\n\n public const array SOFT_PHONE_CONFERENCE_STATUSES = [\n Activity::STATUS_IN_PROGRESS,\n Activity::STATUS_COMPLETED,\n ];\n\n // @todo refactor prefix from `TYPE_` to `CHANNEL_`\n public const string TYPE_SOFTPHONE = 'softphone';\n public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';\n public const string TYPE_CONFERENCE = 'conference';\n public const string TYPE_SMS_INBOUND = 'sms-inbound';\n public const string TYPE_SMS_OUTBOUND = 'sms-outbound';\n public const string TYPE_EMAIL_INBOUND = 'email-inbound';\n public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';\n\n public const array CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n public const array PLAYABLE_CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n ];\n\n // Recording States\n public const string RECORDING_OFF = 'off'; // Default state\n public const string RECORDING_IN_PROGRESS = 'in-progress';\n public const string RECORDING_PAUSED = 'paused';\n public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.\n public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.\n public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.\n\n // Live Stream States\n public const int ON_AIR_DEFAULT = 0;\n public const int ON_AIR_READY = 1;\n public const int ON_AIR_PREPARING = 2;\n public const int ON_AIR_STREAMING = 3;\n public const int ON_AIR_FINISHED = 4;\n public const int ON_AIR_NOT_STREAMED = 5;\n public const int ON_AIR_ERROR = -1;\n\n public const string SOURCE_GONG = 'gong';\n public const string SOURCE_CHORUS = 'chorus';\n public const string SOURCE_OUTLOOK = 'outlook';\n public const string SOURCE_GOOGLE = 'google';\n\n // Activity Providers\n public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.\n public const string PROVIDER_OUTREACH = 'outreach';\n public const string PROVIDER_ZOOM_BOT = 'zoom-bot';\n public const string PROVIDER_SALESLOFT = 'salesloft';\n public const string PROVIDER_GOOGLE = 'google';\n public const string PROVIDER_AIRCALL = 'aircall';\n public const string PROVIDER_JUSTCALL = 'justcall';\n public const string PROVIDER_GOOGLE_MEET = 'google-meet';\n public const string PROVIDER_GONG = 'gong';\n public const string PROVIDER_HUBSPOT = 'hubspot';\n public const string PROVIDER_CLOSE = 'close';\n public const string PROVIDER_TEAMS = 'ms-teams';\n public const string PROVIDER_SALESFORCE = 'salesforce';\n public const string PROVIDER_GROOVE = 'groove';\n public const string PROVIDER_XANT = 'xant';\n public const string PROVIDER_OFFICE = 'office';\n public const string PROVIDER_NATTERBOX = 'natterbox';\n public const string PROVIDER_RINGCENTRAL = 'ringcentral';\n public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';\n public const string PROVIDER_GOTOMEETING = 'go-to-meeting';\n public const string PROVIDER_DEMODESK = 'demo-desk';\n public const string PROVIDER_DIALPAD = 'dialpad';\n public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';\n public const string PROVIDER_CLOUDCALL = 'cloudcall';\n public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';\n public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // \"8x8\" UK\n public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // \"8x8\" Canada\n public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // \"8x8\" Australia\n public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // \"8x8\" US East\n public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // \"8x8\" US West\n public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';\n public const string PROVIDER_CLOUD_TALK = 'cloud-talk';\n public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';\n public const string PROVIDER_VONAGE = 'vonage';\n public const string PROVIDER_MIGRATOR = 'migrator';\n public const string PROVIDER_UPLOADER = 'uploader';\n public const string PROVIDER_TALKDESK = 'talkdesk';\n public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';\n public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';\n public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';\n public const string PROVIDER_AVAYA = 'avaya';\n public const string PROVIDER_TELUS = 'telus';\n public const string PROVIDER_FIVE_NINE = 'five-nine';\n public const string PROVIDER_APOLLO = 'apollo';\n public const string PROVIDER_ORUM = 'orum';\n public const string PROVIDER_BLOOBIRDS = 'bloobirds';\n\n /**\n * @const API_PROVIDERS\n * A list of integrations that import calls via API instead of webhooks\n */\n public const array API_PROVIDERS = [\n self::PROVIDER_OUTREACH,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n ];\n\n public const array FINITE_STATES = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,\n ];\n\n public const array FINITE_STATES_CONFERENCE = [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_CANCELLED,\n ];\n\n public const array MEETING_BOT_JOIN_ATTEMPTED = [\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_BOT_INSTANCE_STARTED,\n ];\n\n public static array $enumStatuses = [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_ACCEPTED,\n self::STATUS_QUEUED,\n self::STATUS_SENDING,\n self::STATUS_SENT,\n self::STATUS_RESENT,\n self::STATUS_DELIVERED,\n self::STATUS_UNDELIVERED,\n self::STATUS_RECEIVING,\n self::STATUS_RECEIVED,\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_STARTING_SOON,\n self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,\n self::STATUS_BOT_INSTANCE_STARTED,\n self::STATUS_DUPLICATED,\n ];\n\n public static array $enumProviders = [\n self::PROVIDER_TWILIO,\n self::PROVIDER_OUTREACH,\n self::PROVIDER_ZOOM_BOT,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_AIRCALL,\n self::PROVIDER_JUSTCALL,\n self::PROVIDER_GOOGLE_MEET,\n self::PROVIDER_GONG,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_CLOSE,\n self::PROVIDER_TEAMS,\n self::PROVIDER_SALESFORCE,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_GOOGLE,\n self::PROVIDER_OFFICE,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_RINGCENTRAL_VIDEO,\n self::PROVIDER_GOTOMEETING,\n self::PROVIDER_DEMODESK,\n self::PROVIDER_DIALPAD,\n self::PROVIDER_ZOOM_PHONE,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n ];\n\n public static $enumRecordingStates = [\n self::RECORDING_OFF, // Default state\n self::RECORDING_IN_PROGRESS,\n self::RECORDING_PAUSED,\n self::RECORDING_STOPPED,\n self::RECORDING_RECORDED,\n self::RECORDING_FAILED,\n ];\n\n // @Important:\n // This collection is not used anywhere, and is fully duplicated by the Channels const.\n // Validate if it is referred somehow via the enum trait, and if not, remove it entirely.\n // An even better strategy will be to move all those constants to a dedicated class\n protected array $enumTypes = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n protected static $enumFailedStatuses = [\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n self::STATUS_CANCELLED,\n ];\n\n protected $table = 'activities';\n\n protected $fillable = [\n // Type of activity.\n 'type', // @todo refactor to `channel`\n // The activity type.\n 'playbook_category_id',\n // User who hosts the activity.\n 'user_id',\n // Related Lead record (if applicable)\n 'lead_id',\n // Related Account record (if applicable)\n 'account_id',\n // Related Contact record (if applicable)\n 'contact_id',\n // Related Opportunity record (if applicable)\n 'opportunity_id',\n // Stage of activity.\n 'stage_id',\n // Value of opportunity.\n 'value',\n // If the activity relates to a CRM task.\n 'crm_provider_id',\n // If the activity was created through an external device.\n 'device_id',\n // the activity's language code\n 'language',\n // transcription id\n 'transcription_id',\n // Duration of the call, with microseconds precision.\n 'duration',\n // One of enumStatuses above.\n 'status',\n // Have we reminded them to log the call?\n 'log_reminder_sent_at',\n // If activity is private or inter-org, flagged here.\n 'is_internal',\n // Managers and above can mark a call as private, to exclude it from other team members\n 'is_private',\n 'is_processed',\n // Boolean for this activity being instant invite handled.\n 'is_instant_invite',\n // If activity is in recording state, flagged here.\n 'recording_state',\n // If activity recording is overidden from default.\n 'recording_preference',\n // if recording did (not) happen, why that is\n 'recording_reason_code',\n // Average score, updated during\n 'average_score',\n // Summary that the organizer has taken after the call.\n 'summary',\n // Subject of the activity, usually taken from calendar event.\n 'title',\n // Description of the activity, usually taken from calendar event.\n 'description',\n // Start time, usually taken from calendar event.\n 'scheduled_start_time',\n // End time, usually taken from calendar event.\n 'scheduled_end_time',\n // When the call actually started.\n 'actual_start_time',\n // When the call actually ended.\n 'actual_end_time',\n // SMS: Message reference\n 'telephony_provider_id',\n // SMS: Participant who sent message\n 'from_participant_id',\n // SMS: Participant who should receive the message\n 'to_participant_id',\n // When an external guest joins an organizers meeting room and the organizer is not present,\n // send them an SMS notification that someone has joined.\n 'organizer_notified_at',\n // where was the activity imported from\n 'source',\n // The id in the source system (e.g. the bot id in Recall.ai)\n 'external_id',\n // The provider, by default it is twilio.\n 'provider',\n // Meeting location url\n 'location',\n // The snapshot for displaying a poster image.\n 'poster_path',\n 'crm_configuration_id',\n // If there is an automated message that the conversation is being recorded\n 'has_recording_prompt',\n // If the activity is being live-streamed\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected $appends = [\n 'id_string',\n 'organizer',\n ];\n\n protected $hidden = [\n 'uuid',\n ];\n\n protected $visible = [\n 'id_string',\n 'type',\n 'duration',\n 'average_score',\n 'status',\n 'log_reminder_sent_at',\n 'title',\n 'description',\n 'is_internal',\n 'scheduled_start_time',\n 'scheduled_end_time',\n 'actual_start_time',\n 'actual_end_time',\n 'user',\n 'category',\n 'account',\n 'contact',\n 'opportunity',\n 'lead',\n 'stage',\n 'stats',\n 'participants',\n 'playlists',\n 'tracks',\n 'comments',\n 'plays',\n 'coachingFeedbacks',\n 'shares',\n 'favorites',\n 'language',\n 'transcription',\n 'is_private',\n 'is_instant_invite',\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'scheduled_start_time' => 'datetime',\n 'scheduled_end_time' => 'datetime',\n 'actual_start_time' => 'datetime',\n 'actual_end_time' => 'datetime',\n 'organizer_notified_at' => 'datetime',\n 'log_reminder_sent_at' => 'datetime',\n 'is_internal' => 'boolean',\n 'duration' => 'integer',\n 'average_score' => 'decimal:2',\n 'is_private' => 'boolean',\n 'is_processed' => 'boolean',\n 'is_instant_invite' => 'boolean',\n 'value' => 'decimal:2',\n 'recording_preference' => 'boolean',\n 'recording_reason_code' => 'integer',\n 'has_recording_prompt' => 'boolean',\n 'on_air' => 'integer',\n ];\n }\n\n protected static function boot()\n {\n parent::boot();\n\n static::updated(static function (Activity $activity) {\n // If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week\n if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||\n ($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {\n if ($activity->isDirty('status')) {\n event(new StatusUpdated($activity));\n }\n\n if ($activity->isDirty('stage_id')) {\n event(new StageUpdated($activity));\n }\n\n if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {\n event(new ProspectUpdated($activity));\n }\n\n if ($activity->isDirty('opportunity_id')) {\n event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));\n }\n\n if ($activity->isDirty('title')) {\n event(new TitleUpdated($activity));\n }\n }\n\n if ($activity->isDirty('playbook_category_id')) {\n event(new ActivityTypeUpdated($activity));\n }\n });\n\n static::deleted(static function (Activity $activity) {\n // Hard delete associated playlistActivities\n $activity->playlistActivities()->delete();\n });\n }\n\n public function getOrganizerAttribute(): ?Participant\n {\n $participant = $this->participants()->where('user_id', $this->user_id)->first();\n\n if (! $participant instanceof Participant && $participant !== null) {\n throw new RuntimeException(sprintf('$participant must be an instance of \"%s\" or null', Participant::class));\n }\n\n return $participant;\n }\n\n public function getFormattedValueAttribute()\n {\n $currencyCode = 'USD';\n if ($this->opportunity) {\n $currencyCode = $this->opportunity->getCurrencyCode();\n }\n\n $formatter = new CurrencyFormatter();\n $formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);\n $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);\n\n return $formatter->format($this->value, $currencyCode);\n }\n\n public function getProspectNameAttribute(): ?string\n {\n $prospectName = null;\n\n if ($this->lead_id) {\n $prospectName = $this->lead->name;\n } elseif ($this->contact_id) {\n $prospectName = $this->contact->name;\n } elseif ($this->account_id) {\n $prospectName = $this->account->name;\n }\n\n return $prospectName;\n }\n\n public function getProspectName(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('prospect_name');\n }\n\n /**\n * Get activity title depending on prospect or title\n */\n public function getActivityTitleAttribute(): ?string\n {\n $activityTitle = null;\n if ($this->prospect && $this->prospect->getName()) {\n if ($this->account_id) {\n $activityTitle = $this->account->name;\n } elseif ($this->lead_id) {\n $activityTitle = $this->lead->company;\n } elseif ($this->contact_id) {\n $activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;\n }\n } elseif ($this->title) {\n $activityTitle = $this->title;\n }\n\n return $activityTitle;\n }\n\n public function wasRecentlyCreated(): bool\n {\n return $this->wasRecentlyCreated;\n }\n\n public function getProspectTypeAttribute()\n {\n $prospectType = null;\n\n if ($this->lead_id) {\n $prospectType = 'Lead';\n } elseif ($this->contact_id) {\n $prospectType = 'Contact';\n } elseif ($this->account_id) {\n $prospectType = 'Account';\n }\n\n return $prospectType;\n }\n\n /**\n * Return the best match for prospect. Results are in the following order of priority:\n * 1. Lead\n * 2. Contact\n * 3. Account\n * 4. NULL\n */\n public function getProspectAttribute(): ?ProspectInterface\n {\n if ($this->hasLead()) {\n return $this->getLead();\n }\n\n if ($this->hasContact()) {\n return $this->getContact();\n }\n\n if ($this->hasAccount()) {\n return $this->getAccount();\n }\n\n return null;\n }\n\n public function getTitleAttribute($value): ?string\n {\n return \\getActivityTitleAttribute(\n $this->user->name,\n $this->getType(),\n $value,\n $this->prospect->name ?? null,\n $this->from->national_phone_number ?? null\n );\n }\n\n public function getTitle(): ?string\n {\n return $this->getAttribute('title');\n }\n\n public function getSummary(): ?string\n {\n return $this->getAttribute('summary');\n }\n\n public function isInternal(): bool\n {\n return $this->getAttribute('is_internal');\n }\n\n public function getIsPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n public function getDescription(): ?string\n {\n return $this->getAttribute('description');\n }\n\n public function hasTitle(): bool\n {\n return $this->getOriginal('title') !== null;\n }\n\n public function getPlayCountAttribute()\n {\n return $this->getPlaysCountAttribute();\n }\n\n public function getPlaysCountAttribute()\n {\n if (! isset($this->attributes['plays_count'])) {\n $this->loadCount('plays');\n }\n\n return $this->attributes['plays_count'];\n }\n\n public function getCommentCountAttribute()\n {\n return $this->getCommentsCountAttribute();\n }\n\n public function getCommentsCountAttribute()\n {\n if (! isset($this->attributes['comments_count'])) {\n $this->loadCount('comments');\n }\n\n return $this->attributes['comments_count'];\n }\n\n public function getVisibleCommentsCountAttribute()\n {\n if (! isset($this->attributes['visible_comments_count'])) {\n $activityCommentsService = app(ActivityCommentService::class);\n $user = Auth::user() instanceof User ? Auth::user() : null;\n $this->attributes['visible_comments_count'] = $activityCommentsService\n ->getVisibleCommentsCount($this, $user);\n }\n\n return $this->attributes['visible_comments_count'];\n }\n\n public function getShareCountAttribute()\n {\n return $this->getSharesCountAttribute();\n }\n\n public function getSharesCountAttribute()\n {\n if (! isset($this->attributes['shares_count'])) {\n $this->loadCount('shares');\n }\n\n return $this->attributes['shares_count'];\n }\n\n\n /**\n * Get the count of favorites playlists this activity appears in\n */\n public function getFavoriteCountAttribute(): int\n {\n return $this->getFavoritesCountAttribute();\n }\n\n public function getFavoritesCountAttribute()\n {\n if (! isset($this->attributes['favorites_count'])) {\n $this->loadCount('favorites');\n }\n\n return $this->attributes['favorites_count'];\n }\n\n public function getActiveParticipantsCountAttribute()\n {\n if (! isset($this->attributes['active_participants_count'])) {\n $this->loadCount('activeParticipants');\n }\n\n return $this->attributes['active_participants_count'];\n }\n\n public function getTracksWithTelephonyCountAttribute()\n {\n if (! isset($this->attributes['tracks_with_telephony_count'])) {\n $this->loadCount('tracksWithTelephony');\n }\n\n return $this->attributes['tracks_with_telephony_count'];\n }\n\n /**\n * @TEMP\n * $this->loadCount('tracksWithTelephony') throws null pointer exception\n */\n public function countTracksWithTelephony(): int\n {\n return $this->tracks()->whereNotNull('telephony_provider_id')->count();\n }\n\n public function getDuration(): float\n {\n return $this->getAttribute('duration');\n }\n\n public function getDurationForHumansAttribute()\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);\n }\n\n public function getDurationForHumansShortAttribute(): string\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);\n }\n\n public function hasRecordingPreference(): bool\n {\n return $this->getAttribute('recording_preference') !== null;\n }\n\n public function getRecordingPreference()\n {\n return $this->getAttribute('recording_preference');\n }\n\n /** @return BelongsTo<User, self> */\n public function user(): BelongsTo\n {\n return $this->belongsTo(User::class)->with('group');\n }\n\n public function device()\n {\n return $this->belongsTo(Device::class);\n }\n\n public function category()\n {\n return $this->belongsTo(PlaybookCategory::class, 'playbook_category_id');\n }\n\n public function getCategory(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function getPlaybookCategoryId(): ?int\n {\n return $this->getAttribute('playbook_category_id');\n }\n\n public function hasStats(): bool\n {\n return $this->getAttribute('stats') !== null;\n }\n\n public function getStats(): ?Stats\n {\n return $this->getAttribute('stats');\n }\n\n public function stats(): HasOne\n {\n return $this->hasOne(Stats::class);\n }\n\n public function participantStats(): Eloquent\\Relations\\HasManyThrough\n {\n return $this->hasManyThrough(\n Models\\Participant\\ParticipantStats::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantStats(): Eloquent\\Collection\n {\n return $this->getAttribute('participantStats');\n }\n\n public function account()\n {\n return $this->belongsTo(Account::class);\n }\n\n public function contact()\n {\n return $this->belongsTo(Contact::class)->with(['account']);\n }\n\n public function lead()\n {\n return $this->belongsTo(Lead::class)->with(['stage', 'recordType']);\n }\n\n /**\n * @return BelongsTo<Opportunity, self>\n */\n public function opportunity(): BelongsTo\n {\n /** @var BelongsTo<Opportunity, self> */\n return $this->belongsTo(Opportunity::class);\n }\n\n public function stage()\n {\n return $this->belongsTo(Stage::class);\n }\n\n /**\n * @return HasMany<Session>\n */\n public function sessions(): HasMany\n {\n return $this->hasMany(Session::class);\n }\n\n /**\n * @return HasMany|ParticipantSpeech[]|Eloquent\\Collection\n */\n public function participantSpeeches()\n {\n return $this->hasMany(ParticipantSpeech::class);\n }\n\n public function getParticipantSpeeches(): Eloquent\\Collection\n {\n return $this->getAttribute('participantSpeeches');\n }\n\n /**\n * @return HasMany|Log[]|Eloquent\\Collection\n */\n public function logs()\n {\n return $this->hasMany(Log::class);\n }\n\n /**\n * @return HasMany|Moment[]|Eloquent\\Collection\n */\n public function moments()\n {\n return $this->hasMany(Moment::class);\n }\n\n /**\n * @return HasMany|Note[]|Eloquent\\Collection\n */\n public function notes()\n {\n return $this->hasMany(Note::class);\n }\n\n /**\n * @return Eloquent\\Collection|Note[]\n */\n public function getNotes(): Eloquent\\Collection\n {\n return $this->getAttribute('notes');\n }\n\n /**\n * @return HasMany|Message[]|Eloquent\\Collection\n */\n public function messages()\n {\n return $this->hasMany(Message::class);\n }\n\n public function coachingMessages(): HasMany\n {\n return $this->hasMany(Message::class)\n ->where('is_private', 1);\n }\n\n public function getCoachingMessages(): Eloquent\\Collection\n {\n return $this->getAttribute('coachingMessages');\n }\n\n public function participants(): HasMany\n {\n return $this->hasMany(Participant::class);\n }\n\n public function getSnapshots(): Eloquent\\Collection\n {\n return $this->getAttribute('snapshots');\n }\n\n /** @return HasMany<Track> */\n public function tracks(): HasMany\n {\n return $this->hasMany(Track::class);\n }\n\n public function tracksWithTelephony(): HasMany\n {\n return $this->hasMany(Track::class)->whereNotNull('telephony_provider_id');\n }\n\n public function getTracksWithTelephony(): Eloquent\\Collection\n {\n return $this->getAttribute('tracksWithTelephony');\n }\n\n /** @return Collection|Track[] */\n public function getTracks(): Eloquent\\Collection\n {\n return $this->getAttribute('tracks');\n }\n\n public function masterTrack(): HasOne\n {\n return $this->hasOne(Track::class)->where('is_master', 1)\n ->whereIn('format', [Track::FORMAT_WAV, Track::FORMAT_M3U8])\n ->latest();\n }\n\n public function getMasterTrack(): ?Track\n {\n /** @var Track|null */\n return $this->getAttribute('masterTrack');\n }\n\n public function transcription(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Transcription::class, 'transcription_id');\n }\n\n public function findTranscriptionPromptSummaries(): Collection\n {\n $transcriptionId = $this->getTranscriptionId();\n if (is_null($transcriptionId)) {\n return new Collection();\n }\n\n return Models\\AiPrompt::query()\n ->where('transcription_id', $transcriptionId)\n ->get();\n }\n\n public function getTranscription(): Transcription\n {\n return $this->getAttribute('transcription');\n }\n\n public function hasTranscription(): bool\n {\n return $this->getAttribute('transcription') !== null;\n }\n\n public function setTranscriptionId(int $transcriptionId): Activity\n {\n $this->setAttribute('transcription_id', $transcriptionId);\n\n return $this;\n }\n\n public function unsetTranscriptionId(): self\n {\n $this->setAttribute('transcription_id', null);\n\n return $this;\n }\n\n public function getTranscriptionId(): ?int\n {\n return $this->getAttribute('transcription_id');\n }\n\n /** @deprecated */\n public function hasTranscriptionId(): bool\n {\n return $this->getAttribute('transcription_id') !== null;\n }\n\n public function coachRequests()\n {\n return $this->hasMany(CoachRequest::class);\n }\n\n public function availabilityNotifications()\n {\n return $this->hasMany(AvailabilityNotification::class);\n }\n\n public function processingStates()\n {\n return $this->hasMany(Models\\Activity\\ActivityProcessingState::class);\n }\n\n public function uploadSettings()\n {\n return $this->hasMany(ActivityUploadSetting::class);\n }\n\n public function comments()\n {\n return $this->hasMany(Comment::class);\n }\n\n public function getComments(): Eloquent\\Collection\n {\n return $this->getAttribute('comments');\n }\n\n public function visibleComments()\n {\n $rel = $this->hasMany(Comment::class);\n // Doesn't have auth()->user() in some tests, breaks the build\n if ($user = auth()->user()) {\n return $rel->visibleThreads($user->id);\n }\n\n return $rel;\n }\n\n public function snapshots(): HasMany\n {\n return $this->hasMany(Snapshot::class);\n }\n\n public function calendarEvent()\n {\n return $this->belongsTo(CalendarEvent::class);\n }\n\n public function getCalendarEvent(): ?CalendarEvent\n {\n return $this->getAttribute('calendarEvent');\n }\n\n public function latestCoachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class)->latest();\n }\n\n public function playlists(): BelongsToMany\n {\n return $this->belongsToMany(Playlist::class, 'playlist_activities')\n ->withPivot('id', 'uuid', 'user_id', 'start_time', 'end_time')\n ->using(PlaylistActivity::class)\n ->withTimestamps();\n }\n\n public function coachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class);\n }\n\n /**\n * @return Eloquent\\Collection|CoachingFeedback[]\n */\n public function getCoachingFeedback(?int $visibility = null): Eloquent\\Collection\n {\n $feedbacks = $this->coachingFeedbacks();\n if ($visibility !== null) {\n $feedbacks = $feedbacks->where('visibility', $visibility);\n }\n\n return $feedbacks->get();\n }\n\n /** @return Eloquent\\Collection<int, PlaylistActivity> */\n public function favoritedBy(User $user): Eloquent\\Collection\n {\n return $this->favorites()->where('user_id', $user->getId())->get();\n }\n\n /**\n * Checks whether consumer has added this activity to their favorites playlist\n * In addition a default playlist gets created if not already present\n */\n public function wasFavoritedBy(User $user): bool\n {\n $playlist = $user->favoritePlaylist();\n\n return $playlist\n ->activities()\n ->where('activity_id', '=', $this->getId())\n ->exists();\n }\n\n /**\n * @return HasMany<PlaylistActivity>\n */\n public function playlistActivities(): HasMany\n {\n return $this->hasMany(PlaylistActivity::class);\n }\n\n /**\n * @return HasManyThrough<Playlist>\n */\n public function favoritePlaylists(): HasManyThrough\n {\n return $this->hasManyThrough(\n Playlist::class,\n PlaylistActivity::class,\n 'activity_id',\n 'id',\n 'id',\n 'playlist_id'\n )->where('is_default', 1);\n }\n\n /**\n * @return Eloquent\\Collection<int, Playlist>\n */\n public function getFavoritePlaylists(): Eloquent\\Collection\n {\n return $this->getAttribute('favoritePlaylists');\n }\n\n /**\n * Get activities from the default/favorite playlist\n *\n * @return Eloquent\\Builder|static\n */\n public function favorites()\n {\n return $this->playlistActivities()->whereHas('playlist', function ($query) {\n $query->where('is_default', 1);\n });\n }\n\n /**\n * @return Model|SubscriptionSet|null|object\n */\n public function subscribedBy(User $user)\n {\n if ($this->prospect === null) {\n return null;\n }\n\n return SubscriptionSet::select('activity_subscription_sets.*')\n ->where('user_id', $user->id)\n ->join('activity_subscriptions', function ($join) {\n $join\n ->on('subscription_set_id', '=', 'activity_subscription_sets.id');\n\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $join\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $join\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $join\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $join\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n }\n })\n ->first();\n }\n\n /**\n * @return array|Eloquent\\Builder[]|Eloquent\\Collection|SubscriptionSet[]\n */\n public function subscribers()\n {\n if ($this->prospect === null) {\n return [];\n }\n\n return SubscriptionSet::with(['subscriptions', 'user'])\n ->whereHas('subscriptions', function ($query) {\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $query\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $query\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $query\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $query\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n } else {\n // Nothing to join on?\n // refactor - use Jiminny specific exception\n throw new InvalidArgumentException('Cannot join on a specific customer filter.');\n }\n })\n ->whereHas('user', function ($query) {\n $query\n ->where('team_id', $this->user->team_id)\n ->where('status', User::STATUS_ACTIVE);\n })\n ->get();\n }\n\n /**\n * @return HasMany|Builder|Eloquent\\Collection|Play[]\n */\n public function plays()\n {\n return $this->hasMany(Play::class);\n }\n\n public function getPlays(): Eloquent\\Collection\n {\n return $this->getAttribute('plays');\n }\n\n public function playsBy(User $user)\n {\n /** @var Builder $builder */\n $builder = $this->plays()->where('user_id', $user->id);\n\n return $builder->get();\n }\n\n /**\n * Check if activity was played by a user\n */\n public function wasPlayedBy(User $user): bool\n {\n return $this->plays()->where('user_id', $user->id)->exists();\n }\n\n public function shares()\n {\n return $this->hasMany(Share::class);\n }\n\n /** @return BelongsTo<Participant, self> */\n public function from(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'from_participant_id');\n }\n\n /** @return BelongsTo<Participant, self> */\n public function to(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'to_participant_id');\n }\n\n /**\n * Get all of the connections through the participants.\n */\n public function connections()\n {\n return $this->hasManyThrough(\n Connection::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getConnections(): Eloquent\\Collection\n {\n return $this->getAttribute('connections');\n }\n\n /**\n * Get all of the shares through the participants.\n */\n public function participantShares()\n {\n return $this->hasManyThrough(\n Participant\\Share::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantShares(): Eloquent\\Collection\n {\n return $this->getAttribute('participantShares');\n }\n\n public function topicTriggers(): HasMany\n {\n return $this->hasMany(TopicTrigger::class);\n }\n\n public function activityScorecardRuleTriggers(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRuleTrigger::class);\n }\n\n public function activityScorecardRules(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRule::class);\n }\n\n public function questions(): HasMany\n {\n return $this->hasMany(Question::class);\n }\n\n /**\n * Get all the custom data attached to it.\n */\n public function data(): HasMany\n {\n return $this->hasMany(FieldData::class);\n }\n\n public function getData(): Eloquent\\Collection\n {\n /** @var Eloquent\\Collection */\n return $this->getAttribute('data');\n }\n\n #[Scope]\n protected function heldBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('actual_start_date', '>=', $from)\n ->where('actual_end_date', '<=', $until);\n }\n\n #[Scope]\n protected function scheduledBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('scheduled_start_date', '>=', $from)\n ->where('scheduled_end_date', '<=', $until);\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function forTeam(Builder $query, int $teamId): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas('user', static function (Builder $query) use ($teamId): void {\n $query->where('team_id', $teamId);\n });\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function inOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query\n ->where('is_closed', false)\n ->where('deleted_at', '=', null),\n );\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function notInOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->where(\n static fn (Builder $query): Builder => $query->whereNull('opportunity_id')\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->where('is_closed', true),\n )\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->withTrashed()->where('deleted_at', '!=', null),\n ),\n );\n }\n\n /**\n * Finds a participant and updates it with data. If participant doesn't exist creates a new participant from data.\n *\n * @param array $data participant data used to identify the participant and update it\n * @param bool $enterRoom true if participant is entering the room. false if we just want to update some participant data\n * @param Carbon|null $enterTime if $enterNow is true then this is the join time when the actual enter has occurred\n */\n public function updateOrCreateParticipant(\n array $data,\n bool $enterRoom = true,\n ?Carbon $enterTime = null,\n bool $nameMatching = false,\n ): Participant {\n $search = [];\n $participant = null;\n\n if (isset($data['user_id'])) {\n // Check if they already exist based on their ID.\n $search['user_id'] = $data['user_id'];\n } elseif (isset($data['provider_id'])) {\n $search['provider_id'] = $data['provider_id'];\n } elseif ($nameMatching && isset($data['name'])) {\n $search['name'] = $data['name'];\n }\n\n if (! empty($data['email'])) {\n $search['email'] = $data['email'];\n\n // If we have their email, this should be unique enough to lookup (e.g. calendar event based participant).\n unset($search['provider_id']);\n }\n\n // Search by phone number only in case nothing else is available to search by.\n if (array_key_exists('phone_number', $data) && empty($search)) {\n $search['phone_number'] = $data['phone_number'];\n }\n\n if (! empty($search)) {\n // Do a lookup now to see if we have a match on the provided data.\n $lookup = array_map(static function ($key, $value): array {\n return [$key, $value];\n }, array_keys($search), $search);\n\n $participant = $this->participants()->withTrashed()->where($lookup)->first();\n }\n\n // Do a partial match on the name and search in the team members.\n if (! $participant instanceof Participant && $nameMatching && ! empty($data['name'])) {\n $participantMatcher = app(MeetingBot\\Service\\ParticipantMatcher::class);\n\n if (! $participantMatcher instanceof MeetingBot\\Service\\ParticipantMatcher) {\n throw new LogicException('Expecting ParticipantMatcher service instance');\n }\n\n $participant = $participantMatcher->match($this, $data['name']);\n\n // If we've found good participant, avoid data overwrite in `$participant->fill($data)` below.\n if ($participant instanceof Models\\Participant && $participant->hasName()) {\n unset($data['name']); // Thoughts: should we unset also $data['user_id'] and $data['email'] ?\n }\n }\n\n if (! $participant instanceof Participant) {\n // If no match, create a new participant.\n if (empty($search)) {\n $participant = $this->participants()->create();\n } else {\n // If no match, create a new participant but avoid creating duplicates\n $participant = $this->participants()->withTrashed()->firstOrNew($search);\n }\n }\n\n // If we have just recycled a deleted participant\n if ($participant->trashed()) {\n $participant->deleted_at = null;\n }\n\n // Deal with the case when calendar syncs the event while it's in progress.\n // We should prevent change of the participant name, because speeches mapping will fail.\n if ($enterRoom === false\n && $this->isInProgress()\n && $participant->hasName()\n && isset($data['name'])\n && $data['name'] !== $participant->getName()\n ) {\n unset($data['name']);\n }\n\n // Upsert with new data.\n $participant->fill($data);\n\n if ($enterRoom) {\n if ($enterTime === null) {\n $enterTime = now();\n }\n\n // Participant enters room for the first time\n if ($participant->enter_time === null) {\n $participant->enter_time = $enterTime;\n }\n\n // If there is an exit time and it's prior to new enter_time\n if ($participant->exit_time && $participant->exit_time->lt($enterTime)) {\n // Participant has re-joined\n $participant->exit_time = null;\n }\n }\n\n $participant->save();\n\n return $participant;\n }\n\n /**\n * Updates participant CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n * @param Participant $participant participant the CRM data is associated with\n */\n public function updateParticipantCrmData(array $records, Participant $participant): void\n {\n // Extract the records.\n [$lead, , , $contact] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForParticipant($lead, $contact);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n if (! $participant->hasName()) {\n $participant->name = $lead->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $lead->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $lead->phone;\n }\n\n $participant->lead_id = $lead->id;\n $participant->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n if (! $participant->hasName()) {\n $participant->name = $contact->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $contact->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $contact->phone;\n }\n\n $participant->contact_id = $contact->id;\n $participant->save();\n }\n }\n\n /**\n * Updates activity CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n */\n public function updateActivityCrmData(array $records): void\n {\n // Extract the records.\n [$lead, $account, $opportunity, $contact, $stage] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForActivity($lead, $contact, $account);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n if ($this->account_id === null && $this->contact_id === null && $this->lead_id === null) {\n $this->lead_id = $lead->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n $this->save();\n }\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Don't trust previous matched account_id as it might have been changed in the CRM\n if ($account && $account->id !== $this->account_id) {\n $this->account_id = $account->id;\n }\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($opportunity && $this->opportunity_id !== $opportunity->id) {\n $this->opportunity_id = $opportunity->id;\n }\n\n if ($opportunity && $this->value !== $opportunity->value) {\n $this->value = $opportunity->value;\n }\n\n // Always set contact_id when available, regardless of account_id status\n if ($this->contact_id === null && $contact) {\n $this->contact_id = $contact->id;\n }\n\n $this->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Account && $this->account_id === null) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Update the account and opportunity on the activity record if possible.\n $this->account_id = $account->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($this->opportunity_id === null && $opportunity) {\n $this->opportunity_id = $opportunity->id;\n $this->value = $opportunity->value;\n }\n\n $this->save();\n }\n }\n\n public function getActivityProspectData(): array\n {\n return [\n 'lead' => $this->lead_id,\n 'contact' => $this->contact_id,\n 'account' => $this->account_id,\n 'opportunity' => $this->opportunity_id,\n 'stage' => $this->stage_id,\n ];\n }\n\n public function isOrganizer(User $user): bool\n {\n return $this->user_id && $this->user_id === $user->id;\n }\n\n public function isJoinable(): bool\n {\n return \\in_array($this->status, [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n ], true);\n }\n\n public function isAttemptedForBotJoin(): bool\n {\n return in_array($this->getAttribute('status'), self::MEETING_BOT_JOIN_ATTEMPTED, true);\n }\n\n /**\n * Check if the activity can be saved to CRM (manual or autolog)\n */\n public function isLoggable(): bool\n {\n if ($this->getUser()->getTeam()->hasFeature(FeatureEnum::SIDEKICK_SETTINGS)) {\n $sidekickService = app(SidekickService::class);\n\n if (! $sidekickService->isSidekickEnabledForUser($this->getUser())) {\n return false;\n }\n }\n\n // If we don't know the activity type, don't try to log.\n if ($this->playbook_category_id === null) {\n return false;\n }\n\n if ($this->user->crm_required === false) {\n return false;\n }\n\n // Don't prompt for internal meetings.\n if ($this->is_internal) {\n return false;\n }\n\n // If we don't know who we are trying to log to, don't try to log.\n if ($this->prospect === null) {\n return false;\n }\n\n $validStatus = false;\n switch ($this->type) {\n case self::TYPE_SOFTPHONE:\n case self::TYPE_SOFTPHONE_INBOUND:\n $validStatus = true;\n\n break;\n case self::TYPE_CONFERENCE:\n $validStatus = in_array($this->status, [\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n ], true);\n\n break;\n case self::TYPE_SMS_INBOUND:\n case self::TYPE_SMS_OUTBOUND:\n $validStatus = in_array($this->status, [\n self::STATUS_QUEUED,\n self::STATUS_SENT,\n self::STATUS_UNDELIVERED,\n self::STATUS_DELIVERED,\n self::STATUS_RECEIVED,\n ], true);\n\n break;\n }\n\n // Depending on the activity channel, we should not try to log.\n return $validStatus;\n }\n\n public function isScheduled(): bool\n {\n return $this->status === self::STATUS_SCHEDULED;\n }\n\n public function scheduledDuration(): int\n {\n if ($this->scheduled_start_time && $this->scheduled_end_time) {\n return $this->scheduled_end_time->timestamp - $this->scheduled_start_time->timestamp;\n }\n\n return 0;\n }\n\n public function isPending(): bool\n {\n return $this->status === self::STATUS_PENDING;\n }\n\n public function isCompleted(): bool\n {\n return $this->status === self::STATUS_COMPLETED;\n }\n\n public function isRinging(): bool\n {\n return $this->status === self::STATUS_RINGING;\n }\n\n public function isInProgress(): bool\n {\n return $this->status === self::STATUS_IN_PROGRESS;\n }\n\n public function isBusy(): bool\n {\n return $this->status === self::STATUS_BUSY;\n }\n\n public function isNoAnswer(): bool\n {\n return $this->status === self::STATUS_NO_ANSWER;\n }\n\n public function isFailed(): bool\n {\n return $this->status === self::STATUS_FAILED;\n }\n\n public function isCancelled(): bool\n {\n return $this->status === self::STATUS_CANCELLED;\n }\n\n public function hasEnded(int $gracePeriodMinutes = 15): bool\n {\n if ($this->isCompleted()) {\n return true;\n }\n\n if (($this->isFailed() || $this->isCancelled()) && $this->hasScheduledEndTime()) {\n return $this->getScheduledEndTime()->addMinutes($gracePeriodMinutes)->isPast();\n }\n\n return false;\n }\n\n public function hasStarted(): bool\n {\n return $this->hasActualStartTime();\n }\n\n public function isOngoing(): bool\n {\n return $this->hasActualStartTime() && ! $this->hasActualEndTime();\n }\n\n public function isTypeSmsInbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_INBOUND;\n }\n\n public function isTypeSmsOutbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_OUTBOUND;\n }\n\n public function isTypeSoftPhone(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE;\n }\n\n public function isTypeSoftphoneInbound(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE_INBOUND;\n }\n\n public function isTypeConference(): bool\n {\n return $this->getType() === self::TYPE_CONFERENCE;\n }\n\n /**\n * Get a conference elapsed time in seconds.\n *\n * @return int seconds count\n */\n public function secondsTimeElapsed(): int\n {\n if (empty($this->actual_start_time)) {\n return 0;\n }\n\n // Get number of seconds since conference actual start time\n return (int) abs(Carbon::now()->diffInRealSeconds($this->actual_start_time));\n }\n\n /**\n * Get a conference elapsed time formatted as \"1:30:20\" if more than 1 hour or \"30:20\" otherwise.\n */\n public function formattedTimeElapsed(): string\n {\n // Get number of seconds since conference actual start time.\n $elapsedSeconds = $this->secondsTimeElapsed();\n $elapsedTime = Carbon::createFromTimestampUTC($elapsedSeconds);\n\n // Format conference start time.\n return $elapsedTime->format($elapsedSeconds < 3600 ? 'i:s' : 'G:i:s');\n }\n\n public function wasScheduled(): bool\n {\n return $this->calendarEvent !== null || in_array($this->getSource(), [self::SOURCE_OUTLOOK, self::SOURCE_GOOGLE]);\n }\n\n public function isInstant(): bool\n {\n return ! $this->wasScheduled();\n }\n\n /**\n * GETTERS AND SETTERS FOLLOW BELOW\n */\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getFromParticipantId(): ?int\n {\n return $this->getAttribute('from_participant_id');\n }\n\n public function getFromParticipant(): ?Participant\n {\n return $this->getAttribute('from');\n }\n\n public function getToParticipantId(): ?int\n {\n return $this->getAttribute('to_participant_id');\n }\n\n public function getToParticipant(): ?Participant\n {\n return $this->getAttribute('to');\n }\n\n public function hasScheduledStartTime(): bool\n {\n return $this->getAttribute('scheduled_start_time') !== null;\n }\n\n public function getScheduledStartTime(): ?Carbon\n {\n return $this->getAttribute('scheduled_start_time');\n }\n\n public function setScheduledStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_start_time', $dateTime);\n\n return $this;\n }\n\n public function getScheduledEndTime(): ?DateTimeInterface\n {\n return $this->getAttribute('scheduled_end_time');\n }\n\n public function hasScheduledEndTime(): bool\n {\n return $this->getAttribute('scheduled_end_time') !== null;\n }\n\n public function setScheduledEndTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_end_time', $dateTime);\n\n return $this;\n }\n\n public function getActualStartTime(): ?Carbon\n {\n return $this->getAttribute('actual_start_time');\n }\n\n public function hasActualStartTime(): bool\n {\n return $this->getAttribute('actual_start_time') !== null;\n }\n\n public function getActualEndTime(): ?Carbon\n {\n return $this->getAttribute('actual_end_time');\n }\n\n public function hasActualEndTime(): bool\n {\n return $this->getAttribute('actual_end_time') !== null;\n }\n\n public function getType(): ?string\n {\n return $this->getAttribute('type');\n }\n\n public function getStatus(): string\n {\n return $this->getAttribute('status');\n }\n\n public function setStatus(string $status): self\n {\n $this->setAttribute('status', $status);\n\n return $this;\n }\n\n public function setActualStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('actual_start_time', $dateTime);\n\n return $this;\n }\n\n public function setActualEndTime(DateTimeInterface $dateTime, bool $shouldUpdateDuration = true): self\n {\n $this->setAttribute('actual_end_time', $dateTime);\n\n if (! $shouldUpdateDuration) {\n return $this;\n }\n\n return $this->updateDuration();\n }\n\n public function updateDuration(): self\n {\n if (! $this->hasActualStartTime() || ! $this->hasActualEndTime()) {\n return $this;\n }\n\n return $this->setDuration(\n (int) abs($this->getActualStartTime()->diffInRealSeconds($this->getActualEndTime()))\n );\n }\n\n public function setDuration(int $duration): self\n {\n $this->setAttribute('duration', $duration);\n\n return $this;\n }\n\n public function getRecordingState(): string\n {\n return $this->getAttribute('recording_state');\n }\n\n public function isRecordingState(string $recordingState): bool\n {\n return $this->getRecordingState() === $recordingState;\n }\n\n public function setRecordingState(string $recordingState): self\n {\n $this->setAttribute('recording_state', $recordingState);\n\n return $this;\n }\n\n public function hasActivityType(): bool\n {\n return $this->getAttribute('category') !== null;\n }\n\n public function getActivityType(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function setActivityType(int $playbookCategoryId): self\n {\n $this->setAttribute('playbook_category_id', $playbookCategoryId);\n\n return $this;\n }\n\n public function hasStage(): bool\n {\n return $this->getAttribute('stage') !== null;\n }\n\n public function getStage(): ?Stage\n {\n return $this->getAttribute('stage');\n }\n\n public function getStageId(): ?int\n {\n return $this->getAttribute('stage_id');\n }\n\n public function setStageId(?int $stageId): void\n {\n $this->setAttribute('stage_id', $stageId);\n }\n\n public function hasOpportunity(): bool\n {\n return $this->getAttribute('opportunity') !== null;\n }\n\n public function getOpportunity(): ?Opportunity\n {\n return $this->getAttribute('opportunity');\n }\n\n public function getOpportunityId(): ?int\n {\n return $this->getAttribute('opportunity_id');\n }\n\n public function setOpportunityId(?int $opportunityId): void\n {\n $this->setAttribute('opportunity_id', $opportunityId);\n }\n\n public function hasContact(): bool\n {\n return $this->getAttribute('contact') !== null;\n }\n\n public function getContact(): ?Contact\n {\n return $this->getAttribute('contact');\n }\n\n public function getContactId(): ?int\n {\n return $this->getAttribute('contact_id');\n }\n\n public function setContactId(?int $contactId): void\n {\n $this->setAttribute('contact_id', $contactId);\n }\n\n public function hasLead(): bool\n {\n return $this->getAttribute('lead') !== null;\n }\n\n public function getLead(): ?Lead\n {\n return $this->getAttribute('lead');\n }\n\n public function getLeadId(): ?int\n {\n return $this->getAttribute('lead_id');\n }\n\n public function setLeadId(?int $leadId): void\n {\n $this->setAttribute('lead_id', $leadId);\n }\n\n public function hasAccount(): bool\n {\n return $this->getAttribute('account') !== null;\n }\n\n public function getAccount(): ?Account\n {\n return $this->getAttribute('account');\n }\n\n public function getAccountId(): ?int\n {\n return $this->getAttribute('account_id');\n }\n\n public function setAccountId(?int $accountId): void\n {\n $this->setAttribute('account_id', $accountId);\n }\n\n /**\n * This method exists to avoid confusion using ->participants() or ->participants. Use the getter instead.\n *\n * @return Collection<int, Participant>|Participant[]\n */\n public function getParticipants(): Collection\n {\n return $this->participants;\n }\n\n /**\n * @deprecated use ParticipantRepository::findParticipantRoomOwner() instead\n */\n public function findParticipantRoomOwner(): ?Participant\n {\n $roomOwnerId = $this->getUserId();\n\n return $this->getParticipants()\n ->filter(static fn (Participant $participant): bool => $participant->isSameUserId($roomOwnerId))\n ->first();\n }\n\n public function hasCrmProviderId(): bool\n {\n return $this->getAttribute('crm_provider_id') !== null;\n }\n\n public function getCrmProviderId(): ?string\n {\n return $this->getAttribute('crm_provider_id');\n }\n\n public function setCrmProviderId(?string $crmProviderId): void\n {\n $this->setAttribute('crm_provider_id', $crmProviderId);\n }\n\n public function getUserId(): ?int\n {\n return $this->getAttribute('user_id');\n }\n\n public function hasUser(): bool\n {\n return $this->user()->exists();\n }\n\n public function getUser(): User\n {\n return $this->getAttribute('user');\n }\n\n public function getCreatedAt(): Carbon\n {\n return $this->getAttribute('created_at');\n }\n\n public function isInFiniteState(): bool\n {\n return $this->isFiniteState($this->getStatus());\n }\n\n public function isFiniteState(string $status): bool\n {\n $finiteStates = self::FINITE_STATES[$this->getType()] ?? [];\n\n return in_array($status, $finiteStates, true);\n }\n\n public function getParticipant(Authenticatable $user): Participant\n {\n return $this->findParticipant($user);\n }\n\n public function findParticipant(Authenticatable $user): ?Participant\n {\n if ($user instanceof User) {\n /** @var User $user */\n return $this->participants()->where('user_id', '=', $user->getId())->first();\n }\n\n throw new LogicException(sprintf('Unsupported Authenticatable implementation %s', get_class($user)));\n }\n\n public function hasLanguageCode(): bool\n {\n return $this->getAttribute('language') !== null;\n }\n\n public function getLanguageCode(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('language');\n }\n\n public function getLanguageCodeHyphenated(): string\n {\n return str_replace('_', '-', $this->getLanguageCode() ?? '');\n }\n\n public function getLanguageCodeLocale(): string\n {\n [ $language ] = explode('_', $this->getLanguageCode() ?? '');\n\n return $language;\n }\n\n public function setLanguageCode(string $value): self\n {\n return $this->setAttribute('language', $value);\n }\n\n public function hasSource(): bool\n {\n return $this->getAttribute('source') !== null;\n }\n\n public function setSource(?string $source): self\n {\n return $this->setAttribute('source', $source);\n }\n\n public function isSource(string $source): bool\n {\n return $this->getAttribute('source') === $source;\n }\n\n public function getSource(): ?string\n {\n return $this->getAttribute('source');\n }\n\n public function isSourceGong(): bool\n {\n return $this->isSource(self::SOURCE_GONG);\n }\n\n public function getExternalId(): ?string\n {\n return $this->getAttribute('external_id');\n }\n\n public function setExternalId(?string $externalId): self\n {\n return $this->setAttribute('external_id', $externalId);\n }\n\n public function hasExternalId(): bool\n {\n return $this->getAttribute('external_id') !== null;\n }\n\n public function getProvider(): string\n {\n return $this->getAttribute('provider');\n }\n\n public function hasTelephonyProviderId(): bool\n {\n return $this->getAttribute('telephony_provider_id') !== null;\n }\n\n public function getTelephonyProviderId(): ?string\n {\n return $this->getAttribute('telephony_provider_id');\n }\n\n public function setTelephonyProviderId(?string $telephonyProviderId): self\n {\n return $this->setAttribute('telephony_provider_id', $telephonyProviderId);\n }\n\n public function getLocation(): ?string\n {\n return $this->getAttribute('location');\n }\n\n public function setLocation(?string $location): self\n {\n return $this->setAttribute('location', $location);\n }\n\n public function isDeleted(): bool\n {\n return $this->getAttribute('deleted_at') !== null;\n }\n\n /**\n * Check if activity recording is on and activity status is not one of the failed statuses.\n */\n public function canReviewActivity(): bool\n {\n $failedStatuses = self::$enumFailedStatuses;\n\n return (! in_array($this->recording_state, [self::RECORDING_OFF, self::RECORDING_STOPPED], true) &&\n ! in_array($this->status, $failedStatuses, true));\n }\n\n public function hasReasonCodeBotKicked(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_MEETING_BOT_KICKED);\n }\n\n public function hasReasonCodeNotCompliant(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_CONSENT_DENIED);\n }\n\n public function hasTopicTriggers(): bool\n {\n return $this->topicTriggers()->count() !== 0;\n }\n\n public function getTopicTriggers(): Collection\n {\n return $this->topicTriggers;\n }\n\n public function getTopicTriggersSorted(): Collection\n {\n $this->loadMissing([\n 'topicTriggers.participant',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme',\n ]);\n\n return $this->topicTriggers\n ->sortBy([\n 'playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme.sort',\n 'playbackThemeTopicTrigger.playbackThemeTopic.sort',\n 'playbackThemeTopicTrigger.sort',\n ]);\n }\n\n public function hasQuestions(): bool\n {\n return $this->questions()->exists();\n }\n\n public function getQuestions(): Collection\n {\n return $this->questions;\n }\n\n public function hasValue(): bool\n {\n return $this->getAttribute('value') !== null;\n }\n\n public function getValue(): ?float\n {\n return $this->getAttribute('value');\n }\n\n public function setValue(?float $value): void\n {\n $this->setAttribute('value', $value);\n }\n\n public function transitionTo(string $newState, callable $callback, ?int $timeout = null): self\n {\n $newState = $this->getWorkflowStateFor(\n $this->getType(),\n $newState\n );\n\n return $this->traitTransitionTo($newState, $callback, $timeout);\n }\n\n public function getWorkflowState(): string\n {\n return $this->getWorkflowStateFor(\n $this->getType(),\n $this->getStatus()\n );\n }\n\n public function getActivityProviderDisplayName(): string\n {\n return \\Cache::remember('activity_provider_display_name-' . $this->getProvider(), 60 * 60 * 24, function () {\n $activityProviderRegistry = app()->make(ActivityProviderRegistry::class);\n\n try {\n return $activityProviderRegistry->get($this->getProvider())->getDisplayName();\n } catch (Exception $exception) {\n return ucfirst($this->getProvider());\n }\n });\n }\n\n private function getWorkflowStateFor(string $activityChannel, string $activityStatus): string\n {\n return sprintf(\n '%s::%s',\n $activityChannel,\n $activityStatus\n );\n }\n\n public function getWorkflow(): array\n {\n $map = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_SCHEDULED => [\n self::STATUS_PENDING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_PENDING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_RINGING => [\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_IN_PROGRESS,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_RINGING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_NO_ANSWER,\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n ];\n\n return collect($map)\n ->mapWithKeys(function (array $currentStates, string $activityChannel): array {\n return [\n $activityChannel => collect($currentStates)\n ->mapWithKeys(function (array $possibleStates, $currentState) use ($activityChannel): array {\n $transitionName = $this->getWorkflowStateFor($activityChannel, $currentState);\n\n return [\n $transitionName => array_map(function (string $newState) use ($activityChannel) {\n return $this->getWorkflowStateFor($activityChannel, $newState);\n }, $possibleStates),\n ];\n }),\n ];\n })\n ->reduce(static function (array $carry, Collection $item): array {\n return array_merge($carry, $item->all());\n }, []);\n }\n\n public function hasPosterPath(): bool\n {\n return $this->getAttribute('poster_path') !== null;\n }\n\n public function getPosterPath(): ?string\n {\n return $this->getAttribute('poster_path');\n }\n\n /**\n * Take into account all recording settings and determine if we need to record this activity or not.\n */\n public function shouldRecord(): bool\n {\n return $this->determineRecordingReasonCode() === null;\n }\n\n public function determineRecordingReasonCode(): ?int\n {\n // Conference specific decisions.\n if ($this->isTypeConference()) {\n // If they have manually overridden the recording setting to not record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === false) {\n return self::FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE;\n }\n\n // If they have manually overridden the recording setting to record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === true) {\n return null;\n }\n\n // If their team has disabled recording meetings, don't record.\n if ($this->user->team->isConferenceRecordPreferenceDisabled()) {\n return self::FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED;\n }\n\n // If the host has disabled recording meetings, don't record.\n if ($this->user->checkConferenceRecordPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED;\n }\n\n // If it was marked internal...\n if ($this->is_internal) {\n // and their team has disabled recording internal meetings, don't record.\n if (\n $this->user->team->isConferenceRecordPreferenceEnabled()\n && ! $this->user->team->isConferenceRecordInternalPreferenceEnabled()\n ) {\n return self::FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED;\n }\n\n // and the host has disabled recording internal meetings, don't record.\n if ($this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED;\n }\n }\n\n // If it was not scheduled and they disabled internal meetings, we cannot determine if it was internal.\n if ($this->wasScheduled() === false && $this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED;\n }\n }\n\n return null;\n }\n\n public function getRecordingReasonCode(): int\n {\n return $this->getAttribute('recording_reason_code');\n }\n\n public function setRecordingReasonCode(int $recordingReasonCode): self\n {\n $this->setAttribute('recording_reason_code', $recordingReasonCode);\n\n return $this;\n }\n\n // Not used today.\n public function getRecordingReasonString(): ?string\n {\n if ($this->hasRecordingReasonCompliancePrompted()) {\n return Team::COMPLIANCE_MODE_RECORDING_PROMPT;\n }\n\n if ($this->hasRecordingReasonComplianceRestricted()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT;\n }\n\n if ($this->hasRecordingReasonComplianceRestrictedToOneSideRecording()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT_ONE_SIDE;\n }\n\n return null;\n }\n\n public function hasRecordingReasonComplianceRestricted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT);\n }\n\n public function hasRecordingReasonCompliancePrompted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_PROMPT);\n }\n\n public function hasRecordingReasonComplianceRestrictedToOneSideRecording(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE);\n }\n\n public function getAudioTrack(): ?Track\n {\n /** @var Track|null */\n return $this->tracks()\n ->where('type', '=', Track::TYPE_AUDIO)\n ->first();\n }\n\n public function activeParticipants(): HasMany\n {\n return $this->hasMany(Participant::class)->active();\n }\n\n public function getActiveParticipants(): Eloquent\\Collection\n {\n return $this->getAttribute('activeParticipants');\n }\n\n public function crm(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Configuration::class, 'crm_configuration_id');\n }\n\n public function activitySummaryLogs(): HasMany\n {\n return $this->hasMany(ActivitySummaryLog::class);\n }\n\n public function getCrm(): ?Configuration\n {\n return $this->getAttribute('crm');\n }\n\n public function hasCrmConfiguration(): bool\n {\n return $this->getAttribute('crm') !== null;\n }\n\n public function isProcessed(): ?bool\n {\n return $this->getAttribute('is_processed');\n }\n\n public function hasRecordingPrompt(): bool\n {\n return $this->getAttribute('has_recording_prompt') === true;\n }\n\n public function isOnAir(): bool\n {\n return $this->getAttribute('on_air') === self::ON_AIR_READY || $this->getAttribute('on_air') === self::ON_AIR_STREAMING;\n }\n\n public function setOnAir(int $onAir): self\n {\n $this->setAttribute('on_air', $onAir);\n\n return $this;\n }\n\n public function getOnAir(): ?int\n {\n return $this->getAttribute('on_air');\n }\n\n public function setTitleFromCallData(Call $call): void\n {\n $direction = $call->isOutbound() ? 'to' : 'from';\n\n $party = $this->prospect_name\n ?? $call->getContactName()\n ?? $call->getOtherPartyPhoneNumber()\n ;\n\n $this->update(['title' => sprintf('Call %s %s', $direction, $party)]);\n }\n\n /**\n * @param array{}|array{channels:string|null, format:string|null, type:string|null, status:string|null} $audioParams\n */\n public function createAudioTrack(\n string $telephonyProviderId,\n string $recordingUrl,\n array $audioParams = []\n ): Track {\n return $this->tracks()->updateOrCreate([\n 'telephony_provider_id' => $telephonyProviderId,\n ], [\n 'type' => $audioParams['type'] ?? Track::TYPE_AUDIO,\n 'status' => $audioParams['status'] ?? Track::STATUS_PENDING,\n 'format' => $audioParams['format'] ?? Track::FORMAT_WAV,\n 'provider_content_url' => $recordingUrl,\n 'start_time' => $this->actual_start_time,\n 'end_time' => $this->actual_end_time,\n ]);\n }\n\n public function createTrack(string $telephonyProviderId, array $params): Track\n {\n return $this->tracks()->updateOrCreate(\n [\n 'telephony_provider_id' => $telephonyProviderId,\n ],\n $params\n );\n }\n\n public function createOrganiserParticipant(Call $call): Participant\n {\n $user = $this->getUser();\n\n return $this->updateOrCreateParticipant([\n 'is_ghost' => 0,\n 'name' => $user->name,\n 'email' => $user->email,\n 'phone_number' => phone_e164(null, $call->getUserPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'user_id' => $user->id,\n ], false);\n }\n\n public function createProspectParticipant(Call $call): Participant\n {\n // not null 'name' is mandatory here to create a separate participant with 'nameMatching'\n // in case of the same phone_number with the Organiser\n $useNameMatching = $call->getUserPhoneNumber() === $call->getOtherPartyPhoneNumber();\n $defaultName = $useNameMatching ? '' : null;\n\n return $this->updateOrCreateParticipant(data: [\n 'is_ghost' => 0,\n 'name' => $this->prospect->name ?? $defaultName,\n 'email' => $this->prospect->email ?? null,\n 'phone_number' => phone_e164(null, $call->getOtherPartyPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'contact_id' => $this->contact_id ?? null,\n 'lead_id' => $this->lead_id ?? null,\n ], enterRoom: false, nameMatching: $useNameMatching);\n }\n\n public function updateParticipants(Participant $organiserParticipant, Participant $prospectParticipant): void\n {\n $this->update([\n 'from_participant_id' => $this->isTypeSoftPhone() ? $organiserParticipant->id : $prospectParticipant->id,\n 'to_participant_id' => $this->isTypeSoftPhone() ? $prospectParticipant->id : $organiserParticipant->id,\n ]);\n }\n\n public function hasProspect(): bool\n {\n return $this->getProspectAttribute() !== null;\n }\n\n public function isPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n /** Create a new factory instance for the model. */\n protected static function newFactory(): Factory\n {\n return ActivityFactory::new();\n }\n\n public function getUpdatedAt(): Carbon\n {\n return $this->getAttribute('updated_at');\n }\n\n public function getActivitySummaryLogs(): Eloquent\\Collection\n {\n return $this->getAttribute('activitySummaryLogs');\n }\n\n public function hasProspectActivitySummaryLog(): bool\n {\n return $this->getActivitySummaryLogs()->contains(\n 'relation_type',\n ActivitySummaryLog::RELATION_OBJECT_TYPE_PROSPECT\n );\n }\n\n public function getTeam(): Team\n {\n return $this->getUser()->getTeam();\n }\n\n private function getUpdateCrmDataResolver(): UpdateCrmDataResolverInterface\n {\n $factory = app(UpdateCrmDataResolverFactory::class);\n\n return $factory->create($this);\n }\n\n public function getMeetingTrackProviderId(string $type): string\n {\n $label = match ($type) {\n Track::TYPE_VIDEO => 'v',\n Track::TYPE_AUDIO => 'a',\n default => throw new InvalidArgumentJiminnyException('Invalid track type'),\n };\n\n $startTimestamp = $this->getScheduledStartTime()?->getTimestamp();\n $teamId = $this->getTeam()->getId();\n\n return $this->getTelephonyProviderId() . ':' . $label . ':' . $startTimestamp . ':' . $teamId;\n }\n\n /**\n * Get all consent records associated with this activity\n *\n * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasMany\n */\n public function participantConsents(): HasMany\n {\n return $this->hasMany(Participant\\Consent::class);\n }\n\n public function isDiallerCall(): bool\n {\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return false;\n }\n\n if (! in_array($this->getType(), [self::TYPE_SOFTPHONE, self::TYPE_SOFTPHONE_INBOUND])) {\n return false;\n }\n\n return $this->getProvider() !== self::PROVIDER_TWILIO;\n }\n\n public function getActivityDateWithFallback(): Carbon\n {\n if ($this->getActualStartTime() !== null) {\n return $this->getActualStartTime();\n }\n\n if ($this->getScheduledStartTime() !== null) {\n return $this->getScheduledStartTime();\n }\n\n return $this->getCreatedAt();\n }\n\n public function getCrmType(): ?string\n {\n // Treat uploader activities as conferences\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return Activity::TYPE_CONFERENCE;\n }\n\n return $this->getType();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8376151907542764157
|
8179532969745786684
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
169
4
102
4
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Models;
use Carbon\Carbon;
use Database\Factories\ActivityFactory;
use DateTimeInterface;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use InvalidArgumentException;
use Jiminny\Component\ElasticSearch;
use Jiminny\Component\MeetingBot;
use Jiminny\Component\Model\BitwiseFlagTrait;
use Jiminny\Component\PlaybackPage\Comments\Services\ActivityCommentService;
use Jiminny\Component\Sidekick\SidekickService;
use Jiminny\Component\Uuid\UuidAwareInterface;
use Jiminny\Component\Workflow;
use Jiminny\Contracts;
use Jiminny\Contracts\Crm\ProspectInterface;
use Jiminny\DTO\ImportCall\Call;
use Jiminny\Events\Activities\ActivityTypeUpdated;
use Jiminny\Events\Activities\ActivityUpdated;
use Jiminny\Events\Activities\ProspectUpdated;
use Jiminny\Events\Activities\StageUpdated;
use Jiminny\Events\Activities\StatusUpdated;
use Jiminny\Events\Activities\TitleUpdated;
use Jiminny\Exceptions\InvalidArgumentException as InvalidArgumentJiminnyException;
use Jiminny\Exceptions\LogicException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models;
use Jiminny\Models\Activity\ActivitySummaryLog;
use Jiminny\Models\Activity\ActivityUploadSetting;
use Jiminny\Models\Activity\AvailabilityNotification;
use Jiminny\Models\Activity\CoachRequest;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\Activity\Log;
use Jiminny\Models\Activity\Message;
use Jiminny\Models\Activity\Moment;
use Jiminny\Models\Activity\Note;
use Jiminny\Models\Activity\ParticipantSpeech;
use Jiminny\Models\Activity\Play;
use Jiminny\Models\Activity\Question;
use Jiminny\Models\Activity\Share;
use Jiminny\Models\Activity\Snapshot;
use Jiminny\Models\Activity\Stats;
use Jiminny\Models\Activity\SubscriptionSet;
use Jiminny\Models\Activity\TopicTrigger;
use Jiminny\Models\Activity\Transcription;
use Jiminny\Models\Calendar\CalendarEvent;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\FieldData;
use Jiminny\Models\ElasticSearch\ActivityElasticSearchTrait;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Participant\Connection;
use Jiminny\Models\Playlist\Activity as PlaylistActivity;
use Jiminny\Services\Activity\ActivityProviderRegistry;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataByStrategy;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverFactory;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverInterface;
use Jiminny\Traits\Enums;
use Jiminny\Traits\RequiresUUID;
use Jiminny\Utils\CurrencyFormatter;
use NumberFormatter;
use function in_array;
/**
* Jiminny\Models\Activity
*
* @property null|int $auto_score filled from ES hydrator, not in DB!
* @property-read Account|null $account
* @property-read CalendarEvent|null $calendarEvent
* @property-read Contact|null $contact
* @property-read Lead|null $lead
* @property-read Opportunity|null $opportunity
* @property-read Stage|null $stage
* @property int $id
* @property mixed|null $uuid
* @property string|null $source
* @property string|null $external_id
* @property string $provider
* @property string|null $location
* @property string|null $telephony_provider_id
* @property int|null $from_participant_id
* @property int|null $to_participant_id
* @property int|null $device_id
* @property string|null $type
* @property int|null $playbook_category_id
* @property int $user_id
* @property int|null $lead_id
* @property int|null $account_id
* @property int|null $contact_id
* @property int|null $opportunity_id
* @property int|null $stage_id
* @property string|null $value
* @property int|null $crm_configuration_id
* @property string|null $crm_provider_id
* @property string|null $language
* @property int|null $transcription_id
* @property int $duration
* @property string $status
* @property int|null $on_air
* @property int|null $calendar_event_id
* @property string $recording_state
* @property bool|null $recording_preference
* @property int $recording_reason_code
* @property int $summary_reminder_sent
* @property \Illuminate\Support\Carbon|null $log_reminder_sent_at
* @property \Illuminate\Support\Carbon|null $organizer_notified_at
* @property bool|null $has_recording_prompt
* @property bool $is_internal
* @property int $is_locked
* @property int $is_recording
* @property bool|null $is_processed
* @property bool $is_private
* @property bool $is_instant_invite
* @property string|null $poster_path
* @property string|null $summary
* @property string|null $title
* @property string|null $description
* @property \Illuminate\Support\Carbon|null $scheduled_start_time
* @property \Illuminate\Support\Carbon|null $scheduled_end_time
* @property \Illuminate\Support\Carbon|null $actual_start_time
* @property \Illuminate\Support\Carbon|null $actual_end_time
* @property int|null $uploaded_by
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $average_score
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $activeParticipants
* @property-read int|null $active_participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers
* @property-read int|null $activity_scorecard_rule_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRule> $activityScorecardRules
* @property-read int|null $activity_scorecard_rules_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, AvailabilityNotification> $availabilityNotifications
* @property-read int|null $availability_notifications_count
* @property-read \Jiminny\Models\PlaybookCategory|null $category
* @property-read \Illuminate\Database\Eloquent\Collection<int, CoachRequest> $coachRequests
* @property-read int|null $coach_requests_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $coachingFeedbacks
* @property-read int|null $coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $coachingMessages
* @property-read int|null $coaching_messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $comments
* @property-read int|null $comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Connection> $connections
* @property-read int|null $connections_count
* @property-read Configuration|null $crm
* @property-read \Illuminate\Database\Eloquent\Collection<int, FieldData> $data
* @property-read int|null $data_count
* @property-read \Jiminny\Models\Device|null $device
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $favoritePlaylists
* @property-read int|null $favorite_playlists_count
* @property-read \Jiminny\Models\Participant|null $from
* @property-read string|null $activity_title
* @property-read mixed $comment_count
* @property-read mixed $duration_for_humans
* @property-read string $duration_for_humans_short
* @property-read int $favorite_count
* @property-read mixed $favorites_count
* @property-read mixed $formatted_value
* @property-read string $id_string
* @property-read \Jiminny\Models\Participant|null $organizer
* @property-read mixed $play_count
* @property-read int|null $plays_count
* @property-read ?ProspectInterface $prospect
* @property-read string|null $prospect_name
* @property-read mixed $prospect_type
* @property-read mixed $share_count
* @property-read int|null $shares_count
* @property-read int|null $tracks_with_telephony_count
* @property-read int|null $visible_comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $latestCoachingFeedbacks
* @property-read int|null $latest_coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Log> $logs
* @property-read int|null $logs_count
* @property-read \Jiminny\Models\Track|null $masterTrack
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $messages
* @property-read int|null $messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Moment> $moments
* @property-read int|null $moments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Note> $notes
* @property-read int|null $notes_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\Share> $participantShares
* @property-read int|null $participant_shares_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, ParticipantSpeech> $participantSpeeches
* @property-read int|null $participant_speeches_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\ParticipantStats> $participantStats
* @property-read int|null $participant_stats_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $participants
* @property-read int|null $participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, PlaylistActivity> $playlistActivities
* @property-read int|null $playlist_activities_count
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $playlists
* @property-read int|null $playlists_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Play> $plays
* @property-read \Illuminate\Database\Eloquent\Collection<int, Question> $questions
* @property-read int|null $questions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Session> $sessions
* @property-read int|null $sessions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Share> $shares
* @property-read \Illuminate\Database\Eloquent\Collection<int, Snapshot> $snapshots
* @property-read int|null $snapshots_count
* @property-read Stats|null $stats
* @property-read \Jiminny\Models\Participant|null $to
* @property-read \Illuminate\Database\Eloquent\Collection<int, TopicTrigger> $topicTriggers
* @property-read int|null $topic_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracks
* @property-read int|null $tracks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracksWithTelephony
* @property-read Transcription|null $transcription
* @property-read \Jiminny\Models\User $user
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $visibleComments
*
* @method static \Illuminate\Database\Eloquent\Collection<int, static> all($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)
* @method static \Database\Factories\ActivityFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Collection<int, static> get($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity heldBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity idOrUuId($idOrUuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity newModelQuery()
* @method static \Jiminny\Component\Eloquent\Builder|Activity newQuery()
* @method static Builder|Activity onlyTrashed()
* @method static \Jiminny\Component\Eloquent\Builder|Activity query()
* @method static \Jiminny\Component\Eloquent\Builder|Activity scheduledBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity inOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity notInOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity forTeam(int $teamId)
* @method static \Jiminny\Component\Eloquent\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity uuid(string $uuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAccountId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAverageScore($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCalendarEventId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereContactId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCreatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmConfigurationId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeletedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDescription($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeviceId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDuration($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereFromParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereHasRecordingPrompt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInstantInvite($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInternal($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsLocked($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsPrivate($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsProcessed($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsRecording($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLanguage($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLeadId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLocation($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLogReminderSentAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOnAir($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOpportunityId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOrganizerNotifiedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePlaybookCategoryId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePosterPath($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereProvider($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingPreference($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingReasonCode($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingState($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSource($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereExternalId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStageId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStatus($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummary($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummaryReminderSent($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTelephonyProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTitle($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereToParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTranscriptionId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereType($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUpdatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUploadedBy($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUserId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUuid($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereValue($value)
* @method static Builder|Activity withTrashed()
* @method static Builder|Activity withoutTrashed()
*
* @mixin \Eloquent
*/
class Activity extends Model implements
ElasticSearch\Contract\Searchable,
Workflow\Workflow\WorkflowAwareInterface,
Models\Contracts\ActivityContract,
Contracts\Model\ActivityInterface,
UuidAwareInterface
{
use HasFactory;
use Enums;
use SoftDeletes;
use RequiresUUID;
use BitwiseFlagTrait;
use ElasticSearch\Model\Searchable;
use ActivityElasticSearchTrait;
use Workflow\Workflow\WorkflowAware {
transitionTo as traitTransitionTo;
}
public const int FLAG_RECORDING_REASON_DEFAULT = 0;
// Recording Prompted but never started
public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;
public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;
// Recording Disabled by Organization
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;
// Recording was restricted to one-side recordings only
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;
// Recording was not started because it was internal and team setting disabled that.
public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;
// Recording was not started because it was internal and user setting disabled that.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;
// Recording was not started because user setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;
// Recording was not started because team setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;
// Recording was not started because user has overriden default.
public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;
// Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;
// Recording was not started because their team setting does excludes the meeting type.
public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;
// Recording was not started because the external provider disabled it (or recording is missing etc).
public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;
// Recording was stopped externally ("exit-meeting" Pusher event)
public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;
// Recording couldn't be started due to Zoom hosting conflict error
public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;
// meeting.failed event with reason code BOT_DENIED_FROM_LOBBY
public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;
// meeting.failed event with reason code LOBBY_TIMEOUT
public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;
// meeting.failed event with reason code BOT_KICKED
public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;
// meeting.failed event with reason code UNKNOWN
public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;
public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;
// Invalid meeting (e.g. URL is invalid, or the meeting is not found)
public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;
// The host stopped the recording.
public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;
// Recording was not started because an alternative vendor disabled it (or overrode it).
public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;
// Login required meeting.failed code
public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;
// Password for meeting was not provided - meeting.failed code
public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;
// meeting.failed - when the meeting is locked
public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;
// max recording duration reached
public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;
// recording size is too small
public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;
// meeting.failed - when bot is redirected to sign in page multiple times
public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;
// meeting.failed event with reason code CONNECTION_LOST
public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;
// recording is corrupted.
public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;
// meeting ended in lobby
public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;
// meeting not started
public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;
// unfinished zoom custom disclaimer
public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;
// recording download failed - server error
public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;
// recording download failed - client code 404
public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;
// recording download failed - client code 401, 403
public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;
// recording download failed - client code 429
public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;
// recording download failed - unknown client error
public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;
// recording download failed - unknown error
public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;
// It has been setup ahead of time through calendar
public const string STATUS_SCHEDULED = 'scheduled';
// It is awaiting audio.
public const string STATUS_PENDING = 'pending';
// Participant(s) dialed in, awaiting organizer.
public const string STATUS_RINGING = 'ringing';
// Call is in progress.
public const string STATUS_IN_PROGRESS = 'in-progress';
// It has ended.
public const string STATUS_COMPLETED = 'completed';
// Cancelled prior to starting.
public const string STATUS_CANCELLED = 'canceled';
public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference
public const string STATUS_STARTING_SOON = 'starting-soon';
public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';
public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';
public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';
// When bot instance is waiting in lobby
public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';
public const string STATUS_BUSY = 'busy';
public const string STATUS_NO_ANSWER = 'no-answer';
public const string STATUS_FAILED = 'failed'; // Used by SMS too
// SMS related
public const string STATUS_ACCEPTED = 'accepted';
public const string STATUS_QUEUED = 'queued';
public const string STATUS_SENDING = 'sending';
public const string STATUS_SENT = 'sent';
public const string STATUS_DELIVERED = 'delivered';
public const string STATUS_UNDELIVERED = 'undelivered';
public const string STATUS_RECEIVING = 'receiving';
public const string STATUS_RECEIVED = 'received';
public const string STATUS_RESENT = 'resent';
public const array SMS_STATUSES = [
Activity::STATUS_RECEIVED,
Activity::STATUS_SENT,
Activity::STATUS_DELIVERED,
];
public const array SOFT_PHONE_CONFERENCE_STATUSES = [
Activity::STATUS_IN_PROGRESS,
Activity::STATUS_COMPLETED,
];
// @todo refactor prefix from `TYPE_` to `CHANNEL_`
public const string TYPE_SOFTPHONE = 'softphone';
public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';
public const string TYPE_CONFERENCE = 'conference';
public const string TYPE_SMS_INBOUND = 'sms-inbound';
public const string TYPE_SMS_OUTBOUND = 'sms-outbound';
public const string TYPE_EMAIL_INBOUND = 'email-inbound';
public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';
public const array CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
public const array PLAYABLE_CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
];
// Recording States
public const string RECORDING_OFF = 'off'; // Default state
public const string RECORDING_IN_PROGRESS = 'in-progress';
public const string RECORDING_PAUSED = 'paused';
public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.
public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.
public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.
// Live Stream States
public const int ON_AIR_DEFAULT = 0;
public const int ON_AIR_READY = 1;
public const int ON_AIR_PREPARING = 2;
public const int ON_AIR_STREAMING = 3;
public const int ON_AIR_FINISHED = 4;
public const int ON_AIR_NOT_STREAMED = 5;
public const int ON_AIR_ERROR = -1;
public const string SOURCE_GONG = 'gong';
public const string SOURCE_CHORUS = 'chorus';
public const string SOURCE_OUTLOOK = 'outlook';
public const string SOURCE_GOOGLE = 'google';
// Activity Providers
public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.
public const string PROVIDER_OUTREACH = 'outreach';
public const string PROVIDER_ZOOM_BOT = 'zoom-bot';
public const string PROVIDER_SALESLOFT = 'salesloft';
public const string PROVIDER_GOOGLE = 'google';
public const string PROVIDER_AIRCALL = 'aircall';
public const string PROVIDER_JUSTCALL = 'justcall';
public const string PROVIDER_GOOGLE_MEET = 'google-meet';
public const string PROVIDER_GONG = 'gong';
public const string PROVIDER_HUBSPOT = 'hubspot';
public const string PROVIDER_CLOSE = 'close';
public const string PROVIDER_TEAMS = 'ms-teams';
public const string PROVIDER_SALESFORCE = 'salesforce';
public const string PROVIDER_GROOVE = 'groove';
public const string PROVIDER_XANT = 'xant';
public const string PROVIDER_OFFICE = 'office';
public const string PROVIDER_NATTERBOX = 'natterbox';
public const string PROVIDER_RINGCENTRAL = 'ringcentral';
public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';
public const string PROVIDER_GOTOMEETING = 'go-to-meeting';
public const string PROVIDER_DEMODESK = 'demo-desk';
public const string PROVIDER_DIALPAD = 'dialpad';
public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';
public const string PROVIDER_CLOUDCALL = 'cloudcall';
public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';
public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // "8x8" UK
public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // "8x8" Canada
public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // "8x8" Australia
public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // "8x8" US East
public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // "8x8" US West
public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';
public const string PROVIDER_CLOUD_TALK = 'cloud-talk';
public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';
public const string PROVIDER_VONAGE = 'vonage';
public const string PROVIDER_MIGRATOR = 'migrator';
public const string PROVIDER_UPLOADER = 'uploader';
public const string PROVIDER_TALKDESK = 'talkdesk';
public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';
public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';
public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';
public const string PROVIDER_AVAYA = 'avaya';
public const string PROVIDER_TELUS = 'telus';
public const string PROVIDER_FIVE_NINE = 'five-nine';
public const string PROVIDER_APOLLO = 'apollo';
public const string PROVIDER_ORUM = 'orum';
public const string PROVIDER_BLOOBIRDS = 'bloobirds';
/**
* @const API_PROVIDERS
* A list of integrations that import calls via API instead of webhooks
*/
public const array API_PROVIDERS = [
self::PROVIDER_OUTREACH,
self::PROVIDER_SALESLOFT,
self::PROVIDER_HUBSPOT,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_NATTERBOX,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
];
public const array FINITE_STATES = [
self::TYPE_SOFTPHONE => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_SOFTPHONE_INBOUND => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,
];
public const array FINITE_STATES_CONFERENCE = [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_CANCELLED,
];
public const array MEETING_BOT_JOIN_ATTEMPTED = [
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_BOT_INSTANCE_STARTED,
];
public static array $enumStatuses = [
self::STATUS_SCHEDULED,
self::STATUS_PENDING,
self::STATUS_RINGING,
self::STATUS_IN_PROGRESS,
self::STATUS_COMPLETED,
self::STATUS_CANCELLED,
self::STATUS_BUSY,
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_ACCEPTED,
self::STATUS_QUEUED,
self::STATUS_SENDING,
self::STATUS_SENT,
self::STATUS_RESENT,
self::STATUS_DELIVERED,
self::STATUS_UNDELIVERED,
self::STATUS_RECEIVING,
self::STATUS_RECEIVED,
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_STARTING_SOON,
self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,
self::STATUS_BOT_INSTANCE_STARTED,
self::STATUS_DUPLICATED,
];
public static array $enumProviders = [
self::PROVIDER_TWILIO,
self::PROVIDER_OUTREACH,
self::PROVIDER_ZOOM_BOT,
self::PROVIDER_SALESLOFT,
self::PROVIDER_AIRCALL,
self::PROVIDER_JUSTCALL,
self::PROVIDER_GOOGLE_MEET,
self::PROVIDER_GONG,
self::PROVIDER_HUBSPOT,
self::PROVIDER_CLOSE,
self::PROVIDER_TEAMS,
self::PROVIDER_SALESFORCE,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_GOOGLE,
self::PROVIDER_OFFICE,
self::PROVIDER_NATTERBOX,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_RINGCENTRAL_VIDEO,
self::PROVIDER_GOTOMEETING,
self::PROVIDER_DEMODESK,
self::PROVIDER_DIALPAD,
self::PROVIDER_ZOOM_PHONE,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
];
public static $enumRecordingStates = [
self::RECORDING_OFF, // Default state
self::RECORDING_IN_PROGRESS,
self::RECORDING_PAUSED,
self::RECORDING_STOPPED,
self::RECORDING_RECORDED,
self::RECORDING_FAILED,
];
// @Important:
// This collection is not used anywhere, and is fully duplicated by the Channels const.
// Validate if it is referred somehow via the enum trait, and if not, remove it entirely.
// An even better strategy will be to move all those constants to a dedicated class
protected array $enumTypes = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
protected static $enumFailedStatuses = [
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_BUSY,
self::STATUS_CANCELLED,
];
protected $table = 'activities';
protected $fillable = [
// Type of activity.
'type', // @todo refactor to `channel`
// The activity type.
'playbook_category_id',
// User who hosts the activity.
'user_id',
// Related Lead record (if applicable)
'lead_id',
// Related Account record (if applicable)
'account_id',
// Related Contact record (if applicable)
'contact_id',
// Related Opportunity record (if applicable)
'opportunity_id',
// Stage of activity.
'stage_id',
// Value of opportunity.
'value',
// If the activity relates to a CRM task.
'crm_provider_id',
// If the activity was created through an external device.
'device_id',
// the activity's language code
'language',
// transcription id
'transcription_id',
// Duration of the call, with microseconds precision.
'duration',
// One of enumStatuses above.
'status',
// Have we reminded them to log the call?
'log_reminder_sent_at',
// If activity is private or inter-org, flagged here.
'is_internal',
// Managers and above can mark a call as private, to exclude it from other team members
'is_private',
'is_processed',
// Boolean for this activity being instant invite handled.
'is_instant_invite',
// If activity is in recording state, flagged here.
'recording_state',
// If activity recording is overidden from default.
'recording_preference',
// if recording did (not) happen, why that is
'recording_reason_code',
// Average score, updated during
'average_score',
// Summary that the organizer has taken after the call.
'summary',
// Subject of the activity, usually taken from calendar event.
'title',
// Description of the activity, usually taken from calendar event.
'description',
// Start time, usually taken from calendar event.
'scheduled_start_time',
// End time, usually taken from calendar event.
'scheduled_end_time',
// When the call actually started.
'actual_start_time',
// When the call actually ended.
'actual_end_time',
// SMS: Message reference
'telephony_provider_id',
// SMS: Participant who sent message
'from_participant_id',
// SMS: Participant who should receive the message
'to_participant_id',
// When an external guest joins an organizers meeting room and the organizer is not present,
// send them an SMS notification that someone has joined.
'organizer_notified_at',
// where was the activity imported from
'source',
// The id in the source system (e.g. the bot id in Recall.ai)
'external_id',
// The provider, by default it is twilio.
'provider',
// Meeting location url
'location',
// The snapshot for displaying a poster image.
'poster_path',
'crm_configuration_id',
// If there is an automated message that the conversation is being recorded
'has_recording_prompt',
// If the activity is being live-streamed
'on_air',
'calendar_event_id',
];
protected $appends = [
'id_string',
'organizer',
];
protected $hidden = [
'uuid',
];
protected $visible = [
'id_string',
'type',
'duration',
'average_score',
'status',
'log_reminder_sent_at',
'title',
'description',
'is_internal',
'scheduled_start_time',
'scheduled_end_time',
'actual_start_time',
'actual_end_time',
'user',
'category',
'account',
'contact',
'opportunity',
'lead',
'stage',
'stats',
'participants',
'playlists',
'tracks',
'comments',
'plays',
'coachingFeedbacks',
'shares',
'favorites',
'language',
'transcription',
'is_private',
'is_instant_invite',
'on_air',
'calendar_event_id',
];
protected function casts(): array
{
return [
'scheduled_start_time' => 'datetime',
'scheduled_end_time' => 'datetime',
'actual_start_time' => 'datetime',
'actual_end_time' => 'datetime',
'organizer_notified_at' => 'datetime',
'log_reminder_sent_at' => 'datetime',
'is_internal' => 'boolean',
'duration' => 'integer',
'average_score' => 'decimal:2',
'is_private' => 'boolean',
'is_processed' => 'boolean',
'is_instant_invite' => 'boolean',
'value' => 'decimal:2',
'recording_preference' => 'boolean',
'recording_reason_code' => 'integer',
'has_recording_prompt' => 'boolean',
'on_air' => 'integer',
];
}
protected static function boot()
{
parent::boot();
static::updated(static function (Activity $activity) {
// If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week
if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||
($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {
if ($activity->isDirty('status')) {
event(new StatusUpdated($activity));
}
if ($activity->isDirty('stage_id')) {
event(new StageUpdated($activity));
}
if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {
event(new ProspectUpdated($activity));
}
if ($activity->isDirty('opportunity_id')) {
event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));
}
if ($activity->isDirty('title')) {
event(new TitleUpdated($activity));
}
}
if ($activity->isDirty('playbook_category_id')) {
event(new ActivityTypeUpdated($activity));
}
});
static::deleted(static function (Activity $activity) {
// Hard delete associated playlistActivities
$activity->playlistActivities()->delete();
});
}
public function getOrganizerAttribute(): ?Participant
{
$participant = $this->participants()->where('user_id', $this->user_id)->first();
if (! $participant instanceof Participant && $participant !== null) {
throw new RuntimeException(sprintf('$participant must be an instance of "%s" or null', Participant::class));
}
return $participant;
}
public function getFormattedValueAttribute()
{
$currencyCode = 'USD';
if ($this->opportunity) {
$currencyCode = $this->opportunity->getCurrencyCode();
}
$formatter = new CurrencyFormatter();
$formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
return $formatter->format($this->value, $currencyCode);
}
public function getProspectNameAttribute(): ?string
{
$prospectName = null;
if ($this->lead_id) {
$prospectName = $this->lead->name;
} elseif ($this->contact_id) {
$prospectName = $this->contact->name;
} elseif ($this->account_id) {
$prospectName = $this->account->name;
}
return $prospectName;
}
public function getProspectName(): ?string
{
/** @var string|null */
return $this->getAttribute('prospect_name');
}
/**
* Get activity title depending on prospect or title
*/
public function getActivityTitleAttribute(): ?string
{
$activityTitle = null;
if ($this->prospect && $this->prospect->getName()) {
if ($this->account_id) {
$activityTitle = $this->account->name;
} elseif ($this->lead_id) {
$activityTitle = $this->lead->company;
} elseif ($this->contact_id) {
$activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;
}
} elseif ($this->title) {
$activityTitle = $this->title;
}
return $activityTitle;
}
public function wasRecentlyCreated(): bool
{
return $this->wasRecentlyCreated;
}
public function getProspectTypeAttribute()
{
$prospectType = null;
if ($this->lead_id) {
$prospectType = 'Lead';
} elseif ($this->contact_id) {
$prospectType = 'Contact';
} elseif ($this->account_id) {
$prospectType = 'Account';
}
return $prospectType;
}
/**
* Return the best match for prospect. Results are in the following order of priority:
* 1. Lead
* 2. Contact
* 3. Account
* 4. NULL
*/
public function getProspectAttribute(): ?ProspectInterface
{
if ($this->hasLead()) {
return $this->getLead();
}
if ($this->hasContact()) {
return $this->getContact();
}
if ($this->hasAccount()) {
return $this->getAccount();
}
return null;
}
public function getTitleAttribute($value): ?string
{
return \getActivityTitleAttribute(
$this->user->name,
$this->getType(),
$value,
$this->prospect->name ?? null,
$this->from->national_phone_number ?? null
);
}
public function getTitle(): ?string
{
return $this->getAttribute('title');
}
public function getSummary(): ?string
{
return $this->getAttribute('summary');
}
public function isInternal(): bool
{
return $this->getAttribute('is_internal');
}
public function getIsPrivate(): bool
{
return $this->getAttribute('is_private');
}
public function getDescription(): ?string
{
return $this->getAttribute('description');
}
public function hasTitle(): bool
{
return $this->getOriginal('title') !== null;
}
public function getPlayCountAttribute()
{
return $this->getPlaysCountAttribute();
}
public function getPlaysCountAttribute()
{
if (! isset($this->attributes['plays_count'])) {
$this->loadCount('plays');
}
return $this->attributes['plays_count'];
}
public function getCommentCountAttribute()
{
return $this->getCommentsCountAttribute();
}
public function getCommentsCountAttribute()
{
if (! isset($this->attributes['comments_count'])) {
$this->loadCount('comments');
}
return $this->attributes['comments_count'];
}
public function getVisibleCommentsCountAttribute()
{
if (! isset($this->attributes['visible_comments_count'])) {
$activityCommentsService = app(ActivityCommentService::class);
$user = Auth::user() instanceof User ? Auth::user() : null;
$this->attributes['visible_comments_count'] = $activityCommentsService
->getVisibleCommentsCount($this, $user);
}
return $this->attributes['visible_comments_count'];
}
public function getShareCountAttribute()
{
return $this->getSharesCountAttribute();
}
public function getSharesCountAttribute()
{
if (! isset($this->attributes['shares_count'])) {
$this->loadCount('shares');
}
return $this->attributes['shares_count'];
}
/**
* Get the count of favorites playlists this activity appears in
*/
public function getFavoriteCountAttribute(): int
{
return $this->getFavoritesCountAttribute();
}
public function getFavoritesCountAttribute()
{
if (! isset($this->attributes['favorites_count'])) {
$this->loadCount('favorites');
}
return $this->attributes['favorites_count'];
}
public function getActiveParticipantsCountAttribute()
{
if (! isset($this->attributes['active_participants_count'])) {
$this->loadCount('activeParticipants');
}
return $this->attributes['active_participants_count'];
}
public function getTracksWithTelephonyCountAttribute()
{
if (! isset($this->attributes['tracks_with_telephony_count'])) {
$this->loadCount('tracksWithTelephony');
}
return $this->attributes['tracks_with_telephony_count'];
}
/**
* @TEMP
* $this->loadCount('tracksWithTelephony') throws null pointer exception
*/
public function countTracksWithTelephony(): int
{
return $this->tracks()->whereNotNull('telephony_provider_id')->count();
}
public function getDuration(): float
{
return $this->getAttribute('duration');
}
public function getDurationForHumansAttribute()
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);
}
public function getDurationForHumansShortAttribute(): string
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);
}
public function has...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45483
|
1628
|
17
|
2026-05-14T14:39:32.973215+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769572973_m2.jpg...
|
PhpStorm
|
faVsco.js – IntegrationApp/Service.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp;
use Carbon\Carbon;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Services\Crm\ClientInterface;
use Jiminny\Contracts\Services\Crm\FetchRelatedActivityInterface;
use Jiminny\Contracts\Services\Crm\ImportsBusinessProcessesInterface;
use Jiminny\Contracts\Services\Crm\LayoutManagementInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityLookupInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\RemoteNoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\SendSummaryToCrmInterface;
use Jiminny\Contracts\Services\Crm\SettingsInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmMetadataInterface;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\SocialAccountNotFoundException;
use Jiminny\Jobs\Crm\NoteObject;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contracts\ActivityContract;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Jiminny\Models\User;
use Jiminny\Services\Crm\BaseService;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationAppProviders;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationConfigFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\FieldMapperInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\LeadFieldMapper;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\GenerateProviderUrlInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\IntegrationAppCrmGeneratorFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\UrlGeneratorInterface;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmFieldsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SystemStateTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\LayoutTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\MatchProspectsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\NotSupportedTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmEntitiesTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmMetadataTrait;
use Psr\Log\LoggerInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\OpportunityFieldMapper;
use Jiminny\Repositories\Crm\ProfileRepository;
use Jiminny\Repositories\Crm\OpportunityRepository;
use Jiminny\Models\Crm\Profile;
use Jiminny\Services\Crm\CrmObjects\CrmObjectsRepository;
class Service extends BaseService implements
IntegrationAppInterface,
SyncCrmEntitiesInterface,
SyncCrmMetadataInterface,
ImportsBusinessProcessesInterface,
RemoteEntityManipulationInterface,
LayoutManagementInterface,
SettingsInterface,
MatchCrmEntitiesInterface,
RemoteEntityLookupInterface,
RemoteNoteEntityManipulationInterface,
SendSummaryToCrmInterface,
UrlGeneratorInterface,
FetchRelatedActivityInterface
{
use SyncCrmMetadataTrait;
use SyncCrmEntitiesTrait;
use SystemStateTrait;
use LayoutTrait;
use NotSupportedTrait;
use MatchProspectsTrait;
use SyncCrmFieldsTrait;
public const string CALL_TYPE_MISSED = 'Missed';
public const string CALL_TYPE_INBOUND = 'Inbound';
public const string CALL_TYPE_OUTBOUND = 'Outbound';
public const string RELATIONSHIP_OPPORTUNITY = 'Deals';
public const string RELATIONSHIP_LEAD = 'Leads';
public const string RELATIONSHIP_ACCOUNT = 'Accounts';
/**
* @var ClientInterface&DataClient
*/
protected $client;
protected ?User $invokedUser = null;
protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;
public function __construct(
DataClient $client,
LoggerInterface $logger,
) {
parent::__construct();
$this->client = $client;
$this->logger = $logger;
}
public function getDisplayName(): string
{
return Providers::getProviderDisplayName(
Providers::getCrmIntegrationSlug($this->config)
);
}
/**
* @throws \Exception
*/
public function setUser(User $user): void
{
$this->configureSentryScope($user);
$this->invokedUser = $user;
$this->team = $user->getTeam();
$teamOwner = $this->team->getOwner();
$this->setConfiguration($user->getTeam()->getCrmConfiguration());
$this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));
$this->setCrmUrlGenerator($this->config);
$this->client->setTeam($this->team);
$socialAccount = $teamOwner?->getSocialAccount('integration-app');
if ($socialAccount === null) {
$this->logger->info('[integration-app] Social account not found', [
'teamId' => $this->team->getId(),
'teamOwnerId' => $teamOwner?->getId(),
'userId' => $user->getId(),
]);
throw new SocialAccountNotFoundException('Social account not found!');
}
$this->client->setSocialAccount($socialAccount);
// The CRM Service is properly bootstrapped, and supports remote operations
$this->connect();
}
public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string
{
return $fieldValue;
}
public function find(string $name, array $scopes): array
{
/** @var LocalSearch $localSearch */
$localSearch = app(LocalSearch::class);
$localSearch->setConfiguration($this->config);
$localSearch->setCountryCode($this->invokedUser->getCountryCode());
return $localSearch->search($name);
// if (! empty($localMatch)) {
// return $localMatch;
// }
//
// /** @var RemoteSearch $remoteSearch */
// $remoteSearch = app(RemoteSearch::class);
// $remoteSearch->setClient($this->client);
// $remoteSearch->setConfiguration($this->config);
//
// return $remoteSearch->search($name);
}
public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array
{
$data = [];
$ownerData = [];
$account = $this->getAccount($crmAccountId, $crmContactId);
if ($account === null) {
return [];
}
$ownerId = $this->getOwnerId($userId);
try {
$opportunityRepository = app(OpportunityRepository::class);
$opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(
$this->config,
$account->getId()
);
foreach ($opportunities as $opportunity) {
/** @var Opportunity $opportunity */
$record = $this->buildOpportunityData($opportunity);
if ($ownerId && $opportunity->getOwnerId() === $ownerId) {
$ownerData[] = $record;
}
$data[] = $record;
}
if (! empty($ownerData)) {
return $ownerData;
}
return $data;
} catch (\Exception $e) {
$this->logger->info('[integration-app] Failed to fetch opportunities', [
'contact' => $crmContactId,
'account' => $crmAccountId,
'owner' => $ownerId,
'error' => $e->getMessage(),
]);
return $data;
}
}
private function getOwnerId(?int $userId = null): ?string
{
if (! $userId) {
return null;
}
$profileRepository = app(ProfileRepository::class);
$profile = $profileRepository->findProfileByUserId($this->config, $userId);
return $profile instanceof Profile ? $profile->getCrmProviderId() : null;
}
private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account
{
$crmRepository = app(CrmObjectsRepository::class);
if ($crmAccountId === null) {
$contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);
return $contact->getAccount();
}
return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);
}
private function buildOpportunityData(Opportunity $opportunity): array
{
$record = [
'crmId' => $opportunity->getCrmProviderId(),
'name' => $opportunity->getName(),
'won' => $opportunity->isWon(),
'closed' => $opportunity->isClosed(),
];
if (! empty($opportunity->getFormattedValueAttribute())) {
$record['value'] = $opportunity->getFormattedValueAttribute();
}
if (! empty($opportunity->getStage())) {
$record['stage'] = [
'id' => $opportunity->getStage()->getUuid(),
'name' => $opportunity->getStage()->getName(),
];
}
return $record;
}
public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void
{
$data = [
'data' => $this->normalizeData($objectType, $data),
];
$this->client->updateRecordById($objectType, $objectId, $data);
}
private function normalizeData(string $objectType, array $data): array
{
$fieldMapper = $this->getFieldMapper($objectType);
if (! $fieldMapper instanceof FieldMapperInterface) {
return $data;
}
return $fieldMapper->mapToCrmFields($data);
}
private function getFieldMapper(string $objectType): ?FieldMapperInterface
{
if ($objectType === self::OBJECT_OPPORTUNITY) {
return app(OpportunityFieldMapper::class);
}
if ($objectType === self::OBJECT_LEAD) {
return app(LeadFieldMapper::class);
}
return null;
}
public function getRecord(string $objectType, string $objectId, array $fields = []): array
{
return $this->client->getRecordById($objectType, $objectId);
}
public function getConfiguration(): Configuration
{
return $this->config;
}
public function setConfiguration(Configuration $config): void
{
$this->clearExternalMapCache();
$this->config = $config;
}
private function setEditionConfiguration(string $provider): void
{
$this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);
}
public function setCrmUrlGenerator(Configuration $config): void
{
$this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);
}
public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface
{
if ($this->crmUrlGenerator === null) {
$this->setCrmUrlGenerator($this->config);
}
return $this->crmUrlGenerator;
}
public function subscribeEntityEvents(bool $enableTrigger = true): void
{
$eventStates = $this->client->updateEntityEventsState($enableTrigger);
$this->logger->info('[integration-app] Change team entity events subscription', [
'teamId' => $this->team->getId(),
'teamName' => $this->team->getName(),
'states' => $eventStates,
'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',
]);
}
#[\Override] public function supportsNotes(): bool
{
return $this->editionConfig->supportsNotes();
}
#[\Override] public function saveNote(
string $title,
string $body,
string $objectId,
?NoteObject $noteObject = null,
): ?string {
if ($noteObject === null) {
return null;
}
$notePayload = [
'title' => $title,
'content' => $body,
'objectId' => $objectId,
'objectType' => $noteObject->value,
];
$result = $this->client->createNote($notePayload);
// debug saving note response
$this->logger->info('[integration-app] createNote response', [
'objectId' => $objectId,
'objectType' => $noteObject->value,
'result' => $result,
'hasId' => isset($result['id']),
]);
return $result['id'] ?? null;
}
/**
* @throws CrmException
*/
#[\Override] public function saveActivity(Activity $activity): Activity
{
$this->logger->info('[integration-app] saveActivity', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
]);
if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {
$crmActivity = $this->saveMeeting($activity);
} elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {
$crmActivity = $this->saveCall($activity);
} else {
throw new CrmException('Unsupported activity type');
}
$crmActivityId = $crmActivity['id'] ?? null;
if ($crmActivityId !== null) {
$activity->crm_provider_id = $crmActivityId;
$activity->save();
$this->logger->info('[integration-app] Activity successfully logged to CRM', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
'crmId' => $crmActivityId,
]);
}
return $activity;
}
public function saveMeeting(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$meetingPayload = [
'Event_Title' => $decorateActivity->generateTitle($activity),
'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),
'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($meetingPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$meeting = $this->client->getMeeting($crmId);
$oldDescription = $meeting['fields']['Description'] ?? null;
$payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update meeting', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateMeeting($crmId, $payload);
}
$payload['Description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log meeting', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createMeeting($payload);
}
public function saveCall(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$callPayload = [
'Call_Type' => $this->getCallType($activity),
'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),
'Call_Duration' => $activity->getDuration(),
'name' => $decorateActivity->generateTitle($activity),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($callPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$call = $this->client->getCall($crmId);
$oldDescription = $call['fields']['Description'] ?? null;
$payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update call', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateCall($crmId, $payload);
}
$payload['description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log call', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createCall($payload);
}
private function getCallType(Activity $activity): string
{
if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {
return self::CALL_TYPE_MISSED;
}
return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;
}
private function attachToProspect(Activity $activity): array
{
$payload = [];
if ($activity->hasContact()) {
$payload['contactId'] = $activity->getContact()->getCrmProviderId();
}
if ($activity->hasOpportunity()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_OPPORTUNITY,
$activity->getOpportunity()->getCrmProviderId()
)
);
}
if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_ACCOUNT,
$activity->getAccount()->getCrmProviderId()
)
);
}
if ($activity->hasLead()) {
$payload = $this->handleLeadPayload($activity);
}
return $payload;
}
private function handleLeadPayload(Activity $activity): array
{
$freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());
$lead = $freshLead ?? $activity->getLead();
if ($lead->getConvertedAt() === null) {
return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());
}
$activity->lead_id = null;
if ($lead->hasAccount()) {
$account = $lead->getAccount();
$activity->account_id = $account->getId();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());
} else {
$payload = [];
}
if ($lead->hasOpportunity()) {
$opportunity = $lead->getOpportunity();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());
$activity->opportunity_id = $opportunity->getId();
$activity->value = $opportunity->value;
$activity->stage_id = $opportunity->stage_id;
} else {
$activity->stage_id = null;
}
if ($lead->hasContact()) {
$contact = $lead->getContact();
$payload['contactId'] = $contact->getCrmProviderId();
$activity->contact_id = $contact->getId();
}
$activity->save();
event(new ActivityLeadConverted($activity, $lead));
$this->logger->info('[integration-app] Lead converted', [
'activityUuid' => $activity->getUuid(),
'leadUuid' => $lead->getUuid(),
]);
return $payload;
}
private function buildBasicPayload(string $type, string $id): array
{
return [
'type' => $type,
'id' => $id,
];
}
private function getActivityOwnerId(Activity $activity): ?string
{
$ownerId = null;
if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {
$ownerId = $activity->getUser()->getProfile()->getCrmProviderId();
}
return $ownerId;
}
#[\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
$taskPayload = [
'subject' => $fields['subject'],
'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,
'ownerId' => $this->getActivityOwnerId($activity),
];
if (isset($fields['status'])) {
$taskPayload['status'] = $fields['status'];
}
if (isset($fields['priority'])) {
$taskPayload['priority'] = $fields['priority'];
}
if (isset($fields['content'])) {
$taskPayload['content'] = $fields['content'];
}
$payload = array_merge($taskPayload, $this->attachToProspect($activity));
$this->logger->info('[integration-app] CRM log follow up task', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
$task = $this->client->createTask($payload);
return $task['id'] ?? null;
}
#[\Override] public function saveTranscriptionSummaryAsNote(
ActivityContract $activity,
string $title,
string $body,
?string $objectId,
?NoteObject $noteObject = null,
): ?string {
// We have to find a way to store the transcription summary
// This might be possible either by Tasks, Events, Engagements & Notes
// Find what the CRM supports and save the note with the appropriate object(eg Notes)
// For now use only Notes as both ZOHO & Salesforce support them.
if ($this->supportsNotes() && $objectId !== null) {
$this->logger->info('[integration-app] saving note', [
'activityId' => $activity->getUuid(),
'objectId' => $objectId,
]);
return $this->saveNote($title, $body, $objectId, $noteObject);
}
$this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [
'activityId' => $activity->getUuid(),
'supportsNotes' => $this->supportsNotes(),
'objectId' => $objectId,
]);
return null;
}
public function generateProviderUrl(string $providerId, string $objectType): ?string
{
return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);
}
public function updateStage($crmObject, Stage $stage): void
{
$objectType = $stage->getType();
$objectId = $crmObject->getCrmProviderId();
$params = ['stageName' => $stage->getCrmProviderId()];
$this->logger->info('[integration-app] updateStage', [
'objectType' => $objectType,
'objectId' => $objectId,
'params' => $params,
]);
$data = [
'data' => $this->normalizeData($objectType, $params),
];
if ($objectType === Stage::TYPE_LEAD) {
$this->client->updateLead($objectId, $data);
} else {
$this->client->updateDeal($objectId, $data);
}
}
/**
* @throws \Exception
*/
public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity
{
if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {
return null;
}
if (! $activity->isTypeConference()) {
return null;
}
// The related activity is already linked.
if ($activity->hasCrmProviderId()) {
return $activity;
}
if ($activity->hasActualStartTime() === false) {
return null;
}
return $this->fetchAndAssociateZohoRelatedActivity($activity);
}
public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity
{
try {
$meeting = $this->fetchRelatedZohoActivity($activity);
if (empty($meeting)) {
$this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [
'activity' => $activity->getUuid(),
]);
return null;
}
$decorateActivity = app(DecorateActivity::class);
$oldDescription = $meeting['Description'] ?? '';
$updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [
'activity' => $activity->getUuid(),
'description' => $updatedDescription,
]);
$this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);
// Update our activity to reflect the remote data.
$activity->update([
'crm_provider_id' => $meeting['id'],
'summary' => $meeting['Description'],
]);
return $activity;
} catch (\Exception $exception) {
\Sentry::captureException($exception);
throw $exception;
}
}
public function fetchRelatedZohoActivity(Activity $activity): array
{
[$from, $to] = $this->getFromToDates($activity);
$start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00
$end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00
if ($start === null || $end === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity missing start or end date',
[
'activity' => $activity->getUuid(),
'start' => $start,
'end' => $end,
'from' => $from,
'to' => $to,
]
);
return [];
}
$whoId = null;
$whatId = null;
$criteriaParts = [];
if ($activity->getContact()) {
$whoId = $activity->getContact()->getCrmProviderId();
$criteriaParts[] = "(Who_Id:equals:$whoId)";
}
if ($activity->getOpportunity()) {
$whatId = $activity->getOpportunity()->getCrmProviderId();
} elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {
$whatId = $activity->getAccount()->getCrmProviderId();
} elseif ($activity->getLead()) {
$whatId = $activity->getLead()->getCrmProviderId();
}
if ($whatId !== null) {
$criteriaParts[] = "(What_Id:equals:$whatId)";
}
if ($whoId === null && $whatId === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity cannot find prospect',
[
'activity' => $activity->getUuid(),
]
);
return [];
}
$criteriaParts[] = "(Start_DateTime:greater_equal:$start)";
$criteriaParts[] = "(End_DateTime:less_equal:$end)";
$criteria = implode(' AND ', $criteriaParts);
$params = [
'criteria' => $criteria,
'sort_by' => 'Modified_Time',
'sort_order' => 'desc',
];
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity searching for related activity',
[
'activity' => $activity->getUuid(),
'params' => $params,
]
);
$meetings = $this->client->searchMeetings($params);
if (! empty($meetings)) {
return $meetings[0];
}
return [];
}
private function getFromToDates(Activity $activity): array
{
$calendarEvent = $activity->calendarEvent()->first();
$from = $calendarEvent?->getStartTime();
$to = $calendarEvent?->getEndTime();
if (! $from || ! $to) {
$from = $activity->hasScheduledStartTime()
? $activity->getScheduledStartTime()
: $activity->getActualStartTime();
$to = $activity->hasScheduledEndTime()
? $activity->getScheduledEndTime()->addMinutes(15)
: $activity->getActualEndTime();
}
return [$from, $to];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"16","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Services\\Crm\\ClientInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\FetchRelatedActivityInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\ImportsBusinessProcessesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\LayoutManagementInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\MatchCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityLookupInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteNoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SendSummaryToCrmInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SettingsInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmMetadataInterface;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\SocialAccountNotFoundException;\nuse Jiminny\\Jobs\\Crm\\NoteObject;\nuse Jiminny\\Models\\Account;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Contracts\\ActivityContract;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Opportunity;\nuse Jiminny\\Models\\Stage;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Crm\\BaseService;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationAppProviders;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationConfigFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\FieldMapperInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\LeadFieldMapper;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\GenerateProviderUrlInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\IntegrationAppCrmGeneratorFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\UrlGeneratorInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmFieldsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SystemStateTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\LayoutTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\MatchProspectsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\NotSupportedTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmEntitiesTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmMetadataTrait;\nuse Psr\\Log\\LoggerInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\OpportunityFieldMapper;\nuse Jiminny\\Repositories\\Crm\\ProfileRepository;\nuse Jiminny\\Repositories\\Crm\\OpportunityRepository;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Services\\Crm\\CrmObjects\\CrmObjectsRepository;\n\nclass Service extends BaseService implements\n IntegrationAppInterface,\n SyncCrmEntitiesInterface,\n SyncCrmMetadataInterface,\n ImportsBusinessProcessesInterface,\n RemoteEntityManipulationInterface,\n LayoutManagementInterface,\n SettingsInterface,\n MatchCrmEntitiesInterface,\n RemoteEntityLookupInterface,\n RemoteNoteEntityManipulationInterface,\n SendSummaryToCrmInterface,\n UrlGeneratorInterface,\n FetchRelatedActivityInterface\n{\n use SyncCrmMetadataTrait;\n use SyncCrmEntitiesTrait;\n use SystemStateTrait;\n use LayoutTrait;\n use NotSupportedTrait;\n use MatchProspectsTrait;\n use SyncCrmFieldsTrait;\n\n public const string CALL_TYPE_MISSED = 'Missed';\n public const string CALL_TYPE_INBOUND = 'Inbound';\n public const string CALL_TYPE_OUTBOUND = 'Outbound';\n public const string RELATIONSHIP_OPPORTUNITY = 'Deals';\n public const string RELATIONSHIP_LEAD = 'Leads';\n public const string RELATIONSHIP_ACCOUNT = 'Accounts';\n\n /**\n * @var ClientInterface&DataClient\n */\n protected $client;\n\n protected ?User $invokedUser = null;\n\n protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;\n\n public function __construct(\n DataClient $client,\n LoggerInterface $logger,\n ) {\n parent::__construct();\n $this->client = $client;\n $this->logger = $logger;\n }\n\n public function getDisplayName(): string\n {\n return Providers::getProviderDisplayName(\n Providers::getCrmIntegrationSlug($this->config)\n );\n }\n\n /**\n * @throws \\Exception\n */\n public function setUser(User $user): void\n {\n $this->configureSentryScope($user);\n $this->invokedUser = $user;\n\n $this->team = $user->getTeam();\n $teamOwner = $this->team->getOwner();\n\n $this->setConfiguration($user->getTeam()->getCrmConfiguration());\n $this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));\n $this->setCrmUrlGenerator($this->config);\n\n $this->client->setTeam($this->team);\n $socialAccount = $teamOwner?->getSocialAccount('integration-app');\n if ($socialAccount === null) {\n $this->logger->info('[integration-app] Social account not found', [\n 'teamId' => $this->team->getId(),\n 'teamOwnerId' => $teamOwner?->getId(),\n 'userId' => $user->getId(),\n ]);\n\n throw new SocialAccountNotFoundException('Social account not found!');\n }\n $this->client->setSocialAccount($socialAccount);\n\n // The CRM Service is properly bootstrapped, and supports remote operations\n $this->connect();\n }\n\n public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string\n {\n return $fieldValue;\n }\n\n public function find(string $name, array $scopes): array\n {\n /** @var LocalSearch $localSearch */\n $localSearch = app(LocalSearch::class);\n $localSearch->setConfiguration($this->config);\n $localSearch->setCountryCode($this->invokedUser->getCountryCode());\n\n return $localSearch->search($name);\n\n // if (! empty($localMatch)) {\n // return $localMatch;\n // }\n //\n // /** @var RemoteSearch $remoteSearch */\n // $remoteSearch = app(RemoteSearch::class);\n // $remoteSearch->setClient($this->client);\n // $remoteSearch->setConfiguration($this->config);\n //\n // return $remoteSearch->search($name);\n }\n\n public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array\n {\n $data = [];\n $ownerData = [];\n\n $account = $this->getAccount($crmAccountId, $crmContactId);\n if ($account === null) {\n return [];\n }\n\n $ownerId = $this->getOwnerId($userId);\n\n try {\n $opportunityRepository = app(OpportunityRepository::class);\n $opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(\n $this->config,\n $account->getId()\n );\n\n foreach ($opportunities as $opportunity) {\n /** @var Opportunity $opportunity */\n $record = $this->buildOpportunityData($opportunity);\n\n if ($ownerId && $opportunity->getOwnerId() === $ownerId) {\n $ownerData[] = $record;\n }\n\n $data[] = $record;\n }\n\n if (! empty($ownerData)) {\n return $ownerData;\n }\n\n return $data;\n } catch (\\Exception $e) {\n $this->logger->info('[integration-app] Failed to fetch opportunities', [\n 'contact' => $crmContactId,\n 'account' => $crmAccountId,\n 'owner' => $ownerId,\n 'error' => $e->getMessage(),\n ]);\n\n return $data;\n }\n }\n\n private function getOwnerId(?int $userId = null): ?string\n {\n if (! $userId) {\n return null;\n }\n\n $profileRepository = app(ProfileRepository::class);\n $profile = $profileRepository->findProfileByUserId($this->config, $userId);\n\n return $profile instanceof Profile ? $profile->getCrmProviderId() : null;\n }\n\n private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account\n {\n $crmRepository = app(CrmObjectsRepository::class);\n\n if ($crmAccountId === null) {\n $contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);\n\n return $contact->getAccount();\n }\n\n return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);\n }\n\n private function buildOpportunityData(Opportunity $opportunity): array\n {\n $record = [\n 'crmId' => $opportunity->getCrmProviderId(),\n 'name' => $opportunity->getName(),\n 'won' => $opportunity->isWon(),\n 'closed' => $opportunity->isClosed(),\n ];\n\n if (! empty($opportunity->getFormattedValueAttribute())) {\n $record['value'] = $opportunity->getFormattedValueAttribute();\n }\n\n if (! empty($opportunity->getStage())) {\n $record['stage'] = [\n 'id' => $opportunity->getStage()->getUuid(),\n 'name' => $opportunity->getStage()->getName(),\n ];\n }\n\n return $record;\n }\n\n public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void\n {\n $data = [\n 'data' => $this->normalizeData($objectType, $data),\n ];\n\n $this->client->updateRecordById($objectType, $objectId, $data);\n }\n\n private function normalizeData(string $objectType, array $data): array\n {\n $fieldMapper = $this->getFieldMapper($objectType);\n\n if (! $fieldMapper instanceof FieldMapperInterface) {\n return $data;\n }\n\n return $fieldMapper->mapToCrmFields($data);\n }\n\n private function getFieldMapper(string $objectType): ?FieldMapperInterface\n {\n if ($objectType === self::OBJECT_OPPORTUNITY) {\n return app(OpportunityFieldMapper::class);\n }\n\n if ($objectType === self::OBJECT_LEAD) {\n return app(LeadFieldMapper::class);\n }\n\n return null;\n }\n\n public function getRecord(string $objectType, string $objectId, array $fields = []): array\n {\n return $this->client->getRecordById($objectType, $objectId);\n }\n\n public function getConfiguration(): Configuration\n {\n return $this->config;\n }\n\n public function setConfiguration(Configuration $config): void\n {\n $this->clearExternalMapCache();\n\n $this->config = $config;\n }\n\n private function setEditionConfiguration(string $provider): void\n {\n $this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);\n }\n\n public function setCrmUrlGenerator(Configuration $config): void\n {\n $this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);\n }\n\n public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface\n {\n if ($this->crmUrlGenerator === null) {\n $this->setCrmUrlGenerator($this->config);\n }\n\n return $this->crmUrlGenerator;\n }\n\n public function subscribeEntityEvents(bool $enableTrigger = true): void\n {\n $eventStates = $this->client->updateEntityEventsState($enableTrigger);\n\n $this->logger->info('[integration-app] Change team entity events subscription', [\n 'teamId' => $this->team->getId(),\n 'teamName' => $this->team->getName(),\n 'states' => $eventStates,\n 'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',\n ]);\n }\n\n #[\\Override] public function supportsNotes(): bool\n {\n return $this->editionConfig->supportsNotes();\n }\n\n #[\\Override] public function saveNote(\n string $title,\n string $body,\n string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n if ($noteObject === null) {\n return null;\n }\n\n $notePayload = [\n 'title' => $title,\n 'content' => $body,\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n ];\n\n $result = $this->client->createNote($notePayload);\n\n // debug saving note response\n $this->logger->info('[integration-app] createNote response', [\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n 'result' => $result,\n 'hasId' => isset($result['id']),\n ]);\n\n return $result['id'] ?? null;\n }\n\n /**\n * @throws CrmException\n */\n #[\\Override] public function saveActivity(Activity $activity): Activity\n {\n $this->logger->info('[integration-app] saveActivity', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n ]);\n\n if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {\n $crmActivity = $this->saveMeeting($activity);\n } elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {\n $crmActivity = $this->saveCall($activity);\n } else {\n throw new CrmException('Unsupported activity type');\n }\n\n $crmActivityId = $crmActivity['id'] ?? null;\n\n if ($crmActivityId !== null) {\n $activity->crm_provider_id = $crmActivityId;\n $activity->save();\n\n $this->logger->info('[integration-app] Activity successfully logged to CRM', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n 'crmId' => $crmActivityId,\n ]);\n }\n\n return $activity;\n }\n\n public function saveMeeting(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $meetingPayload = [\n 'Event_Title' => $decorateActivity->generateTitle($activity),\n 'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),\n 'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($meetingPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $meeting = $this->client->getMeeting($crmId);\n\n $oldDescription = $meeting['fields']['Description'] ?? null;\n $payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update meeting', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateMeeting($crmId, $payload);\n }\n\n $payload['Description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log meeting', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createMeeting($payload);\n }\n\n public function saveCall(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $callPayload = [\n 'Call_Type' => $this->getCallType($activity),\n 'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),\n 'Call_Duration' => $activity->getDuration(),\n 'name' => $decorateActivity->generateTitle($activity),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($callPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $call = $this->client->getCall($crmId);\n\n $oldDescription = $call['fields']['Description'] ?? null;\n $payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update call', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateCall($crmId, $payload);\n }\n\n $payload['description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log call', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createCall($payload);\n }\n\n private function getCallType(Activity $activity): string\n {\n if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {\n return self::CALL_TYPE_MISSED;\n }\n\n return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;\n }\n\n private function attachToProspect(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->hasContact()) {\n $payload['contactId'] = $activity->getContact()->getCrmProviderId();\n }\n\n if ($activity->hasOpportunity()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_OPPORTUNITY,\n $activity->getOpportunity()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_ACCOUNT,\n $activity->getAccount()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasLead()) {\n $payload = $this->handleLeadPayload($activity);\n }\n\n return $payload;\n }\n\n private function handleLeadPayload(Activity $activity): array\n {\n $freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());\n $lead = $freshLead ?? $activity->getLead();\n\n if ($lead->getConvertedAt() === null) {\n return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());\n }\n\n $activity->lead_id = null;\n\n if ($lead->hasAccount()) {\n $account = $lead->getAccount();\n $activity->account_id = $account->getId();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());\n } else {\n $payload = [];\n }\n\n if ($lead->hasOpportunity()) {\n $opportunity = $lead->getOpportunity();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());\n $activity->opportunity_id = $opportunity->getId();\n $activity->value = $opportunity->value;\n $activity->stage_id = $opportunity->stage_id;\n } else {\n $activity->stage_id = null;\n }\n\n if ($lead->hasContact()) {\n $contact = $lead->getContact();\n $payload['contactId'] = $contact->getCrmProviderId();\n $activity->contact_id = $contact->getId();\n }\n\n $activity->save();\n event(new ActivityLeadConverted($activity, $lead));\n\n $this->logger->info('[integration-app] Lead converted', [\n 'activityUuid' => $activity->getUuid(),\n 'leadUuid' => $lead->getUuid(),\n ]);\n\n return $payload;\n }\n\n private function buildBasicPayload(string $type, string $id): array\n {\n return [\n 'type' => $type,\n 'id' => $id,\n ];\n }\n private function getActivityOwnerId(Activity $activity): ?string\n {\n $ownerId = null;\n if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {\n $ownerId = $activity->getUser()->getProfile()->getCrmProviderId();\n }\n\n return $ownerId;\n }\n\n #[\\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n $taskPayload = [\n 'subject' => $fields['subject'],\n 'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n if (isset($fields['status'])) {\n $taskPayload['status'] = $fields['status'];\n }\n\n if (isset($fields['priority'])) {\n $taskPayload['priority'] = $fields['priority'];\n }\n\n if (isset($fields['content'])) {\n $taskPayload['content'] = $fields['content'];\n }\n\n $payload = array_merge($taskPayload, $this->attachToProspect($activity));\n\n $this->logger->info('[integration-app] CRM log follow up task', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n $task = $this->client->createTask($payload);\n\n return $task['id'] ?? null;\n }\n\n #[\\Override] public function saveTranscriptionSummaryAsNote(\n ActivityContract $activity,\n string $title,\n string $body,\n ?string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n // We have to find a way to store the transcription summary\n // This might be possible either by Tasks, Events, Engagements & Notes\n // Find what the CRM supports and save the note with the appropriate object(eg Notes)\n\n // For now use only Notes as both ZOHO & Salesforce support them.\n if ($this->supportsNotes() && $objectId !== null) {\n $this->logger->info('[integration-app] saving note', [\n 'activityId' => $activity->getUuid(),\n 'objectId' => $objectId,\n ]);\n\n return $this->saveNote($title, $body, $objectId, $noteObject);\n }\n\n $this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [\n 'activityId' => $activity->getUuid(),\n 'supportsNotes' => $this->supportsNotes(),\n 'objectId' => $objectId,\n ]);\n\n return null;\n }\n\n public function generateProviderUrl(string $providerId, string $objectType): ?string\n {\n return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);\n }\n\n public function updateStage($crmObject, Stage $stage): void\n {\n $objectType = $stage->getType();\n $objectId = $crmObject->getCrmProviderId();\n $params = ['stageName' => $stage->getCrmProviderId()];\n\n $this->logger->info('[integration-app] updateStage', [\n 'objectType' => $objectType,\n 'objectId' => $objectId,\n 'params' => $params,\n ]);\n\n $data = [\n 'data' => $this->normalizeData($objectType, $params),\n ];\n\n\n if ($objectType === Stage::TYPE_LEAD) {\n $this->client->updateLead($objectId, $data);\n } else {\n $this->client->updateDeal($objectId, $data);\n }\n }\n\n /**\n * @throws \\Exception\n */\n public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity\n {\n if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {\n return null;\n }\n\n if (! $activity->isTypeConference()) {\n return null;\n }\n\n // The related activity is already linked.\n if ($activity->hasCrmProviderId()) {\n return $activity;\n }\n\n if ($activity->hasActualStartTime() === false) {\n return null;\n }\n\n return $this->fetchAndAssociateZohoRelatedActivity($activity);\n }\n\n public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity\n {\n try {\n $meeting = $this->fetchRelatedZohoActivity($activity);\n if (empty($meeting)) {\n $this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [\n 'activity' => $activity->getUuid(),\n ]);\n\n return null;\n }\n\n $decorateActivity = app(DecorateActivity::class);\n $oldDescription = $meeting['Description'] ?? '';\n $updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [\n 'activity' => $activity->getUuid(),\n 'description' => $updatedDescription,\n ]);\n\n $this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);\n\n // Update our activity to reflect the remote data.\n $activity->update([\n 'crm_provider_id' => $meeting['id'],\n 'summary' => $meeting['Description'],\n ]);\n\n return $activity;\n } catch (\\Exception $exception) {\n \\Sentry::captureException($exception);\n\n throw $exception;\n }\n }\n\n public function fetchRelatedZohoActivity(Activity $activity): array\n {\n [$from, $to] = $this->getFromToDates($activity);\n\n $start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00\n $end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00\n if ($start === null || $end === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity missing start or end date',\n [\n 'activity' => $activity->getUuid(),\n 'start' => $start,\n 'end' => $end,\n 'from' => $from,\n 'to' => $to,\n ]\n );\n\n return [];\n }\n\n $whoId = null;\n $whatId = null;\n $criteriaParts = [];\n\n if ($activity->getContact()) {\n $whoId = $activity->getContact()->getCrmProviderId();\n $criteriaParts[] = \"(Who_Id:equals:$whoId)\";\n }\n\n if ($activity->getOpportunity()) {\n $whatId = $activity->getOpportunity()->getCrmProviderId();\n } elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {\n $whatId = $activity->getAccount()->getCrmProviderId();\n } elseif ($activity->getLead()) {\n $whatId = $activity->getLead()->getCrmProviderId();\n }\n\n if ($whatId !== null) {\n $criteriaParts[] = \"(What_Id:equals:$whatId)\";\n }\n\n if ($whoId === null && $whatId === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity cannot find prospect',\n [\n 'activity' => $activity->getUuid(),\n ]\n );\n\n return [];\n }\n\n $criteriaParts[] = \"(Start_DateTime:greater_equal:$start)\";\n $criteriaParts[] = \"(End_DateTime:less_equal:$end)\";\n\n $criteria = implode(' AND ', $criteriaParts);\n\n $params = [\n 'criteria' => $criteria,\n 'sort_by' => 'Modified_Time',\n 'sort_order' => 'desc',\n ];\n\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity searching for related activity',\n [\n 'activity' => $activity->getUuid(),\n 'params' => $params,\n ]\n );\n\n $meetings = $this->client->searchMeetings($params);\n if (! empty($meetings)) {\n return $meetings[0];\n }\n\n return [];\n }\n\n private function getFromToDates(Activity $activity): array\n {\n $calendarEvent = $activity->calendarEvent()->first();\n\n $from = $calendarEvent?->getStartTime();\n $to = $calendarEvent?->getEndTime();\n\n if (! $from || ! $to) {\n $from = $activity->hasScheduledStartTime()\n ? $activity->getScheduledStartTime()\n : $activity->getActualStartTime();\n\n $to = $activity->hasScheduledEndTime()\n ? $activity->getScheduledEndTime()->addMinutes(15)\n : $activity->getActualEndTime();\n }\n\n return [$from, $to];\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Services\\Crm\\ClientInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\FetchRelatedActivityInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\ImportsBusinessProcessesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\LayoutManagementInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\MatchCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityLookupInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteNoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SendSummaryToCrmInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SettingsInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmMetadataInterface;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\SocialAccountNotFoundException;\nuse Jiminny\\Jobs\\Crm\\NoteObject;\nuse Jiminny\\Models\\Account;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Contracts\\ActivityContract;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Opportunity;\nuse Jiminny\\Models\\Stage;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Crm\\BaseService;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationAppProviders;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationConfigFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\FieldMapperInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\LeadFieldMapper;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\GenerateProviderUrlInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\IntegrationAppCrmGeneratorFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\UrlGeneratorInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmFieldsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SystemStateTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\LayoutTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\MatchProspectsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\NotSupportedTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmEntitiesTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmMetadataTrait;\nuse Psr\\Log\\LoggerInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\OpportunityFieldMapper;\nuse Jiminny\\Repositories\\Crm\\ProfileRepository;\nuse Jiminny\\Repositories\\Crm\\OpportunityRepository;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Services\\Crm\\CrmObjects\\CrmObjectsRepository;\n\nclass Service extends BaseService implements\n IntegrationAppInterface,\n SyncCrmEntitiesInterface,\n SyncCrmMetadataInterface,\n ImportsBusinessProcessesInterface,\n RemoteEntityManipulationInterface,\n LayoutManagementInterface,\n SettingsInterface,\n MatchCrmEntitiesInterface,\n RemoteEntityLookupInterface,\n RemoteNoteEntityManipulationInterface,\n SendSummaryToCrmInterface,\n UrlGeneratorInterface,\n FetchRelatedActivityInterface\n{\n use SyncCrmMetadataTrait;\n use SyncCrmEntitiesTrait;\n use SystemStateTrait;\n use LayoutTrait;\n use NotSupportedTrait;\n use MatchProspectsTrait;\n use SyncCrmFieldsTrait;\n\n public const string CALL_TYPE_MISSED = 'Missed';\n public const string CALL_TYPE_INBOUND = 'Inbound';\n public const string CALL_TYPE_OUTBOUND = 'Outbound';\n public const string RELATIONSHIP_OPPORTUNITY = 'Deals';\n public const string RELATIONSHIP_LEAD = 'Leads';\n public const string RELATIONSHIP_ACCOUNT = 'Accounts';\n\n /**\n * @var ClientInterface&DataClient\n */\n protected $client;\n\n protected ?User $invokedUser = null;\n\n protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;\n\n public function __construct(\n DataClient $client,\n LoggerInterface $logger,\n ) {\n parent::__construct();\n $this->client = $client;\n $this->logger = $logger;\n }\n\n public function getDisplayName(): string\n {\n return Providers::getProviderDisplayName(\n Providers::getCrmIntegrationSlug($this->config)\n );\n }\n\n /**\n * @throws \\Exception\n */\n public function setUser(User $user): void\n {\n $this->configureSentryScope($user);\n $this->invokedUser = $user;\n\n $this->team = $user->getTeam();\n $teamOwner = $this->team->getOwner();\n\n $this->setConfiguration($user->getTeam()->getCrmConfiguration());\n $this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));\n $this->setCrmUrlGenerator($this->config);\n\n $this->client->setTeam($this->team);\n $socialAccount = $teamOwner?->getSocialAccount('integration-app');\n if ($socialAccount === null) {\n $this->logger->info('[integration-app] Social account not found', [\n 'teamId' => $this->team->getId(),\n 'teamOwnerId' => $teamOwner?->getId(),\n 'userId' => $user->getId(),\n ]);\n\n throw new SocialAccountNotFoundException('Social account not found!');\n }\n $this->client->setSocialAccount($socialAccount);\n\n // The CRM Service is properly bootstrapped, and supports remote operations\n $this->connect();\n }\n\n public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string\n {\n return $fieldValue;\n }\n\n public function find(string $name, array $scopes): array\n {\n /** @var LocalSearch $localSearch */\n $localSearch = app(LocalSearch::class);\n $localSearch->setConfiguration($this->config);\n $localSearch->setCountryCode($this->invokedUser->getCountryCode());\n\n return $localSearch->search($name);\n\n // if (! empty($localMatch)) {\n // return $localMatch;\n // }\n //\n // /** @var RemoteSearch $remoteSearch */\n // $remoteSearch = app(RemoteSearch::class);\n // $remoteSearch->setClient($this->client);\n // $remoteSearch->setConfiguration($this->config);\n //\n // return $remoteSearch->search($name);\n }\n\n public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array\n {\n $data = [];\n $ownerData = [];\n\n $account = $this->getAccount($crmAccountId, $crmContactId);\n if ($account === null) {\n return [];\n }\n\n $ownerId = $this->getOwnerId($userId);\n\n try {\n $opportunityRepository = app(OpportunityRepository::class);\n $opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(\n $this->config,\n $account->getId()\n );\n\n foreach ($opportunities as $opportunity) {\n /** @var Opportunity $opportunity */\n $record = $this->buildOpportunityData($opportunity);\n\n if ($ownerId && $opportunity->getOwnerId() === $ownerId) {\n $ownerData[] = $record;\n }\n\n $data[] = $record;\n }\n\n if (! empty($ownerData)) {\n return $ownerData;\n }\n\n return $data;\n } catch (\\Exception $e) {\n $this->logger->info('[integration-app] Failed to fetch opportunities', [\n 'contact' => $crmContactId,\n 'account' => $crmAccountId,\n 'owner' => $ownerId,\n 'error' => $e->getMessage(),\n ]);\n\n return $data;\n }\n }\n\n private function getOwnerId(?int $userId = null): ?string\n {\n if (! $userId) {\n return null;\n }\n\n $profileRepository = app(ProfileRepository::class);\n $profile = $profileRepository->findProfileByUserId($this->config, $userId);\n\n return $profile instanceof Profile ? $profile->getCrmProviderId() : null;\n }\n\n private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account\n {\n $crmRepository = app(CrmObjectsRepository::class);\n\n if ($crmAccountId === null) {\n $contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);\n\n return $contact->getAccount();\n }\n\n return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);\n }\n\n private function buildOpportunityData(Opportunity $opportunity): array\n {\n $record = [\n 'crmId' => $opportunity->getCrmProviderId(),\n 'name' => $opportunity->getName(),\n 'won' => $opportunity->isWon(),\n 'closed' => $opportunity->isClosed(),\n ];\n\n if (! empty($opportunity->getFormattedValueAttribute())) {\n $record['value'] = $opportunity->getFormattedValueAttribute();\n }\n\n if (! empty($opportunity->getStage())) {\n $record['stage'] = [\n 'id' => $opportunity->getStage()->getUuid(),\n 'name' => $opportunity->getStage()->getName(),\n ];\n }\n\n return $record;\n }\n\n public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void\n {\n $data = [\n 'data' => $this->normalizeData($objectType, $data),\n ];\n\n $this->client->updateRecordById($objectType, $objectId, $data);\n }\n\n private function normalizeData(string $objectType, array $data): array\n {\n $fieldMapper = $this->getFieldMapper($objectType);\n\n if (! $fieldMapper instanceof FieldMapperInterface) {\n return $data;\n }\n\n return $fieldMapper->mapToCrmFields($data);\n }\n\n private function getFieldMapper(string $objectType): ?FieldMapperInterface\n {\n if ($objectType === self::OBJECT_OPPORTUNITY) {\n return app(OpportunityFieldMapper::class);\n }\n\n if ($objectType === self::OBJECT_LEAD) {\n return app(LeadFieldMapper::class);\n }\n\n return null;\n }\n\n public function getRecord(string $objectType, string $objectId, array $fields = []): array\n {\n return $this->client->getRecordById($objectType, $objectId);\n }\n\n public function getConfiguration(): Configuration\n {\n return $this->config;\n }\n\n public function setConfiguration(Configuration $config): void\n {\n $this->clearExternalMapCache();\n\n $this->config = $config;\n }\n\n private function setEditionConfiguration(string $provider): void\n {\n $this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);\n }\n\n public function setCrmUrlGenerator(Configuration $config): void\n {\n $this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);\n }\n\n public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface\n {\n if ($this->crmUrlGenerator === null) {\n $this->setCrmUrlGenerator($this->config);\n }\n\n return $this->crmUrlGenerator;\n }\n\n public function subscribeEntityEvents(bool $enableTrigger = true): void\n {\n $eventStates = $this->client->updateEntityEventsState($enableTrigger);\n\n $this->logger->info('[integration-app] Change team entity events subscription', [\n 'teamId' => $this->team->getId(),\n 'teamName' => $this->team->getName(),\n 'states' => $eventStates,\n 'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',\n ]);\n }\n\n #[\\Override] public function supportsNotes(): bool\n {\n return $this->editionConfig->supportsNotes();\n }\n\n #[\\Override] public function saveNote(\n string $title,\n string $body,\n string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n if ($noteObject === null) {\n return null;\n }\n\n $notePayload = [\n 'title' => $title,\n 'content' => $body,\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n ];\n\n $result = $this->client->createNote($notePayload);\n\n // debug saving note response\n $this->logger->info('[integration-app] createNote response', [\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n 'result' => $result,\n 'hasId' => isset($result['id']),\n ]);\n\n return $result['id'] ?? null;\n }\n\n /**\n * @throws CrmException\n */\n #[\\Override] public function saveActivity(Activity $activity): Activity\n {\n $this->logger->info('[integration-app] saveActivity', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n ]);\n\n if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {\n $crmActivity = $this->saveMeeting($activity);\n } elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {\n $crmActivity = $this->saveCall($activity);\n } else {\n throw new CrmException('Unsupported activity type');\n }\n\n $crmActivityId = $crmActivity['id'] ?? null;\n\n if ($crmActivityId !== null) {\n $activity->crm_provider_id = $crmActivityId;\n $activity->save();\n\n $this->logger->info('[integration-app] Activity successfully logged to CRM', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n 'crmId' => $crmActivityId,\n ]);\n }\n\n return $activity;\n }\n\n public function saveMeeting(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $meetingPayload = [\n 'Event_Title' => $decorateActivity->generateTitle($activity),\n 'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),\n 'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($meetingPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $meeting = $this->client->getMeeting($crmId);\n\n $oldDescription = $meeting['fields']['Description'] ?? null;\n $payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update meeting', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateMeeting($crmId, $payload);\n }\n\n $payload['Description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log meeting', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createMeeting($payload);\n }\n\n public function saveCall(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $callPayload = [\n 'Call_Type' => $this->getCallType($activity),\n 'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),\n 'Call_Duration' => $activity->getDuration(),\n 'name' => $decorateActivity->generateTitle($activity),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($callPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $call = $this->client->getCall($crmId);\n\n $oldDescription = $call['fields']['Description'] ?? null;\n $payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update call', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateCall($crmId, $payload);\n }\n\n $payload['description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log call', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createCall($payload);\n }\n\n private function getCallType(Activity $activity): string\n {\n if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {\n return self::CALL_TYPE_MISSED;\n }\n\n return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;\n }\n\n private function attachToProspect(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->hasContact()) {\n $payload['contactId'] = $activity->getContact()->getCrmProviderId();\n }\n\n if ($activity->hasOpportunity()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_OPPORTUNITY,\n $activity->getOpportunity()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_ACCOUNT,\n $activity->getAccount()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasLead()) {\n $payload = $this->handleLeadPayload($activity);\n }\n\n return $payload;\n }\n\n private function handleLeadPayload(Activity $activity): array\n {\n $freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());\n $lead = $freshLead ?? $activity->getLead();\n\n if ($lead->getConvertedAt() === null) {\n return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());\n }\n\n $activity->lead_id = null;\n\n if ($lead->hasAccount()) {\n $account = $lead->getAccount();\n $activity->account_id = $account->getId();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());\n } else {\n $payload = [];\n }\n\n if ($lead->hasOpportunity()) {\n $opportunity = $lead->getOpportunity();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());\n $activity->opportunity_id = $opportunity->getId();\n $activity->value = $opportunity->value;\n $activity->stage_id = $opportunity->stage_id;\n } else {\n $activity->stage_id = null;\n }\n\n if ($lead->hasContact()) {\n $contact = $lead->getContact();\n $payload['contactId'] = $contact->getCrmProviderId();\n $activity->contact_id = $contact->getId();\n }\n\n $activity->save();\n event(new ActivityLeadConverted($activity, $lead));\n\n $this->logger->info('[integration-app] Lead converted', [\n 'activityUuid' => $activity->getUuid(),\n 'leadUuid' => $lead->getUuid(),\n ]);\n\n return $payload;\n }\n\n private function buildBasicPayload(string $type, string $id): array\n {\n return [\n 'type' => $type,\n 'id' => $id,\n ];\n }\n private function getActivityOwnerId(Activity $activity): ?string\n {\n $ownerId = null;\n if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {\n $ownerId = $activity->getUser()->getProfile()->getCrmProviderId();\n }\n\n return $ownerId;\n }\n\n #[\\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n $taskPayload = [\n 'subject' => $fields['subject'],\n 'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n if (isset($fields['status'])) {\n $taskPayload['status'] = $fields['status'];\n }\n\n if (isset($fields['priority'])) {\n $taskPayload['priority'] = $fields['priority'];\n }\n\n if (isset($fields['content'])) {\n $taskPayload['content'] = $fields['content'];\n }\n\n $payload = array_merge($taskPayload, $this->attachToProspect($activity));\n\n $this->logger->info('[integration-app] CRM log follow up task', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n $task = $this->client->createTask($payload);\n\n return $task['id'] ?? null;\n }\n\n #[\\Override] public function saveTranscriptionSummaryAsNote(\n ActivityContract $activity,\n string $title,\n string $body,\n ?string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n // We have to find a way to store the transcription summary\n // This might be possible either by Tasks, Events, Engagements & Notes\n // Find what the CRM supports and save the note with the appropriate object(eg Notes)\n\n // For now use only Notes as both ZOHO & Salesforce support them.\n if ($this->supportsNotes() && $objectId !== null) {\n $this->logger->info('[integration-app] saving note', [\n 'activityId' => $activity->getUuid(),\n 'objectId' => $objectId,\n ]);\n\n return $this->saveNote($title, $body, $objectId, $noteObject);\n }\n\n $this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [\n 'activityId' => $activity->getUuid(),\n 'supportsNotes' => $this->supportsNotes(),\n 'objectId' => $objectId,\n ]);\n\n return null;\n }\n\n public function generateProviderUrl(string $providerId, string $objectType): ?string\n {\n return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);\n }\n\n public function updateStage($crmObject, Stage $stage): void\n {\n $objectType = $stage->getType();\n $objectId = $crmObject->getCrmProviderId();\n $params = ['stageName' => $stage->getCrmProviderId()];\n\n $this->logger->info('[integration-app] updateStage', [\n 'objectType' => $objectType,\n 'objectId' => $objectId,\n 'params' => $params,\n ]);\n\n $data = [\n 'data' => $this->normalizeData($objectType, $params),\n ];\n\n\n if ($objectType === Stage::TYPE_LEAD) {\n $this->client->updateLead($objectId, $data);\n } else {\n $this->client->updateDeal($objectId, $data);\n }\n }\n\n /**\n * @throws \\Exception\n */\n public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity\n {\n if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {\n return null;\n }\n\n if (! $activity->isTypeConference()) {\n return null;\n }\n\n // The related activity is already linked.\n if ($activity->hasCrmProviderId()) {\n return $activity;\n }\n\n if ($activity->hasActualStartTime() === false) {\n return null;\n }\n\n return $this->fetchAndAssociateZohoRelatedActivity($activity);\n }\n\n public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity\n {\n try {\n $meeting = $this->fetchRelatedZohoActivity($activity);\n if (empty($meeting)) {\n $this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [\n 'activity' => $activity->getUuid(),\n ]);\n\n return null;\n }\n\n $decorateActivity = app(DecorateActivity::class);\n $oldDescription = $meeting['Description'] ?? '';\n $updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [\n 'activity' => $activity->getUuid(),\n 'description' => $updatedDescription,\n ]);\n\n $this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);\n\n // Update our activity to reflect the remote data.\n $activity->update([\n 'crm_provider_id' => $meeting['id'],\n 'summary' => $meeting['Description'],\n ]);\n\n return $activity;\n } catch (\\Exception $exception) {\n \\Sentry::captureException($exception);\n\n throw $exception;\n }\n }\n\n public function fetchRelatedZohoActivity(Activity $activity): array\n {\n [$from, $to] = $this->getFromToDates($activity);\n\n $start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00\n $end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00\n if ($start === null || $end === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity missing start or end date',\n [\n 'activity' => $activity->getUuid(),\n 'start' => $start,\n 'end' => $end,\n 'from' => $from,\n 'to' => $to,\n ]\n );\n\n return [];\n }\n\n $whoId = null;\n $whatId = null;\n $criteriaParts = [];\n\n if ($activity->getContact()) {\n $whoId = $activity->getContact()->getCrmProviderId();\n $criteriaParts[] = \"(Who_Id:equals:$whoId)\";\n }\n\n if ($activity->getOpportunity()) {\n $whatId = $activity->getOpportunity()->getCrmProviderId();\n } elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {\n $whatId = $activity->getAccount()->getCrmProviderId();\n } elseif ($activity->getLead()) {\n $whatId = $activity->getLead()->getCrmProviderId();\n }\n\n if ($whatId !== null) {\n $criteriaParts[] = \"(What_Id:equals:$whatId)\";\n }\n\n if ($whoId === null && $whatId === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity cannot find prospect',\n [\n 'activity' => $activity->getUuid(),\n ]\n );\n\n return [];\n }\n\n $criteriaParts[] = \"(Start_DateTime:greater_equal:$start)\";\n $criteriaParts[] = \"(End_DateTime:less_equal:$end)\";\n\n $criteria = implode(' AND ', $criteriaParts);\n\n $params = [\n 'criteria' => $criteria,\n 'sort_by' => 'Modified_Time',\n 'sort_order' => 'desc',\n ];\n\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity searching for related activity',\n [\n 'activity' => $activity->getUuid(),\n 'params' => $params,\n ]\n );\n\n $meetings = $this->client->searchMeetings($params);\n if (! empty($meetings)) {\n return $meetings[0];\n }\n\n return [];\n }\n\n private function getFromToDates(Activity $activity): array\n {\n $calendarEvent = $activity->calendarEvent()->first();\n\n $from = $calendarEvent?->getStartTime();\n $to = $calendarEvent?->getEndTime();\n\n if (! $from || ! $to) {\n $from = $activity->hasScheduledStartTime()\n ? $activity->getScheduledStartTime()\n : $activity->getActualStartTime();\n\n $to = $activity->hasScheduledEndTime()\n ? $activity->getScheduledEndTime()->addMinutes(15)\n : $activity->getActualEndTime();\n }\n\n return [$from, $to];\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.28224733,"top":1.0,"width":0.024268618,"height":-0.04788506},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
4266403488567062772
|
6524482065460761565
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp;
use Carbon\Carbon;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Services\Crm\ClientInterface;
use Jiminny\Contracts\Services\Crm\FetchRelatedActivityInterface;
use Jiminny\Contracts\Services\Crm\ImportsBusinessProcessesInterface;
use Jiminny\Contracts\Services\Crm\LayoutManagementInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityLookupInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\RemoteNoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\SendSummaryToCrmInterface;
use Jiminny\Contracts\Services\Crm\SettingsInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmMetadataInterface;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\SocialAccountNotFoundException;
use Jiminny\Jobs\Crm\NoteObject;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contracts\ActivityContract;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Jiminny\Models\User;
use Jiminny\Services\Crm\BaseService;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationAppProviders;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationConfigFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\FieldMapperInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\LeadFieldMapper;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\GenerateProviderUrlInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\IntegrationAppCrmGeneratorFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\UrlGeneratorInterface;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmFieldsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SystemStateTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\LayoutTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\MatchProspectsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\NotSupportedTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmEntitiesTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmMetadataTrait;
use Psr\Log\LoggerInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\OpportunityFieldMapper;
use Jiminny\Repositories\Crm\ProfileRepository;
use Jiminny\Repositories\Crm\OpportunityRepository;
use Jiminny\Models\Crm\Profile;
use Jiminny\Services\Crm\CrmObjects\CrmObjectsRepository;
class Service extends BaseService implements
IntegrationAppInterface,
SyncCrmEntitiesInterface,
SyncCrmMetadataInterface,
ImportsBusinessProcessesInterface,
RemoteEntityManipulationInterface,
LayoutManagementInterface,
SettingsInterface,
MatchCrmEntitiesInterface,
RemoteEntityLookupInterface,
RemoteNoteEntityManipulationInterface,
SendSummaryToCrmInterface,
UrlGeneratorInterface,
FetchRelatedActivityInterface
{
use SyncCrmMetadataTrait;
use SyncCrmEntitiesTrait;
use SystemStateTrait;
use LayoutTrait;
use NotSupportedTrait;
use MatchProspectsTrait;
use SyncCrmFieldsTrait;
public const string CALL_TYPE_MISSED = 'Missed';
public const string CALL_TYPE_INBOUND = 'Inbound';
public const string CALL_TYPE_OUTBOUND = 'Outbound';
public const string RELATIONSHIP_OPPORTUNITY = 'Deals';
public const string RELATIONSHIP_LEAD = 'Leads';
public const string RELATIONSHIP_ACCOUNT = 'Accounts';
/**
* @var ClientInterface&DataClient
*/
protected $client;
protected ?User $invokedUser = null;
protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;
public function __construct(
DataClient $client,
LoggerInterface $logger,
) {
parent::__construct();
$this->client = $client;
$this->logger = $logger;
}
public function getDisplayName(): string
{
return Providers::getProviderDisplayName(
Providers::getCrmIntegrationSlug($this->config)
);
}
/**
* @throws \Exception
*/
public function setUser(User $user): void
{
$this->configureSentryScope($user);
$this->invokedUser = $user;
$this->team = $user->getTeam();
$teamOwner = $this->team->getOwner();
$this->setConfiguration($user->getTeam()->getCrmConfiguration());
$this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));
$this->setCrmUrlGenerator($this->config);
$this->client->setTeam($this->team);
$socialAccount = $teamOwner?->getSocialAccount('integration-app');
if ($socialAccount === null) {
$this->logger->info('[integration-app] Social account not found', [
'teamId' => $this->team->getId(),
'teamOwnerId' => $teamOwner?->getId(),
'userId' => $user->getId(),
]);
throw new SocialAccountNotFoundException('Social account not found!');
}
$this->client->setSocialAccount($socialAccount);
// The CRM Service is properly bootstrapped, and supports remote operations
$this->connect();
}
public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string
{
return $fieldValue;
}
public function find(string $name, array $scopes): array
{
/** @var LocalSearch $localSearch */
$localSearch = app(LocalSearch::class);
$localSearch->setConfiguration($this->config);
$localSearch->setCountryCode($this->invokedUser->getCountryCode());
return $localSearch->search($name);
// if (! empty($localMatch)) {
// return $localMatch;
// }
//
// /** @var RemoteSearch $remoteSearch */
// $remoteSearch = app(RemoteSearch::class);
// $remoteSearch->setClient($this->client);
// $remoteSearch->setConfiguration($this->config);
//
// return $remoteSearch->search($name);
}
public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array
{
$data = [];
$ownerData = [];
$account = $this->getAccount($crmAccountId, $crmContactId);
if ($account === null) {
return [];
}
$ownerId = $this->getOwnerId($userId);
try {
$opportunityRepository = app(OpportunityRepository::class);
$opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(
$this->config,
$account->getId()
);
foreach ($opportunities as $opportunity) {
/** @var Opportunity $opportunity */
$record = $this->buildOpportunityData($opportunity);
if ($ownerId && $opportunity->getOwnerId() === $ownerId) {
$ownerData[] = $record;
}
$data[] = $record;
}
if (! empty($ownerData)) {
return $ownerData;
}
return $data;
} catch (\Exception $e) {
$this->logger->info('[integration-app] Failed to fetch opportunities', [
'contact' => $crmContactId,
'account' => $crmAccountId,
'owner' => $ownerId,
'error' => $e->getMessage(),
]);
return $data;
}
}
private function getOwnerId(?int $userId = null): ?string
{
if (! $userId) {
return null;
}
$profileRepository = app(ProfileRepository::class);
$profile = $profileRepository->findProfileByUserId($this->config, $userId);
return $profile instanceof Profile ? $profile->getCrmProviderId() : null;
}
private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account
{
$crmRepository = app(CrmObjectsRepository::class);
if ($crmAccountId === null) {
$contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);
return $contact->getAccount();
}
return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);
}
private function buildOpportunityData(Opportunity $opportunity): array
{
$record = [
'crmId' => $opportunity->getCrmProviderId(),
'name' => $opportunity->getName(),
'won' => $opportunity->isWon(),
'closed' => $opportunity->isClosed(),
];
if (! empty($opportunity->getFormattedValueAttribute())) {
$record['value'] = $opportunity->getFormattedValueAttribute();
}
if (! empty($opportunity->getStage())) {
$record['stage'] = [
'id' => $opportunity->getStage()->getUuid(),
'name' => $opportunity->getStage()->getName(),
];
}
return $record;
}
public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void
{
$data = [
'data' => $this->normalizeData($objectType, $data),
];
$this->client->updateRecordById($objectType, $objectId, $data);
}
private function normalizeData(string $objectType, array $data): array
{
$fieldMapper = $this->getFieldMapper($objectType);
if (! $fieldMapper instanceof FieldMapperInterface) {
return $data;
}
return $fieldMapper->mapToCrmFields($data);
}
private function getFieldMapper(string $objectType): ?FieldMapperInterface
{
if ($objectType === self::OBJECT_OPPORTUNITY) {
return app(OpportunityFieldMapper::class);
}
if ($objectType === self::OBJECT_LEAD) {
return app(LeadFieldMapper::class);
}
return null;
}
public function getRecord(string $objectType, string $objectId, array $fields = []): array
{
return $this->client->getRecordById($objectType, $objectId);
}
public function getConfiguration(): Configuration
{
return $this->config;
}
public function setConfiguration(Configuration $config): void
{
$this->clearExternalMapCache();
$this->config = $config;
}
private function setEditionConfiguration(string $provider): void
{
$this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);
}
public function setCrmUrlGenerator(Configuration $config): void
{
$this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);
}
public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface
{
if ($this->crmUrlGenerator === null) {
$this->setCrmUrlGenerator($this->config);
}
return $this->crmUrlGenerator;
}
public function subscribeEntityEvents(bool $enableTrigger = true): void
{
$eventStates = $this->client->updateEntityEventsState($enableTrigger);
$this->logger->info('[integration-app] Change team entity events subscription', [
'teamId' => $this->team->getId(),
'teamName' => $this->team->getName(),
'states' => $eventStates,
'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',
]);
}
#[\Override] public function supportsNotes(): bool
{
return $this->editionConfig->supportsNotes();
}
#[\Override] public function saveNote(
string $title,
string $body,
string $objectId,
?NoteObject $noteObject = null,
): ?string {
if ($noteObject === null) {
return null;
}
$notePayload = [
'title' => $title,
'content' => $body,
'objectId' => $objectId,
'objectType' => $noteObject->value,
];
$result = $this->client->createNote($notePayload);
// debug saving note response
$this->logger->info('[integration-app] createNote response', [
'objectId' => $objectId,
'objectType' => $noteObject->value,
'result' => $result,
'hasId' => isset($result['id']),
]);
return $result['id'] ?? null;
}
/**
* @throws CrmException
*/
#[\Override] public function saveActivity(Activity $activity): Activity
{
$this->logger->info('[integration-app] saveActivity', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
]);
if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {
$crmActivity = $this->saveMeeting($activity);
} elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {
$crmActivity = $this->saveCall($activity);
} else {
throw new CrmException('Unsupported activity type');
}
$crmActivityId = $crmActivity['id'] ?? null;
if ($crmActivityId !== null) {
$activity->crm_provider_id = $crmActivityId;
$activity->save();
$this->logger->info('[integration-app] Activity successfully logged to CRM', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
'crmId' => $crmActivityId,
]);
}
return $activity;
}
public function saveMeeting(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$meetingPayload = [
'Event_Title' => $decorateActivity->generateTitle($activity),
'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),
'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($meetingPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$meeting = $this->client->getMeeting($crmId);
$oldDescription = $meeting['fields']['Description'] ?? null;
$payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update meeting', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateMeeting($crmId, $payload);
}
$payload['Description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log meeting', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createMeeting($payload);
}
public function saveCall(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$callPayload = [
'Call_Type' => $this->getCallType($activity),
'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),
'Call_Duration' => $activity->getDuration(),
'name' => $decorateActivity->generateTitle($activity),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($callPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$call = $this->client->getCall($crmId);
$oldDescription = $call['fields']['Description'] ?? null;
$payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update call', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateCall($crmId, $payload);
}
$payload['description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log call', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createCall($payload);
}
private function getCallType(Activity $activity): string
{
if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {
return self::CALL_TYPE_MISSED;
}
return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;
}
private function attachToProspect(Activity $activity): array
{
$payload = [];
if ($activity->hasContact()) {
$payload['contactId'] = $activity->getContact()->getCrmProviderId();
}
if ($activity->hasOpportunity()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_OPPORTUNITY,
$activity->getOpportunity()->getCrmProviderId()
)
);
}
if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_ACCOUNT,
$activity->getAccount()->getCrmProviderId()
)
);
}
if ($activity->hasLead()) {
$payload = $this->handleLeadPayload($activity);
}
return $payload;
}
private function handleLeadPayload(Activity $activity): array
{
$freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());
$lead = $freshLead ?? $activity->getLead();
if ($lead->getConvertedAt() === null) {
return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());
}
$activity->lead_id = null;
if ($lead->hasAccount()) {
$account = $lead->getAccount();
$activity->account_id = $account->getId();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());
} else {
$payload = [];
}
if ($lead->hasOpportunity()) {
$opportunity = $lead->getOpportunity();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());
$activity->opportunity_id = $opportunity->getId();
$activity->value = $opportunity->value;
$activity->stage_id = $opportunity->stage_id;
} else {
$activity->stage_id = null;
}
if ($lead->hasContact()) {
$contact = $lead->getContact();
$payload['contactId'] = $contact->getCrmProviderId();
$activity->contact_id = $contact->getId();
}
$activity->save();
event(new ActivityLeadConverted($activity, $lead));
$this->logger->info('[integration-app] Lead converted', [
'activityUuid' => $activity->getUuid(),
'leadUuid' => $lead->getUuid(),
]);
return $payload;
}
private function buildBasicPayload(string $type, string $id): array
{
return [
'type' => $type,
'id' => $id,
];
}
private function getActivityOwnerId(Activity $activity): ?string
{
$ownerId = null;
if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {
$ownerId = $activity->getUser()->getProfile()->getCrmProviderId();
}
return $ownerId;
}
#[\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
$taskPayload = [
'subject' => $fields['subject'],
'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,
'ownerId' => $this->getActivityOwnerId($activity),
];
if (isset($fields['status'])) {
$taskPayload['status'] = $fields['status'];
}
if (isset($fields['priority'])) {
$taskPayload['priority'] = $fields['priority'];
}
if (isset($fields['content'])) {
$taskPayload['content'] = $fields['content'];
}
$payload = array_merge($taskPayload, $this->attachToProspect($activity));
$this->logger->info('[integration-app] CRM log follow up task', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
$task = $this->client->createTask($payload);
return $task['id'] ?? null;
}
#[\Override] public function saveTranscriptionSummaryAsNote(
ActivityContract $activity,
string $title,
string $body,
?string $objectId,
?NoteObject $noteObject = null,
): ?string {
// We have to find a way to store the transcription summary
// This might be possible either by Tasks, Events, Engagements & Notes
// Find what the CRM supports and save the note with the appropriate object(eg Notes)
// For now use only Notes as both ZOHO & Salesforce support them.
if ($this->supportsNotes() && $objectId !== null) {
$this->logger->info('[integration-app] saving note', [
'activityId' => $activity->getUuid(),
'objectId' => $objectId,
]);
return $this->saveNote($title, $body, $objectId, $noteObject);
}
$this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [
'activityId' => $activity->getUuid(),
'supportsNotes' => $this->supportsNotes(),
'objectId' => $objectId,
]);
return null;
}
public function generateProviderUrl(string $providerId, string $objectType): ?string
{
return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);
}
public function updateStage($crmObject, Stage $stage): void
{
$objectType = $stage->getType();
$objectId = $crmObject->getCrmProviderId();
$params = ['stageName' => $stage->getCrmProviderId()];
$this->logger->info('[integration-app] updateStage', [
'objectType' => $objectType,
'objectId' => $objectId,
'params' => $params,
]);
$data = [
'data' => $this->normalizeData($objectType, $params),
];
if ($objectType === Stage::TYPE_LEAD) {
$this->client->updateLead($objectId, $data);
} else {
$this->client->updateDeal($objectId, $data);
}
}
/**
* @throws \Exception
*/
public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity
{
if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {
return null;
}
if (! $activity->isTypeConference()) {
return null;
}
// The related activity is already linked.
if ($activity->hasCrmProviderId()) {
return $activity;
}
if ($activity->hasActualStartTime() === false) {
return null;
}
return $this->fetchAndAssociateZohoRelatedActivity($activity);
}
public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity
{
try {
$meeting = $this->fetchRelatedZohoActivity($activity);
if (empty($meeting)) {
$this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [
'activity' => $activity->getUuid(),
]);
return null;
}
$decorateActivity = app(DecorateActivity::class);
$oldDescription = $meeting['Description'] ?? '';
$updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [
'activity' => $activity->getUuid(),
'description' => $updatedDescription,
]);
$this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);
// Update our activity to reflect the remote data.
$activity->update([
'crm_provider_id' => $meeting['id'],
'summary' => $meeting['Description'],
]);
return $activity;
} catch (\Exception $exception) {
\Sentry::captureException($exception);
throw $exception;
}
}
public function fetchRelatedZohoActivity(Activity $activity): array
{
[$from, $to] = $this->getFromToDates($activity);
$start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00
$end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00
if ($start === null || $end === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity missing start or end date',
[
'activity' => $activity->getUuid(),
'start' => $start,
'end' => $end,
'from' => $from,
'to' => $to,
]
);
return [];
}
$whoId = null;
$whatId = null;
$criteriaParts = [];
if ($activity->getContact()) {
$whoId = $activity->getContact()->getCrmProviderId();
$criteriaParts[] = "(Who_Id:equals:$whoId)";
}
if ($activity->getOpportunity()) {
$whatId = $activity->getOpportunity()->getCrmProviderId();
} elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {
$whatId = $activity->getAccount()->getCrmProviderId();
} elseif ($activity->getLead()) {
$whatId = $activity->getLead()->getCrmProviderId();
}
if ($whatId !== null) {
$criteriaParts[] = "(What_Id:equals:$whatId)";
}
if ($whoId === null && $whatId === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity cannot find prospect',
[
'activity' => $activity->getUuid(),
]
);
return [];
}
$criteriaParts[] = "(Start_DateTime:greater_equal:$start)";
$criteriaParts[] = "(End_DateTime:less_equal:$end)";
$criteria = implode(' AND ', $criteriaParts);
$params = [
'criteria' => $criteria,
'sort_by' => 'Modified_Time',
'sort_order' => 'desc',
];
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity searching for related activity',
[
'activity' => $activity->getUuid(),
'params' => $params,
]
);
$meetings = $this->client->searchMeetings($params);
if (! empty($meetings)) {
return $meetings[0];
}
return [];
}
private function getFromToDates(Activity $activity): array
{
$calendarEvent = $activity->calendarEvent()->first();
$from = $calendarEvent?->getStartTime();
$to = $calendarEvent?->getEndTime();
if (! $from || ! $to) {
$from = $activity->hasScheduledStartTime()
? $activity->getScheduledStartTime()
: $activity->getActualStartTime();
$to = $activity->hasScheduledEndTime()
? $activity->getScheduledEndTime()->addMinutes(15)
: $activity->getActualEndTime();
}
return [$from, $to];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
45480
|
NULL
|
NULL
|
NULL
|
|
45482
|
1627
|
21
|
2026-05-14T14:39:32.981499+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769572981_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationApp/Service.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp;
use Carbon\Carbon;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Services\Crm\ClientInterface;
use Jiminny\Contracts\Services\Crm\FetchRelatedActivityInterface;
use Jiminny\Contracts\Services\Crm\ImportsBusinessProcessesInterface;
use Jiminny\Contracts\Services\Crm\LayoutManagementInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityLookupInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\RemoteNoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\SendSummaryToCrmInterface;
use Jiminny\Contracts\Services\Crm\SettingsInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmMetadataInterface;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\SocialAccountNotFoundException;
use Jiminny\Jobs\Crm\NoteObject;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contracts\ActivityContract;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Jiminny\Models\User;
use Jiminny\Services\Crm\BaseService;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationAppProviders;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationConfigFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\FieldMapperInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\LeadFieldMapper;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\GenerateProviderUrlInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\IntegrationAppCrmGeneratorFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\UrlGeneratorInterface;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmFieldsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SystemStateTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\LayoutTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\MatchProspectsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\NotSupportedTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmEntitiesTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmMetadataTrait;
use Psr\Log\LoggerInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\OpportunityFieldMapper;
use Jiminny\Repositories\Crm\ProfileRepository;
use Jiminny\Repositories\Crm\OpportunityRepository;
use Jiminny\Models\Crm\Profile;
use Jiminny\Services\Crm\CrmObjects\CrmObjectsRepository;
class Service extends BaseService implements
IntegrationAppInterface,
SyncCrmEntitiesInterface,
SyncCrmMetadataInterface,
ImportsBusinessProcessesInterface,
RemoteEntityManipulationInterface,
LayoutManagementInterface,
SettingsInterface,
MatchCrmEntitiesInterface,
RemoteEntityLookupInterface,
RemoteNoteEntityManipulationInterface,
SendSummaryToCrmInterface,
UrlGeneratorInterface,
FetchRelatedActivityInterface
{
use SyncCrmMetadataTrait;
use SyncCrmEntitiesTrait;
use SystemStateTrait;
use LayoutTrait;
use NotSupportedTrait;
use MatchProspectsTrait;
use SyncCrmFieldsTrait;
public const string CALL_TYPE_MISSED = 'Missed';
public const string CALL_TYPE_INBOUND = 'Inbound';
public const string CALL_TYPE_OUTBOUND = 'Outbound';
public const string RELATIONSHIP_OPPORTUNITY = 'Deals';
public const string RELATIONSHIP_LEAD = 'Leads';
public const string RELATIONSHIP_ACCOUNT = 'Accounts';
/**
* @var ClientInterface&DataClient
*/
protected $client;
protected ?User $invokedUser = null;
protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;
public function __construct(
DataClient $client,
LoggerInterface $logger,
) {
parent::__construct();
$this->client = $client;
$this->logger = $logger;
}
public function getDisplayName(): string
{
return Providers::getProviderDisplayName(
Providers::getCrmIntegrationSlug($this->config)
);
}
/**
* @throws \Exception
*/
public function setUser(User $user): void
{
$this->configureSentryScope($user);
$this->invokedUser = $user;
$this->team = $user->getTeam();
$teamOwner = $this->team->getOwner();
$this->setConfiguration($user->getTeam()->getCrmConfiguration());
$this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));
$this->setCrmUrlGenerator($this->config);
$this->client->setTeam($this->team);
$socialAccount = $teamOwner?->getSocialAccount('integration-app');
if ($socialAccount === null) {
$this->logger->info('[integration-app] Social account not found', [
'teamId' => $this->team->getId(),
'teamOwnerId' => $teamOwner?->getId(),
'userId' => $user->getId(),
]);
throw new SocialAccountNotFoundException('Social account not found!');
}
$this->client->setSocialAccount($socialAccount);
// The CRM Service is properly bootstrapped, and supports remote operations
$this->connect();
}
public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string
{
return $fieldValue;
}
public function find(string $name, array $scopes): array
{
/** @var LocalSearch $localSearch */
$localSearch = app(LocalSearch::class);
$localSearch->setConfiguration($this->config);
$localSearch->setCountryCode($this->invokedUser->getCountryCode());
return $localSearch->search($name);
// if (! empty($localMatch)) {
// return $localMatch;
// }
//
// /** @var RemoteSearch $remoteSearch */
// $remoteSearch = app(RemoteSearch::class);
// $remoteSearch->setClient($this->client);
// $remoteSearch->setConfiguration($this->config);
//
// return $remoteSearch->search($name);
}
public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array
{
$data = [];
$ownerData = [];
$account = $this->getAccount($crmAccountId, $crmContactId);
if ($account === null) {
return [];
}
$ownerId = $this->getOwnerId($userId);
try {
$opportunityRepository = app(OpportunityRepository::class);
$opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(
$this->config,
$account->getId()
);
foreach ($opportunities as $opportunity) {
/** @var Opportunity $opportunity */
$record = $this->buildOpportunityData($opportunity);
if ($ownerId && $opportunity->getOwnerId() === $ownerId) {
$ownerData[] = $record;
}
$data[] = $record;
}
if (! empty($ownerData)) {
return $ownerData;
}
return $data;
} catch (\Exception $e) {
$this->logger->info('[integration-app] Failed to fetch opportunities', [
'contact' => $crmContactId,
'account' => $crmAccountId,
'owner' => $ownerId,
'error' => $e->getMessage(),
]);
return $data;
}
}
private function getOwnerId(?int $userId = null): ?string
{
if (! $userId) {
return null;
}
$profileRepository = app(ProfileRepository::class);
$profile = $profileRepository->findProfileByUserId($this->config, $userId);
return $profile instanceof Profile ? $profile->getCrmProviderId() : null;
}
private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account
{
$crmRepository = app(CrmObjectsRepository::class);
if ($crmAccountId === null) {
$contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);
return $contact->getAccount();
}
return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);
}
private function buildOpportunityData(Opportunity $opportunity): array
{
$record = [
'crmId' => $opportunity->getCrmProviderId(),
'name' => $opportunity->getName(),
'won' => $opportunity->isWon(),
'closed' => $opportunity->isClosed(),
];
if (! empty($opportunity->getFormattedValueAttribute())) {
$record['value'] = $opportunity->getFormattedValueAttribute();
}
if (! empty($opportunity->getStage())) {
$record['stage'] = [
'id' => $opportunity->getStage()->getUuid(),
'name' => $opportunity->getStage()->getName(),
];
}
return $record;
}
public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void
{
$data = [
'data' => $this->normalizeData($objectType, $data),
];
$this->client->updateRecordById($objectType, $objectId, $data);
}
private function normalizeData(string $objectType, array $data): array
{
$fieldMapper = $this->getFieldMapper($objectType);
if (! $fieldMapper instanceof FieldMapperInterface) {
return $data;
}
return $fieldMapper->mapToCrmFields($data);
}
private function getFieldMapper(string $objectType): ?FieldMapperInterface
{
if ($objectType === self::OBJECT_OPPORTUNITY) {
return app(OpportunityFieldMapper::class);
}
if ($objectType === self::OBJECT_LEAD) {
return app(LeadFieldMapper::class);
}
return null;
}
public function getRecord(string $objectType, string $objectId, array $fields = []): array
{
return $this->client->getRecordById($objectType, $objectId);
}
public function getConfiguration(): Configuration
{
return $this->config;
}
public function setConfiguration(Configuration $config): void
{
$this->clearExternalMapCache();
$this->config = $config;
}
private function setEditionConfiguration(string $provider): void
{
$this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);
}
public function setCrmUrlGenerator(Configuration $config): void
{
$this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);
}
public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface
{
if ($this->crmUrlGenerator === null) {
$this->setCrmUrlGenerator($this->config);
}
return $this->crmUrlGenerator;
}
public function subscribeEntityEvents(bool $enableTrigger = true): void
{
$eventStates = $this->client->updateEntityEventsState($enableTrigger);
$this->logger->info('[integration-app] Change team entity events subscription', [
'teamId' => $this->team->getId(),
'teamName' => $this->team->getName(),
'states' => $eventStates,
'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',
]);
}
#[\Override] public function supportsNotes(): bool
{
return $this->editionConfig->supportsNotes();
}
#[\Override] public function saveNote(
string $title,
string $body,
string $objectId,
?NoteObject $noteObject = null,
): ?string {
if ($noteObject === null) {
return null;
}
$notePayload = [
'title' => $title,
'content' => $body,
'objectId' => $objectId,
'objectType' => $noteObject->value,
];
$result = $this->client->createNote($notePayload);
// debug saving note response
$this->logger->info('[integration-app] createNote response', [
'objectId' => $objectId,
'objectType' => $noteObject->value,
'result' => $result,
'hasId' => isset($result['id']),
]);
return $result['id'] ?? null;
}
/**
* @throws CrmException
*/
#[\Override] public function saveActivity(Activity $activity): Activity
{
$this->logger->info('[integration-app] saveActivity', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
]);
if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {
$crmActivity = $this->saveMeeting($activity);
} elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {
$crmActivity = $this->saveCall($activity);
} else {
throw new CrmException('Unsupported activity type');
}
$crmActivityId = $crmActivity['id'] ?? null;
if ($crmActivityId !== null) {
$activity->crm_provider_id = $crmActivityId;
$activity->save();
$this->logger->info('[integration-app] Activity successfully logged to CRM', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
'crmId' => $crmActivityId,
]);
}
return $activity;
}
public function saveMeeting(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$meetingPayload = [
'Event_Title' => $decorateActivity->generateTitle($activity),
'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),
'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($meetingPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$meeting = $this->client->getMeeting($crmId);
$oldDescription = $meeting['fields']['Description'] ?? null;
$payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update meeting', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateMeeting($crmId, $payload);
}
$payload['Description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log meeting', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createMeeting($payload);
}
public function saveCall(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$callPayload = [
'Call_Type' => $this->getCallType($activity),
'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),
'Call_Duration' => $activity->getDuration(),
'name' => $decorateActivity->generateTitle($activity),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($callPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$call = $this->client->getCall($crmId);
$oldDescription = $call['fields']['Description'] ?? null;
$payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update call', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateCall($crmId, $payload);
}
$payload['description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log call', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createCall($payload);
}
private function getCallType(Activity $activity): string
{
if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {
return self::CALL_TYPE_MISSED;
}
return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;
}
private function attachToProspect(Activity $activity): array
{
$payload = [];
if ($activity->hasContact()) {
$payload['contactId'] = $activity->getContact()->getCrmProviderId();
}
if ($activity->hasOpportunity()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_OPPORTUNITY,
$activity->getOpportunity()->getCrmProviderId()
)
);
}
if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_ACCOUNT,
$activity->getAccount()->getCrmProviderId()
)
);
}
if ($activity->hasLead()) {
$payload = $this->handleLeadPayload($activity);
}
return $payload;
}
private function handleLeadPayload(Activity $activity): array
{
$freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());
$lead = $freshLead ?? $activity->getLead();
if ($lead->getConvertedAt() === null) {
return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());
}
$activity->lead_id = null;
if ($lead->hasAccount()) {
$account = $lead->getAccount();
$activity->account_id = $account->getId();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());
} else {
$payload = [];
}
if ($lead->hasOpportunity()) {
$opportunity = $lead->getOpportunity();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());
$activity->opportunity_id = $opportunity->getId();
$activity->value = $opportunity->value;
$activity->stage_id = $opportunity->stage_id;
} else {
$activity->stage_id = null;
}
if ($lead->hasContact()) {
$contact = $lead->getContact();
$payload['contactId'] = $contact->getCrmProviderId();
$activity->contact_id = $contact->getId();
}
$activity->save();
event(new ActivityLeadConverted($activity, $lead));
$this->logger->info('[integration-app] Lead converted', [
'activityUuid' => $activity->getUuid(),
'leadUuid' => $lead->getUuid(),
]);
return $payload;
}
private function buildBasicPayload(string $type, string $id): array
{
return [
'type' => $type,
'id' => $id,
];
}
private function getActivityOwnerId(Activity $activity): ?string
{
$ownerId = null;
if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {
$ownerId = $activity->getUser()->getProfile()->getCrmProviderId();
}
return $ownerId;
}
#[\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
$taskPayload = [
'subject' => $fields['subject'],
'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,
'ownerId' => $this->getActivityOwnerId($activity),
];
if (isset($fields['status'])) {
$taskPayload['status'] = $fields['status'];
}
if (isset($fields['priority'])) {
$taskPayload['priority'] = $fields['priority'];
}
if (isset($fields['content'])) {
$taskPayload['content'] = $fields['content'];
}
$payload = array_merge($taskPayload, $this->attachToProspect($activity));
$this->logger->info('[integration-app] CRM log follow up task', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
$task = $this->client->createTask($payload);
return $task['id'] ?? null;
}
#[\Override] public function saveTranscriptionSummaryAsNote(
ActivityContract $activity,
string $title,
string $body,
?string $objectId,
?NoteObject $noteObject = null,
): ?string {
// We have to find a way to store the transcription summary
// This might be possible either by Tasks, Events, Engagements & Notes
// Find what the CRM supports and save the note with the appropriate object(eg Notes)
// For now use only Notes as both ZOHO & Salesforce support them.
if ($this->supportsNotes() && $objectId !== null) {
$this->logger->info('[integration-app] saving note', [
'activityId' => $activity->getUuid(),
'objectId' => $objectId,
]);
return $this->saveNote($title, $body, $objectId, $noteObject);
}
$this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [
'activityId' => $activity->getUuid(),
'supportsNotes' => $this->supportsNotes(),
'objectId' => $objectId,
]);
return null;
}
public function generateProviderUrl(string $providerId, string $objectType): ?string
{
return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);
}
public function updateStage($crmObject, Stage $stage): void
{
$objectType = $stage->getType();
$objectId = $crmObject->getCrmProviderId();
$params = ['stageName' => $stage->getCrmProviderId()];
$this->logger->info('[integration-app] updateStage', [
'objectType' => $objectType,
'objectId' => $objectId,
'params' => $params,
]);
$data = [
'data' => $this->normalizeData($objectType, $params),
];
if ($objectType === Stage::TYPE_LEAD) {
$this->client->updateLead($objectId, $data);
} else {
$this->client->updateDeal($objectId, $data);
}
}
/**
* @throws \Exception
*/
public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity
{
if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {
return null;
}
if (! $activity->isTypeConference()) {
return null;
}
// The related activity is already linked.
if ($activity->hasCrmProviderId()) {
return $activity;
}
if ($activity->hasActualStartTime() === false) {
return null;
}
return $this->fetchAndAssociateZohoRelatedActivity($activity);
}
public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity
{
try {
$meeting = $this->fetchRelatedZohoActivity($activity);
if (empty($meeting)) {
$this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [
'activity' => $activity->getUuid(),
]);
return null;
}
$decorateActivity = app(DecorateActivity::class);
$oldDescription = $meeting['Description'] ?? '';
$updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [
'activity' => $activity->getUuid(),
'description' => $updatedDescription,
]);
$this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);
// Update our activity to reflect the remote data.
$activity->update([
'crm_provider_id' => $meeting['id'],
'summary' => $meeting['Description'],
]);
return $activity;
} catch (\Exception $exception) {
\Sentry::captureException($exception);
throw $exception;
}
}
public function fetchRelatedZohoActivity(Activity $activity): array
{
[$from, $to] = $this->getFromToDates($activity);
$start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00
$end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00
if ($start === null || $end === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity missing start or end date',
[
'activity' => $activity->getUuid(),
'start' => $start,
'end' => $end,
'from' => $from,
'to' => $to,
]
);
return [];
}
$whoId = null;
$whatId = null;
$criteriaParts = [];
if ($activity->getContact()) {
$whoId = $activity->getContact()->getCrmProviderId();
$criteriaParts[] = "(Who_Id:equals:$whoId)";
}
if ($activity->getOpportunity()) {
$whatId = $activity->getOpportunity()->getCrmProviderId();
} elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {
$whatId = $activity->getAccount()->getCrmProviderId();
} elseif ($activity->getLead()) {
$whatId = $activity->getLead()->getCrmProviderId();
}
if ($whatId !== null) {
$criteriaParts[] = "(What_Id:equals:$whatId)";
}
if ($whoId === null && $whatId === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity cannot find prospect',
[
'activity' => $activity->getUuid(),
]
);
return [];
}
$criteriaParts[] = "(Start_DateTime:greater_equal:$start)";
$criteriaParts[] = "(End_DateTime:less_equal:$end)";
$criteria = implode(' AND ', $criteriaParts);
$params = [
'criteria' => $criteria,
'sort_by' => 'Modified_Time',
'sort_order' => 'desc',
];
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity searching for related activity',
[
'activity' => $activity->getUuid(),
'params' => $params,
]
);
$meetings = $this->client->searchMeetings($params);
if (! empty($meetings)) {
return $meetings[0];
}
return [];
}
private function getFromToDates(Activity $activity): array
{
$calendarEvent = $activity->calendarEvent()->first();
$from = $calendarEvent?->getStartTime();
$to = $calendarEvent?->getEndTime();
if (! $from || ! $to) {
$from = $activity->hasScheduledStartTime()
? $activity->getScheduledStartTime()
: $activity->getActualStartTime();
$to = $activity->hasScheduledEndTime()
? $activity->getScheduledEndTime()->addMinutes(15)
: $activity->getActualEndTime();
}
return [$from, $to];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"16","depth":4,"bounds":{"left":0.77708334,"top":0.3122222,"width":0.02013889,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.80138886,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Services\\Crm\\ClientInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\FetchRelatedActivityInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\ImportsBusinessProcessesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\LayoutManagementInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\MatchCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityLookupInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteNoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SendSummaryToCrmInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SettingsInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmMetadataInterface;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\SocialAccountNotFoundException;\nuse Jiminny\\Jobs\\Crm\\NoteObject;\nuse Jiminny\\Models\\Account;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Contracts\\ActivityContract;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Opportunity;\nuse Jiminny\\Models\\Stage;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Crm\\BaseService;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationAppProviders;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationConfigFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\FieldMapperInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\LeadFieldMapper;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\GenerateProviderUrlInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\IntegrationAppCrmGeneratorFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\UrlGeneratorInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmFieldsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SystemStateTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\LayoutTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\MatchProspectsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\NotSupportedTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmEntitiesTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmMetadataTrait;\nuse Psr\\Log\\LoggerInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\OpportunityFieldMapper;\nuse Jiminny\\Repositories\\Crm\\ProfileRepository;\nuse Jiminny\\Repositories\\Crm\\OpportunityRepository;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Services\\Crm\\CrmObjects\\CrmObjectsRepository;\n\nclass Service extends BaseService implements\n IntegrationAppInterface,\n SyncCrmEntitiesInterface,\n SyncCrmMetadataInterface,\n ImportsBusinessProcessesInterface,\n RemoteEntityManipulationInterface,\n LayoutManagementInterface,\n SettingsInterface,\n MatchCrmEntitiesInterface,\n RemoteEntityLookupInterface,\n RemoteNoteEntityManipulationInterface,\n SendSummaryToCrmInterface,\n UrlGeneratorInterface,\n FetchRelatedActivityInterface\n{\n use SyncCrmMetadataTrait;\n use SyncCrmEntitiesTrait;\n use SystemStateTrait;\n use LayoutTrait;\n use NotSupportedTrait;\n use MatchProspectsTrait;\n use SyncCrmFieldsTrait;\n\n public const string CALL_TYPE_MISSED = 'Missed';\n public const string CALL_TYPE_INBOUND = 'Inbound';\n public const string CALL_TYPE_OUTBOUND = 'Outbound';\n public const string RELATIONSHIP_OPPORTUNITY = 'Deals';\n public const string RELATIONSHIP_LEAD = 'Leads';\n public const string RELATIONSHIP_ACCOUNT = 'Accounts';\n\n /**\n * @var ClientInterface&DataClient\n */\n protected $client;\n\n protected ?User $invokedUser = null;\n\n protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;\n\n public function __construct(\n DataClient $client,\n LoggerInterface $logger,\n ) {\n parent::__construct();\n $this->client = $client;\n $this->logger = $logger;\n }\n\n public function getDisplayName(): string\n {\n return Providers::getProviderDisplayName(\n Providers::getCrmIntegrationSlug($this->config)\n );\n }\n\n /**\n * @throws \\Exception\n */\n public function setUser(User $user): void\n {\n $this->configureSentryScope($user);\n $this->invokedUser = $user;\n\n $this->team = $user->getTeam();\n $teamOwner = $this->team->getOwner();\n\n $this->setConfiguration($user->getTeam()->getCrmConfiguration());\n $this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));\n $this->setCrmUrlGenerator($this->config);\n\n $this->client->setTeam($this->team);\n $socialAccount = $teamOwner?->getSocialAccount('integration-app');\n if ($socialAccount === null) {\n $this->logger->info('[integration-app] Social account not found', [\n 'teamId' => $this->team->getId(),\n 'teamOwnerId' => $teamOwner?->getId(),\n 'userId' => $user->getId(),\n ]);\n\n throw new SocialAccountNotFoundException('Social account not found!');\n }\n $this->client->setSocialAccount($socialAccount);\n\n // The CRM Service is properly bootstrapped, and supports remote operations\n $this->connect();\n }\n\n public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string\n {\n return $fieldValue;\n }\n\n public function find(string $name, array $scopes): array\n {\n /** @var LocalSearch $localSearch */\n $localSearch = app(LocalSearch::class);\n $localSearch->setConfiguration($this->config);\n $localSearch->setCountryCode($this->invokedUser->getCountryCode());\n\n return $localSearch->search($name);\n\n // if (! empty($localMatch)) {\n // return $localMatch;\n // }\n //\n // /** @var RemoteSearch $remoteSearch */\n // $remoteSearch = app(RemoteSearch::class);\n // $remoteSearch->setClient($this->client);\n // $remoteSearch->setConfiguration($this->config);\n //\n // return $remoteSearch->search($name);\n }\n\n public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array\n {\n $data = [];\n $ownerData = [];\n\n $account = $this->getAccount($crmAccountId, $crmContactId);\n if ($account === null) {\n return [];\n }\n\n $ownerId = $this->getOwnerId($userId);\n\n try {\n $opportunityRepository = app(OpportunityRepository::class);\n $opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(\n $this->config,\n $account->getId()\n );\n\n foreach ($opportunities as $opportunity) {\n /** @var Opportunity $opportunity */\n $record = $this->buildOpportunityData($opportunity);\n\n if ($ownerId && $opportunity->getOwnerId() === $ownerId) {\n $ownerData[] = $record;\n }\n\n $data[] = $record;\n }\n\n if (! empty($ownerData)) {\n return $ownerData;\n }\n\n return $data;\n } catch (\\Exception $e) {\n $this->logger->info('[integration-app] Failed to fetch opportunities', [\n 'contact' => $crmContactId,\n 'account' => $crmAccountId,\n 'owner' => $ownerId,\n 'error' => $e->getMessage(),\n ]);\n\n return $data;\n }\n }\n\n private function getOwnerId(?int $userId = null): ?string\n {\n if (! $userId) {\n return null;\n }\n\n $profileRepository = app(ProfileRepository::class);\n $profile = $profileRepository->findProfileByUserId($this->config, $userId);\n\n return $profile instanceof Profile ? $profile->getCrmProviderId() : null;\n }\n\n private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account\n {\n $crmRepository = app(CrmObjectsRepository::class);\n\n if ($crmAccountId === null) {\n $contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);\n\n return $contact->getAccount();\n }\n\n return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);\n }\n\n private function buildOpportunityData(Opportunity $opportunity): array\n {\n $record = [\n 'crmId' => $opportunity->getCrmProviderId(),\n 'name' => $opportunity->getName(),\n 'won' => $opportunity->isWon(),\n 'closed' => $opportunity->isClosed(),\n ];\n\n if (! empty($opportunity->getFormattedValueAttribute())) {\n $record['value'] = $opportunity->getFormattedValueAttribute();\n }\n\n if (! empty($opportunity->getStage())) {\n $record['stage'] = [\n 'id' => $opportunity->getStage()->getUuid(),\n 'name' => $opportunity->getStage()->getName(),\n ];\n }\n\n return $record;\n }\n\n public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void\n {\n $data = [\n 'data' => $this->normalizeData($objectType, $data),\n ];\n\n $this->client->updateRecordById($objectType, $objectId, $data);\n }\n\n private function normalizeData(string $objectType, array $data): array\n {\n $fieldMapper = $this->getFieldMapper($objectType);\n\n if (! $fieldMapper instanceof FieldMapperInterface) {\n return $data;\n }\n\n return $fieldMapper->mapToCrmFields($data);\n }\n\n private function getFieldMapper(string $objectType): ?FieldMapperInterface\n {\n if ($objectType === self::OBJECT_OPPORTUNITY) {\n return app(OpportunityFieldMapper::class);\n }\n\n if ($objectType === self::OBJECT_LEAD) {\n return app(LeadFieldMapper::class);\n }\n\n return null;\n }\n\n public function getRecord(string $objectType, string $objectId, array $fields = []): array\n {\n return $this->client->getRecordById($objectType, $objectId);\n }\n\n public function getConfiguration(): Configuration\n {\n return $this->config;\n }\n\n public function setConfiguration(Configuration $config): void\n {\n $this->clearExternalMapCache();\n\n $this->config = $config;\n }\n\n private function setEditionConfiguration(string $provider): void\n {\n $this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);\n }\n\n public function setCrmUrlGenerator(Configuration $config): void\n {\n $this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);\n }\n\n public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface\n {\n if ($this->crmUrlGenerator === null) {\n $this->setCrmUrlGenerator($this->config);\n }\n\n return $this->crmUrlGenerator;\n }\n\n public function subscribeEntityEvents(bool $enableTrigger = true): void\n {\n $eventStates = $this->client->updateEntityEventsState($enableTrigger);\n\n $this->logger->info('[integration-app] Change team entity events subscription', [\n 'teamId' => $this->team->getId(),\n 'teamName' => $this->team->getName(),\n 'states' => $eventStates,\n 'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',\n ]);\n }\n\n #[\\Override] public function supportsNotes(): bool\n {\n return $this->editionConfig->supportsNotes();\n }\n\n #[\\Override] public function saveNote(\n string $title,\n string $body,\n string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n if ($noteObject === null) {\n return null;\n }\n\n $notePayload = [\n 'title' => $title,\n 'content' => $body,\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n ];\n\n $result = $this->client->createNote($notePayload);\n\n // debug saving note response\n $this->logger->info('[integration-app] createNote response', [\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n 'result' => $result,\n 'hasId' => isset($result['id']),\n ]);\n\n return $result['id'] ?? null;\n }\n\n /**\n * @throws CrmException\n */\n #[\\Override] public function saveActivity(Activity $activity): Activity\n {\n $this->logger->info('[integration-app] saveActivity', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n ]);\n\n if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {\n $crmActivity = $this->saveMeeting($activity);\n } elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {\n $crmActivity = $this->saveCall($activity);\n } else {\n throw new CrmException('Unsupported activity type');\n }\n\n $crmActivityId = $crmActivity['id'] ?? null;\n\n if ($crmActivityId !== null) {\n $activity->crm_provider_id = $crmActivityId;\n $activity->save();\n\n $this->logger->info('[integration-app] Activity successfully logged to CRM', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n 'crmId' => $crmActivityId,\n ]);\n }\n\n return $activity;\n }\n\n public function saveMeeting(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $meetingPayload = [\n 'Event_Title' => $decorateActivity->generateTitle($activity),\n 'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),\n 'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($meetingPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $meeting = $this->client->getMeeting($crmId);\n\n $oldDescription = $meeting['fields']['Description'] ?? null;\n $payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update meeting', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateMeeting($crmId, $payload);\n }\n\n $payload['Description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log meeting', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createMeeting($payload);\n }\n\n public function saveCall(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $callPayload = [\n 'Call_Type' => $this->getCallType($activity),\n 'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),\n 'Call_Duration' => $activity->getDuration(),\n 'name' => $decorateActivity->generateTitle($activity),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($callPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $call = $this->client->getCall($crmId);\n\n $oldDescription = $call['fields']['Description'] ?? null;\n $payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update call', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateCall($crmId, $payload);\n }\n\n $payload['description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log call', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createCall($payload);\n }\n\n private function getCallType(Activity $activity): string\n {\n if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {\n return self::CALL_TYPE_MISSED;\n }\n\n return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;\n }\n\n private function attachToProspect(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->hasContact()) {\n $payload['contactId'] = $activity->getContact()->getCrmProviderId();\n }\n\n if ($activity->hasOpportunity()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_OPPORTUNITY,\n $activity->getOpportunity()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_ACCOUNT,\n $activity->getAccount()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasLead()) {\n $payload = $this->handleLeadPayload($activity);\n }\n\n return $payload;\n }\n\n private function handleLeadPayload(Activity $activity): array\n {\n $freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());\n $lead = $freshLead ?? $activity->getLead();\n\n if ($lead->getConvertedAt() === null) {\n return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());\n }\n\n $activity->lead_id = null;\n\n if ($lead->hasAccount()) {\n $account = $lead->getAccount();\n $activity->account_id = $account->getId();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());\n } else {\n $payload = [];\n }\n\n if ($lead->hasOpportunity()) {\n $opportunity = $lead->getOpportunity();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());\n $activity->opportunity_id = $opportunity->getId();\n $activity->value = $opportunity->value;\n $activity->stage_id = $opportunity->stage_id;\n } else {\n $activity->stage_id = null;\n }\n\n if ($lead->hasContact()) {\n $contact = $lead->getContact();\n $payload['contactId'] = $contact->getCrmProviderId();\n $activity->contact_id = $contact->getId();\n }\n\n $activity->save();\n event(new ActivityLeadConverted($activity, $lead));\n\n $this->logger->info('[integration-app] Lead converted', [\n 'activityUuid' => $activity->getUuid(),\n 'leadUuid' => $lead->getUuid(),\n ]);\n\n return $payload;\n }\n\n private function buildBasicPayload(string $type, string $id): array\n {\n return [\n 'type' => $type,\n 'id' => $id,\n ];\n }\n private function getActivityOwnerId(Activity $activity): ?string\n {\n $ownerId = null;\n if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {\n $ownerId = $activity->getUser()->getProfile()->getCrmProviderId();\n }\n\n return $ownerId;\n }\n\n #[\\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n $taskPayload = [\n 'subject' => $fields['subject'],\n 'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n if (isset($fields['status'])) {\n $taskPayload['status'] = $fields['status'];\n }\n\n if (isset($fields['priority'])) {\n $taskPayload['priority'] = $fields['priority'];\n }\n\n if (isset($fields['content'])) {\n $taskPayload['content'] = $fields['content'];\n }\n\n $payload = array_merge($taskPayload, $this->attachToProspect($activity));\n\n $this->logger->info('[integration-app] CRM log follow up task', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n $task = $this->client->createTask($payload);\n\n return $task['id'] ?? null;\n }\n\n #[\\Override] public function saveTranscriptionSummaryAsNote(\n ActivityContract $activity,\n string $title,\n string $body,\n ?string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n // We have to find a way to store the transcription summary\n // This might be possible either by Tasks, Events, Engagements & Notes\n // Find what the CRM supports and save the note with the appropriate object(eg Notes)\n\n // For now use only Notes as both ZOHO & Salesforce support them.\n if ($this->supportsNotes() && $objectId !== null) {\n $this->logger->info('[integration-app] saving note', [\n 'activityId' => $activity->getUuid(),\n 'objectId' => $objectId,\n ]);\n\n return $this->saveNote($title, $body, $objectId, $noteObject);\n }\n\n $this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [\n 'activityId' => $activity->getUuid(),\n 'supportsNotes' => $this->supportsNotes(),\n 'objectId' => $objectId,\n ]);\n\n return null;\n }\n\n public function generateProviderUrl(string $providerId, string $objectType): ?string\n {\n return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);\n }\n\n public function updateStage($crmObject, Stage $stage): void\n {\n $objectType = $stage->getType();\n $objectId = $crmObject->getCrmProviderId();\n $params = ['stageName' => $stage->getCrmProviderId()];\n\n $this->logger->info('[integration-app] updateStage', [\n 'objectType' => $objectType,\n 'objectId' => $objectId,\n 'params' => $params,\n ]);\n\n $data = [\n 'data' => $this->normalizeData($objectType, $params),\n ];\n\n\n if ($objectType === Stage::TYPE_LEAD) {\n $this->client->updateLead($objectId, $data);\n } else {\n $this->client->updateDeal($objectId, $data);\n }\n }\n\n /**\n * @throws \\Exception\n */\n public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity\n {\n if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {\n return null;\n }\n\n if (! $activity->isTypeConference()) {\n return null;\n }\n\n // The related activity is already linked.\n if ($activity->hasCrmProviderId()) {\n return $activity;\n }\n\n if ($activity->hasActualStartTime() === false) {\n return null;\n }\n\n return $this->fetchAndAssociateZohoRelatedActivity($activity);\n }\n\n public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity\n {\n try {\n $meeting = $this->fetchRelatedZohoActivity($activity);\n if (empty($meeting)) {\n $this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [\n 'activity' => $activity->getUuid(),\n ]);\n\n return null;\n }\n\n $decorateActivity = app(DecorateActivity::class);\n $oldDescription = $meeting['Description'] ?? '';\n $updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [\n 'activity' => $activity->getUuid(),\n 'description' => $updatedDescription,\n ]);\n\n $this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);\n\n // Update our activity to reflect the remote data.\n $activity->update([\n 'crm_provider_id' => $meeting['id'],\n 'summary' => $meeting['Description'],\n ]);\n\n return $activity;\n } catch (\\Exception $exception) {\n \\Sentry::captureException($exception);\n\n throw $exception;\n }\n }\n\n public function fetchRelatedZohoActivity(Activity $activity): array\n {\n [$from, $to] = $this->getFromToDates($activity);\n\n $start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00\n $end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00\n if ($start === null || $end === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity missing start or end date',\n [\n 'activity' => $activity->getUuid(),\n 'start' => $start,\n 'end' => $end,\n 'from' => $from,\n 'to' => $to,\n ]\n );\n\n return [];\n }\n\n $whoId = null;\n $whatId = null;\n $criteriaParts = [];\n\n if ($activity->getContact()) {\n $whoId = $activity->getContact()->getCrmProviderId();\n $criteriaParts[] = \"(Who_Id:equals:$whoId)\";\n }\n\n if ($activity->getOpportunity()) {\n $whatId = $activity->getOpportunity()->getCrmProviderId();\n } elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {\n $whatId = $activity->getAccount()->getCrmProviderId();\n } elseif ($activity->getLead()) {\n $whatId = $activity->getLead()->getCrmProviderId();\n }\n\n if ($whatId !== null) {\n $criteriaParts[] = \"(What_Id:equals:$whatId)\";\n }\n\n if ($whoId === null && $whatId === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity cannot find prospect',\n [\n 'activity' => $activity->getUuid(),\n ]\n );\n\n return [];\n }\n\n $criteriaParts[] = \"(Start_DateTime:greater_equal:$start)\";\n $criteriaParts[] = \"(End_DateTime:less_equal:$end)\";\n\n $criteria = implode(' AND ', $criteriaParts);\n\n $params = [\n 'criteria' => $criteria,\n 'sort_by' => 'Modified_Time',\n 'sort_order' => 'desc',\n ];\n\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity searching for related activity',\n [\n 'activity' => $activity->getUuid(),\n 'params' => $params,\n ]\n );\n\n $meetings = $this->client->searchMeetings($params);\n if (! empty($meetings)) {\n return $meetings[0];\n }\n\n return [];\n }\n\n private function getFromToDates(Activity $activity): array\n {\n $calendarEvent = $activity->calendarEvent()->first();\n\n $from = $calendarEvent?->getStartTime();\n $to = $calendarEvent?->getEndTime();\n\n if (! $from || ! $to) {\n $from = $activity->hasScheduledStartTime()\n ? $activity->getScheduledStartTime()\n : $activity->getActualStartTime();\n\n $to = $activity->hasScheduledEndTime()\n ? $activity->getScheduledEndTime()->addMinutes(15)\n : $activity->getActualEndTime();\n }\n\n return [$from, $to];\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Services\\Crm\\ClientInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\FetchRelatedActivityInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\ImportsBusinessProcessesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\LayoutManagementInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\MatchCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityLookupInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteNoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SendSummaryToCrmInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SettingsInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmMetadataInterface;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\SocialAccountNotFoundException;\nuse Jiminny\\Jobs\\Crm\\NoteObject;\nuse Jiminny\\Models\\Account;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Contracts\\ActivityContract;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Opportunity;\nuse Jiminny\\Models\\Stage;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Crm\\BaseService;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationAppProviders;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationConfigFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\FieldMapperInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\LeadFieldMapper;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\GenerateProviderUrlInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\IntegrationAppCrmGeneratorFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\UrlGeneratorInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmFieldsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SystemStateTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\LayoutTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\MatchProspectsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\NotSupportedTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmEntitiesTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmMetadataTrait;\nuse Psr\\Log\\LoggerInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\OpportunityFieldMapper;\nuse Jiminny\\Repositories\\Crm\\ProfileRepository;\nuse Jiminny\\Repositories\\Crm\\OpportunityRepository;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Services\\Crm\\CrmObjects\\CrmObjectsRepository;\n\nclass Service extends BaseService implements\n IntegrationAppInterface,\n SyncCrmEntitiesInterface,\n SyncCrmMetadataInterface,\n ImportsBusinessProcessesInterface,\n RemoteEntityManipulationInterface,\n LayoutManagementInterface,\n SettingsInterface,\n MatchCrmEntitiesInterface,\n RemoteEntityLookupInterface,\n RemoteNoteEntityManipulationInterface,\n SendSummaryToCrmInterface,\n UrlGeneratorInterface,\n FetchRelatedActivityInterface\n{\n use SyncCrmMetadataTrait;\n use SyncCrmEntitiesTrait;\n use SystemStateTrait;\n use LayoutTrait;\n use NotSupportedTrait;\n use MatchProspectsTrait;\n use SyncCrmFieldsTrait;\n\n public const string CALL_TYPE_MISSED = 'Missed';\n public const string CALL_TYPE_INBOUND = 'Inbound';\n public const string CALL_TYPE_OUTBOUND = 'Outbound';\n public const string RELATIONSHIP_OPPORTUNITY = 'Deals';\n public const string RELATIONSHIP_LEAD = 'Leads';\n public const string RELATIONSHIP_ACCOUNT = 'Accounts';\n\n /**\n * @var ClientInterface&DataClient\n */\n protected $client;\n\n protected ?User $invokedUser = null;\n\n protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;\n\n public function __construct(\n DataClient $client,\n LoggerInterface $logger,\n ) {\n parent::__construct();\n $this->client = $client;\n $this->logger = $logger;\n }\n\n public function getDisplayName(): string\n {\n return Providers::getProviderDisplayName(\n Providers::getCrmIntegrationSlug($this->config)\n );\n }\n\n /**\n * @throws \\Exception\n */\n public function setUser(User $user): void\n {\n $this->configureSentryScope($user);\n $this->invokedUser = $user;\n\n $this->team = $user->getTeam();\n $teamOwner = $this->team->getOwner();\n\n $this->setConfiguration($user->getTeam()->getCrmConfiguration());\n $this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));\n $this->setCrmUrlGenerator($this->config);\n\n $this->client->setTeam($this->team);\n $socialAccount = $teamOwner?->getSocialAccount('integration-app');\n if ($socialAccount === null) {\n $this->logger->info('[integration-app] Social account not found', [\n 'teamId' => $this->team->getId(),\n 'teamOwnerId' => $teamOwner?->getId(),\n 'userId' => $user->getId(),\n ]);\n\n throw new SocialAccountNotFoundException('Social account not found!');\n }\n $this->client->setSocialAccount($socialAccount);\n\n // The CRM Service is properly bootstrapped, and supports remote operations\n $this->connect();\n }\n\n public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string\n {\n return $fieldValue;\n }\n\n public function find(string $name, array $scopes): array\n {\n /** @var LocalSearch $localSearch */\n $localSearch = app(LocalSearch::class);\n $localSearch->setConfiguration($this->config);\n $localSearch->setCountryCode($this->invokedUser->getCountryCode());\n\n return $localSearch->search($name);\n\n // if (! empty($localMatch)) {\n // return $localMatch;\n // }\n //\n // /** @var RemoteSearch $remoteSearch */\n // $remoteSearch = app(RemoteSearch::class);\n // $remoteSearch->setClient($this->client);\n // $remoteSearch->setConfiguration($this->config);\n //\n // return $remoteSearch->search($name);\n }\n\n public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array\n {\n $data = [];\n $ownerData = [];\n\n $account = $this->getAccount($crmAccountId, $crmContactId);\n if ($account === null) {\n return [];\n }\n\n $ownerId = $this->getOwnerId($userId);\n\n try {\n $opportunityRepository = app(OpportunityRepository::class);\n $opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(\n $this->config,\n $account->getId()\n );\n\n foreach ($opportunities as $opportunity) {\n /** @var Opportunity $opportunity */\n $record = $this->buildOpportunityData($opportunity);\n\n if ($ownerId && $opportunity->getOwnerId() === $ownerId) {\n $ownerData[] = $record;\n }\n\n $data[] = $record;\n }\n\n if (! empty($ownerData)) {\n return $ownerData;\n }\n\n return $data;\n } catch (\\Exception $e) {\n $this->logger->info('[integration-app] Failed to fetch opportunities', [\n 'contact' => $crmContactId,\n 'account' => $crmAccountId,\n 'owner' => $ownerId,\n 'error' => $e->getMessage(),\n ]);\n\n return $data;\n }\n }\n\n private function getOwnerId(?int $userId = null): ?string\n {\n if (! $userId) {\n return null;\n }\n\n $profileRepository = app(ProfileRepository::class);\n $profile = $profileRepository->findProfileByUserId($this->config, $userId);\n\n return $profile instanceof Profile ? $profile->getCrmProviderId() : null;\n }\n\n private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account\n {\n $crmRepository = app(CrmObjectsRepository::class);\n\n if ($crmAccountId === null) {\n $contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);\n\n return $contact->getAccount();\n }\n\n return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);\n }\n\n private function buildOpportunityData(Opportunity $opportunity): array\n {\n $record = [\n 'crmId' => $opportunity->getCrmProviderId(),\n 'name' => $opportunity->getName(),\n 'won' => $opportunity->isWon(),\n 'closed' => $opportunity->isClosed(),\n ];\n\n if (! empty($opportunity->getFormattedValueAttribute())) {\n $record['value'] = $opportunity->getFormattedValueAttribute();\n }\n\n if (! empty($opportunity->getStage())) {\n $record['stage'] = [\n 'id' => $opportunity->getStage()->getUuid(),\n 'name' => $opportunity->getStage()->getName(),\n ];\n }\n\n return $record;\n }\n\n public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void\n {\n $data = [\n 'data' => $this->normalizeData($objectType, $data),\n ];\n\n $this->client->updateRecordById($objectType, $objectId, $data);\n }\n\n private function normalizeData(string $objectType, array $data): array\n {\n $fieldMapper = $this->getFieldMapper($objectType);\n\n if (! $fieldMapper instanceof FieldMapperInterface) {\n return $data;\n }\n\n return $fieldMapper->mapToCrmFields($data);\n }\n\n private function getFieldMapper(string $objectType): ?FieldMapperInterface\n {\n if ($objectType === self::OBJECT_OPPORTUNITY) {\n return app(OpportunityFieldMapper::class);\n }\n\n if ($objectType === self::OBJECT_LEAD) {\n return app(LeadFieldMapper::class);\n }\n\n return null;\n }\n\n public function getRecord(string $objectType, string $objectId, array $fields = []): array\n {\n return $this->client->getRecordById($objectType, $objectId);\n }\n\n public function getConfiguration(): Configuration\n {\n return $this->config;\n }\n\n public function setConfiguration(Configuration $config): void\n {\n $this->clearExternalMapCache();\n\n $this->config = $config;\n }\n\n private function setEditionConfiguration(string $provider): void\n {\n $this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);\n }\n\n public function setCrmUrlGenerator(Configuration $config): void\n {\n $this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);\n }\n\n public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface\n {\n if ($this->crmUrlGenerator === null) {\n $this->setCrmUrlGenerator($this->config);\n }\n\n return $this->crmUrlGenerator;\n }\n\n public function subscribeEntityEvents(bool $enableTrigger = true): void\n {\n $eventStates = $this->client->updateEntityEventsState($enableTrigger);\n\n $this->logger->info('[integration-app] Change team entity events subscription', [\n 'teamId' => $this->team->getId(),\n 'teamName' => $this->team->getName(),\n 'states' => $eventStates,\n 'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',\n ]);\n }\n\n #[\\Override] public function supportsNotes(): bool\n {\n return $this->editionConfig->supportsNotes();\n }\n\n #[\\Override] public function saveNote(\n string $title,\n string $body,\n string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n if ($noteObject === null) {\n return null;\n }\n\n $notePayload = [\n 'title' => $title,\n 'content' => $body,\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n ];\n\n $result = $this->client->createNote($notePayload);\n\n // debug saving note response\n $this->logger->info('[integration-app] createNote response', [\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n 'result' => $result,\n 'hasId' => isset($result['id']),\n ]);\n\n return $result['id'] ?? null;\n }\n\n /**\n * @throws CrmException\n */\n #[\\Override] public function saveActivity(Activity $activity): Activity\n {\n $this->logger->info('[integration-app] saveActivity', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n ]);\n\n if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {\n $crmActivity = $this->saveMeeting($activity);\n } elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {\n $crmActivity = $this->saveCall($activity);\n } else {\n throw new CrmException('Unsupported activity type');\n }\n\n $crmActivityId = $crmActivity['id'] ?? null;\n\n if ($crmActivityId !== null) {\n $activity->crm_provider_id = $crmActivityId;\n $activity->save();\n\n $this->logger->info('[integration-app] Activity successfully logged to CRM', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n 'crmId' => $crmActivityId,\n ]);\n }\n\n return $activity;\n }\n\n public function saveMeeting(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $meetingPayload = [\n 'Event_Title' => $decorateActivity->generateTitle($activity),\n 'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),\n 'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($meetingPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $meeting = $this->client->getMeeting($crmId);\n\n $oldDescription = $meeting['fields']['Description'] ?? null;\n $payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update meeting', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateMeeting($crmId, $payload);\n }\n\n $payload['Description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log meeting', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createMeeting($payload);\n }\n\n public function saveCall(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $callPayload = [\n 'Call_Type' => $this->getCallType($activity),\n 'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),\n 'Call_Duration' => $activity->getDuration(),\n 'name' => $decorateActivity->generateTitle($activity),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($callPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $call = $this->client->getCall($crmId);\n\n $oldDescription = $call['fields']['Description'] ?? null;\n $payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update call', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateCall($crmId, $payload);\n }\n\n $payload['description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log call', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createCall($payload);\n }\n\n private function getCallType(Activity $activity): string\n {\n if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {\n return self::CALL_TYPE_MISSED;\n }\n\n return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;\n }\n\n private function attachToProspect(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->hasContact()) {\n $payload['contactId'] = $activity->getContact()->getCrmProviderId();\n }\n\n if ($activity->hasOpportunity()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_OPPORTUNITY,\n $activity->getOpportunity()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_ACCOUNT,\n $activity->getAccount()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasLead()) {\n $payload = $this->handleLeadPayload($activity);\n }\n\n return $payload;\n }\n\n private function handleLeadPayload(Activity $activity): array\n {\n $freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());\n $lead = $freshLead ?? $activity->getLead();\n\n if ($lead->getConvertedAt() === null) {\n return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());\n }\n\n $activity->lead_id = null;\n\n if ($lead->hasAccount()) {\n $account = $lead->getAccount();\n $activity->account_id = $account->getId();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());\n } else {\n $payload = [];\n }\n\n if ($lead->hasOpportunity()) {\n $opportunity = $lead->getOpportunity();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());\n $activity->opportunity_id = $opportunity->getId();\n $activity->value = $opportunity->value;\n $activity->stage_id = $opportunity->stage_id;\n } else {\n $activity->stage_id = null;\n }\n\n if ($lead->hasContact()) {\n $contact = $lead->getContact();\n $payload['contactId'] = $contact->getCrmProviderId();\n $activity->contact_id = $contact->getId();\n }\n\n $activity->save();\n event(new ActivityLeadConverted($activity, $lead));\n\n $this->logger->info('[integration-app] Lead converted', [\n 'activityUuid' => $activity->getUuid(),\n 'leadUuid' => $lead->getUuid(),\n ]);\n\n return $payload;\n }\n\n private function buildBasicPayload(string $type, string $id): array\n {\n return [\n 'type' => $type,\n 'id' => $id,\n ];\n }\n private function getActivityOwnerId(Activity $activity): ?string\n {\n $ownerId = null;\n if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {\n $ownerId = $activity->getUser()->getProfile()->getCrmProviderId();\n }\n\n return $ownerId;\n }\n\n #[\\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n $taskPayload = [\n 'subject' => $fields['subject'],\n 'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n if (isset($fields['status'])) {\n $taskPayload['status'] = $fields['status'];\n }\n\n if (isset($fields['priority'])) {\n $taskPayload['priority'] = $fields['priority'];\n }\n\n if (isset($fields['content'])) {\n $taskPayload['content'] = $fields['content'];\n }\n\n $payload = array_merge($taskPayload, $this->attachToProspect($activity));\n\n $this->logger->info('[integration-app] CRM log follow up task', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n $task = $this->client->createTask($payload);\n\n return $task['id'] ?? null;\n }\n\n #[\\Override] public function saveTranscriptionSummaryAsNote(\n ActivityContract $activity,\n string $title,\n string $body,\n ?string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n // We have to find a way to store the transcription summary\n // This might be possible either by Tasks, Events, Engagements & Notes\n // Find what the CRM supports and save the note with the appropriate object(eg Notes)\n\n // For now use only Notes as both ZOHO & Salesforce support them.\n if ($this->supportsNotes() && $objectId !== null) {\n $this->logger->info('[integration-app] saving note', [\n 'activityId' => $activity->getUuid(),\n 'objectId' => $objectId,\n ]);\n\n return $this->saveNote($title, $body, $objectId, $noteObject);\n }\n\n $this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [\n 'activityId' => $activity->getUuid(),\n 'supportsNotes' => $this->supportsNotes(),\n 'objectId' => $objectId,\n ]);\n\n return null;\n }\n\n public function generateProviderUrl(string $providerId, string $objectType): ?string\n {\n return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);\n }\n\n public function updateStage($crmObject, Stage $stage): void\n {\n $objectType = $stage->getType();\n $objectId = $crmObject->getCrmProviderId();\n $params = ['stageName' => $stage->getCrmProviderId()];\n\n $this->logger->info('[integration-app] updateStage', [\n 'objectType' => $objectType,\n 'objectId' => $objectId,\n 'params' => $params,\n ]);\n\n $data = [\n 'data' => $this->normalizeData($objectType, $params),\n ];\n\n\n if ($objectType === Stage::TYPE_LEAD) {\n $this->client->updateLead($objectId, $data);\n } else {\n $this->client->updateDeal($objectId, $data);\n }\n }\n\n /**\n * @throws \\Exception\n */\n public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity\n {\n if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {\n return null;\n }\n\n if (! $activity->isTypeConference()) {\n return null;\n }\n\n // The related activity is already linked.\n if ($activity->hasCrmProviderId()) {\n return $activity;\n }\n\n if ($activity->hasActualStartTime() === false) {\n return null;\n }\n\n return $this->fetchAndAssociateZohoRelatedActivity($activity);\n }\n\n public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity\n {\n try {\n $meeting = $this->fetchRelatedZohoActivity($activity);\n if (empty($meeting)) {\n $this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [\n 'activity' => $activity->getUuid(),\n ]);\n\n return null;\n }\n\n $decorateActivity = app(DecorateActivity::class);\n $oldDescription = $meeting['Description'] ?? '';\n $updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [\n 'activity' => $activity->getUuid(),\n 'description' => $updatedDescription,\n ]);\n\n $this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);\n\n // Update our activity to reflect the remote data.\n $activity->update([\n 'crm_provider_id' => $meeting['id'],\n 'summary' => $meeting['Description'],\n ]);\n\n return $activity;\n } catch (\\Exception $exception) {\n \\Sentry::captureException($exception);\n\n throw $exception;\n }\n }\n\n public function fetchRelatedZohoActivity(Activity $activity): array\n {\n [$from, $to] = $this->getFromToDates($activity);\n\n $start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00\n $end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00\n if ($start === null || $end === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity missing start or end date',\n [\n 'activity' => $activity->getUuid(),\n 'start' => $start,\n 'end' => $end,\n 'from' => $from,\n 'to' => $to,\n ]\n );\n\n return [];\n }\n\n $whoId = null;\n $whatId = null;\n $criteriaParts = [];\n\n if ($activity->getContact()) {\n $whoId = $activity->getContact()->getCrmProviderId();\n $criteriaParts[] = \"(Who_Id:equals:$whoId)\";\n }\n\n if ($activity->getOpportunity()) {\n $whatId = $activity->getOpportunity()->getCrmProviderId();\n } elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {\n $whatId = $activity->getAccount()->getCrmProviderId();\n } elseif ($activity->getLead()) {\n $whatId = $activity->getLead()->getCrmProviderId();\n }\n\n if ($whatId !== null) {\n $criteriaParts[] = \"(What_Id:equals:$whatId)\";\n }\n\n if ($whoId === null && $whatId === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity cannot find prospect',\n [\n 'activity' => $activity->getUuid(),\n ]\n );\n\n return [];\n }\n\n $criteriaParts[] = \"(Start_DateTime:greater_equal:$start)\";\n $criteriaParts[] = \"(End_DateTime:less_equal:$end)\";\n\n $criteria = implode(' AND ', $criteriaParts);\n\n $params = [\n 'criteria' => $criteria,\n 'sort_by' => 'Modified_Time',\n 'sort_order' => 'desc',\n ];\n\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity searching for related activity',\n [\n 'activity' => $activity->getUuid(),\n 'params' => $params,\n ]\n );\n\n $meetings = $this->client->searchMeetings($params);\n if (! empty($meetings)) {\n return $meetings[0];\n }\n\n return [];\n }\n\n private function getFromToDates(Activity $activity): array\n {\n $calendarEvent = $activity->calendarEvent()->first();\n\n $from = $calendarEvent?->getStartTime();\n $to = $calendarEvent?->getEndTime();\n\n if (! $from || ! $to) {\n $from = $activity->hasScheduledStartTime()\n ? $activity->getScheduledStartTime()\n : $activity->getActualStartTime();\n\n $to = $activity->hasScheduledEndTime()\n ? $activity->getScheduledEndTime()->addMinutes(15)\n : $activity->getActualEndTime();\n }\n\n return [$from, $to];\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-699021019121160678
|
1922900139026029532
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp;
use Carbon\Carbon;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Services\Crm\ClientInterface;
use Jiminny\Contracts\Services\Crm\FetchRelatedActivityInterface;
use Jiminny\Contracts\Services\Crm\ImportsBusinessProcessesInterface;
use Jiminny\Contracts\Services\Crm\LayoutManagementInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityLookupInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\RemoteNoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\SendSummaryToCrmInterface;
use Jiminny\Contracts\Services\Crm\SettingsInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmMetadataInterface;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\SocialAccountNotFoundException;
use Jiminny\Jobs\Crm\NoteObject;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contracts\ActivityContract;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Jiminny\Models\User;
use Jiminny\Services\Crm\BaseService;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationAppProviders;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationConfigFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\FieldMapperInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\LeadFieldMapper;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\GenerateProviderUrlInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\IntegrationAppCrmGeneratorFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\UrlGeneratorInterface;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmFieldsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SystemStateTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\LayoutTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\MatchProspectsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\NotSupportedTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmEntitiesTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmMetadataTrait;
use Psr\Log\LoggerInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\OpportunityFieldMapper;
use Jiminny\Repositories\Crm\ProfileRepository;
use Jiminny\Repositories\Crm\OpportunityRepository;
use Jiminny\Models\Crm\Profile;
use Jiminny\Services\Crm\CrmObjects\CrmObjectsRepository;
class Service extends BaseService implements
IntegrationAppInterface,
SyncCrmEntitiesInterface,
SyncCrmMetadataInterface,
ImportsBusinessProcessesInterface,
RemoteEntityManipulationInterface,
LayoutManagementInterface,
SettingsInterface,
MatchCrmEntitiesInterface,
RemoteEntityLookupInterface,
RemoteNoteEntityManipulationInterface,
SendSummaryToCrmInterface,
UrlGeneratorInterface,
FetchRelatedActivityInterface
{
use SyncCrmMetadataTrait;
use SyncCrmEntitiesTrait;
use SystemStateTrait;
use LayoutTrait;
use NotSupportedTrait;
use MatchProspectsTrait;
use SyncCrmFieldsTrait;
public const string CALL_TYPE_MISSED = 'Missed';
public const string CALL_TYPE_INBOUND = 'Inbound';
public const string CALL_TYPE_OUTBOUND = 'Outbound';
public const string RELATIONSHIP_OPPORTUNITY = 'Deals';
public const string RELATIONSHIP_LEAD = 'Leads';
public const string RELATIONSHIP_ACCOUNT = 'Accounts';
/**
* @var ClientInterface&DataClient
*/
protected $client;
protected ?User $invokedUser = null;
protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;
public function __construct(
DataClient $client,
LoggerInterface $logger,
) {
parent::__construct();
$this->client = $client;
$this->logger = $logger;
}
public function getDisplayName(): string
{
return Providers::getProviderDisplayName(
Providers::getCrmIntegrationSlug($this->config)
);
}
/**
* @throws \Exception
*/
public function setUser(User $user): void
{
$this->configureSentryScope($user);
$this->invokedUser = $user;
$this->team = $user->getTeam();
$teamOwner = $this->team->getOwner();
$this->setConfiguration($user->getTeam()->getCrmConfiguration());
$this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));
$this->setCrmUrlGenerator($this->config);
$this->client->setTeam($this->team);
$socialAccount = $teamOwner?->getSocialAccount('integration-app');
if ($socialAccount === null) {
$this->logger->info('[integration-app] Social account not found', [
'teamId' => $this->team->getId(),
'teamOwnerId' => $teamOwner?->getId(),
'userId' => $user->getId(),
]);
throw new SocialAccountNotFoundException('Social account not found!');
}
$this->client->setSocialAccount($socialAccount);
// The CRM Service is properly bootstrapped, and supports remote operations
$this->connect();
}
public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string
{
return $fieldValue;
}
public function find(string $name, array $scopes): array
{
/** @var LocalSearch $localSearch */
$localSearch = app(LocalSearch::class);
$localSearch->setConfiguration($this->config);
$localSearch->setCountryCode($this->invokedUser->getCountryCode());
return $localSearch->search($name);
// if (! empty($localMatch)) {
// return $localMatch;
// }
//
// /** @var RemoteSearch $remoteSearch */
// $remoteSearch = app(RemoteSearch::class);
// $remoteSearch->setClient($this->client);
// $remoteSearch->setConfiguration($this->config);
//
// return $remoteSearch->search($name);
}
public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array
{
$data = [];
$ownerData = [];
$account = $this->getAccount($crmAccountId, $crmContactId);
if ($account === null) {
return [];
}
$ownerId = $this->getOwnerId($userId);
try {
$opportunityRepository = app(OpportunityRepository::class);
$opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(
$this->config,
$account->getId()
);
foreach ($opportunities as $opportunity) {
/** @var Opportunity $opportunity */
$record = $this->buildOpportunityData($opportunity);
if ($ownerId && $opportunity->getOwnerId() === $ownerId) {
$ownerData[] = $record;
}
$data[] = $record;
}
if (! empty($ownerData)) {
return $ownerData;
}
return $data;
} catch (\Exception $e) {
$this->logger->info('[integration-app] Failed to fetch opportunities', [
'contact' => $crmContactId,
'account' => $crmAccountId,
'owner' => $ownerId,
'error' => $e->getMessage(),
]);
return $data;
}
}
private function getOwnerId(?int $userId = null): ?string
{
if (! $userId) {
return null;
}
$profileRepository = app(ProfileRepository::class);
$profile = $profileRepository->findProfileByUserId($this->config, $userId);
return $profile instanceof Profile ? $profile->getCrmProviderId() : null;
}
private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account
{
$crmRepository = app(CrmObjectsRepository::class);
if ($crmAccountId === null) {
$contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);
return $contact->getAccount();
}
return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);
}
private function buildOpportunityData(Opportunity $opportunity): array
{
$record = [
'crmId' => $opportunity->getCrmProviderId(),
'name' => $opportunity->getName(),
'won' => $opportunity->isWon(),
'closed' => $opportunity->isClosed(),
];
if (! empty($opportunity->getFormattedValueAttribute())) {
$record['value'] = $opportunity->getFormattedValueAttribute();
}
if (! empty($opportunity->getStage())) {
$record['stage'] = [
'id' => $opportunity->getStage()->getUuid(),
'name' => $opportunity->getStage()->getName(),
];
}
return $record;
}
public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void
{
$data = [
'data' => $this->normalizeData($objectType, $data),
];
$this->client->updateRecordById($objectType, $objectId, $data);
}
private function normalizeData(string $objectType, array $data): array
{
$fieldMapper = $this->getFieldMapper($objectType);
if (! $fieldMapper instanceof FieldMapperInterface) {
return $data;
}
return $fieldMapper->mapToCrmFields($data);
}
private function getFieldMapper(string $objectType): ?FieldMapperInterface
{
if ($objectType === self::OBJECT_OPPORTUNITY) {
return app(OpportunityFieldMapper::class);
}
if ($objectType === self::OBJECT_LEAD) {
return app(LeadFieldMapper::class);
}
return null;
}
public function getRecord(string $objectType, string $objectId, array $fields = []): array
{
return $this->client->getRecordById($objectType, $objectId);
}
public function getConfiguration(): Configuration
{
return $this->config;
}
public function setConfiguration(Configuration $config): void
{
$this->clearExternalMapCache();
$this->config = $config;
}
private function setEditionConfiguration(string $provider): void
{
$this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);
}
public function setCrmUrlGenerator(Configuration $config): void
{
$this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);
}
public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface
{
if ($this->crmUrlGenerator === null) {
$this->setCrmUrlGenerator($this->config);
}
return $this->crmUrlGenerator;
}
public function subscribeEntityEvents(bool $enableTrigger = true): void
{
$eventStates = $this->client->updateEntityEventsState($enableTrigger);
$this->logger->info('[integration-app] Change team entity events subscription', [
'teamId' => $this->team->getId(),
'teamName' => $this->team->getName(),
'states' => $eventStates,
'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',
]);
}
#[\Override] public function supportsNotes(): bool
{
return $this->editionConfig->supportsNotes();
}
#[\Override] public function saveNote(
string $title,
string $body,
string $objectId,
?NoteObject $noteObject = null,
): ?string {
if ($noteObject === null) {
return null;
}
$notePayload = [
'title' => $title,
'content' => $body,
'objectId' => $objectId,
'objectType' => $noteObject->value,
];
$result = $this->client->createNote($notePayload);
// debug saving note response
$this->logger->info('[integration-app] createNote response', [
'objectId' => $objectId,
'objectType' => $noteObject->value,
'result' => $result,
'hasId' => isset($result['id']),
]);
return $result['id'] ?? null;
}
/**
* @throws CrmException
*/
#[\Override] public function saveActivity(Activity $activity): Activity
{
$this->logger->info('[integration-app] saveActivity', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
]);
if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {
$crmActivity = $this->saveMeeting($activity);
} elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {
$crmActivity = $this->saveCall($activity);
} else {
throw new CrmException('Unsupported activity type');
}
$crmActivityId = $crmActivity['id'] ?? null;
if ($crmActivityId !== null) {
$activity->crm_provider_id = $crmActivityId;
$activity->save();
$this->logger->info('[integration-app] Activity successfully logged to CRM', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
'crmId' => $crmActivityId,
]);
}
return $activity;
}
public function saveMeeting(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$meetingPayload = [
'Event_Title' => $decorateActivity->generateTitle($activity),
'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),
'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($meetingPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$meeting = $this->client->getMeeting($crmId);
$oldDescription = $meeting['fields']['Description'] ?? null;
$payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update meeting', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateMeeting($crmId, $payload);
}
$payload['Description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log meeting', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createMeeting($payload);
}
public function saveCall(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$callPayload = [
'Call_Type' => $this->getCallType($activity),
'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),
'Call_Duration' => $activity->getDuration(),
'name' => $decorateActivity->generateTitle($activity),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($callPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$call = $this->client->getCall($crmId);
$oldDescription = $call['fields']['Description'] ?? null;
$payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update call', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateCall($crmId, $payload);
}
$payload['description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log call', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createCall($payload);
}
private function getCallType(Activity $activity): string
{
if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {
return self::CALL_TYPE_MISSED;
}
return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;
}
private function attachToProspect(Activity $activity): array
{
$payload = [];
if ($activity->hasContact()) {
$payload['contactId'] = $activity->getContact()->getCrmProviderId();
}
if ($activity->hasOpportunity()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_OPPORTUNITY,
$activity->getOpportunity()->getCrmProviderId()
)
);
}
if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_ACCOUNT,
$activity->getAccount()->getCrmProviderId()
)
);
}
if ($activity->hasLead()) {
$payload = $this->handleLeadPayload($activity);
}
return $payload;
}
private function handleLeadPayload(Activity $activity): array
{
$freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());
$lead = $freshLead ?? $activity->getLead();
if ($lead->getConvertedAt() === null) {
return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());
}
$activity->lead_id = null;
if ($lead->hasAccount()) {
$account = $lead->getAccount();
$activity->account_id = $account->getId();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());
} else {
$payload = [];
}
if ($lead->hasOpportunity()) {
$opportunity = $lead->getOpportunity();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());
$activity->opportunity_id = $opportunity->getId();
$activity->value = $opportunity->value;
$activity->stage_id = $opportunity->stage_id;
} else {
$activity->stage_id = null;
}
if ($lead->hasContact()) {
$contact = $lead->getContact();
$payload['contactId'] = $contact->getCrmProviderId();
$activity->contact_id = $contact->getId();
}
$activity->save();
event(new ActivityLeadConverted($activity, $lead));
$this->logger->info('[integration-app] Lead converted', [
'activityUuid' => $activity->getUuid(),
'leadUuid' => $lead->getUuid(),
]);
return $payload;
}
private function buildBasicPayload(string $type, string $id): array
{
return [
'type' => $type,
'id' => $id,
];
}
private function getActivityOwnerId(Activity $activity): ?string
{
$ownerId = null;
if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {
$ownerId = $activity->getUser()->getProfile()->getCrmProviderId();
}
return $ownerId;
}
#[\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
$taskPayload = [
'subject' => $fields['subject'],
'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,
'ownerId' => $this->getActivityOwnerId($activity),
];
if (isset($fields['status'])) {
$taskPayload['status'] = $fields['status'];
}
if (isset($fields['priority'])) {
$taskPayload['priority'] = $fields['priority'];
}
if (isset($fields['content'])) {
$taskPayload['content'] = $fields['content'];
}
$payload = array_merge($taskPayload, $this->attachToProspect($activity));
$this->logger->info('[integration-app] CRM log follow up task', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
$task = $this->client->createTask($payload);
return $task['id'] ?? null;
}
#[\Override] public function saveTranscriptionSummaryAsNote(
ActivityContract $activity,
string $title,
string $body,
?string $objectId,
?NoteObject $noteObject = null,
): ?string {
// We have to find a way to store the transcription summary
// This might be possible either by Tasks, Events, Engagements & Notes
// Find what the CRM supports and save the note with the appropriate object(eg Notes)
// For now use only Notes as both ZOHO & Salesforce support them.
if ($this->supportsNotes() && $objectId !== null) {
$this->logger->info('[integration-app] saving note', [
'activityId' => $activity->getUuid(),
'objectId' => $objectId,
]);
return $this->saveNote($title, $body, $objectId, $noteObject);
}
$this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [
'activityId' => $activity->getUuid(),
'supportsNotes' => $this->supportsNotes(),
'objectId' => $objectId,
]);
return null;
}
public function generateProviderUrl(string $providerId, string $objectType): ?string
{
return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);
}
public function updateStage($crmObject, Stage $stage): void
{
$objectType = $stage->getType();
$objectId = $crmObject->getCrmProviderId();
$params = ['stageName' => $stage->getCrmProviderId()];
$this->logger->info('[integration-app] updateStage', [
'objectType' => $objectType,
'objectId' => $objectId,
'params' => $params,
]);
$data = [
'data' => $this->normalizeData($objectType, $params),
];
if ($objectType === Stage::TYPE_LEAD) {
$this->client->updateLead($objectId, $data);
} else {
$this->client->updateDeal($objectId, $data);
}
}
/**
* @throws \Exception
*/
public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity
{
if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {
return null;
}
if (! $activity->isTypeConference()) {
return null;
}
// The related activity is already linked.
if ($activity->hasCrmProviderId()) {
return $activity;
}
if ($activity->hasActualStartTime() === false) {
return null;
}
return $this->fetchAndAssociateZohoRelatedActivity($activity);
}
public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity
{
try {
$meeting = $this->fetchRelatedZohoActivity($activity);
if (empty($meeting)) {
$this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [
'activity' => $activity->getUuid(),
]);
return null;
}
$decorateActivity = app(DecorateActivity::class);
$oldDescription = $meeting['Description'] ?? '';
$updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [
'activity' => $activity->getUuid(),
'description' => $updatedDescription,
]);
$this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);
// Update our activity to reflect the remote data.
$activity->update([
'crm_provider_id' => $meeting['id'],
'summary' => $meeting['Description'],
]);
return $activity;
} catch (\Exception $exception) {
\Sentry::captureException($exception);
throw $exception;
}
}
public function fetchRelatedZohoActivity(Activity $activity): array
{
[$from, $to] = $this->getFromToDates($activity);
$start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00
$end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00
if ($start === null || $end === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity missing start or end date',
[
'activity' => $activity->getUuid(),
'start' => $start,
'end' => $end,
'from' => $from,
'to' => $to,
]
);
return [];
}
$whoId = null;
$whatId = null;
$criteriaParts = [];
if ($activity->getContact()) {
$whoId = $activity->getContact()->getCrmProviderId();
$criteriaParts[] = "(Who_Id:equals:$whoId)";
}
if ($activity->getOpportunity()) {
$whatId = $activity->getOpportunity()->getCrmProviderId();
} elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {
$whatId = $activity->getAccount()->getCrmProviderId();
} elseif ($activity->getLead()) {
$whatId = $activity->getLead()->getCrmProviderId();
}
if ($whatId !== null) {
$criteriaParts[] = "(What_Id:equals:$whatId)";
}
if ($whoId === null && $whatId === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity cannot find prospect',
[
'activity' => $activity->getUuid(),
]
);
return [];
}
$criteriaParts[] = "(Start_DateTime:greater_equal:$start)";
$criteriaParts[] = "(End_DateTime:less_equal:$end)";
$criteria = implode(' AND ', $criteriaParts);
$params = [
'criteria' => $criteria,
'sort_by' => 'Modified_Time',
'sort_order' => 'desc',
];
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity searching for related activity',
[
'activity' => $activity->getUuid(),
'params' => $params,
]
);
$meetings = $this->client->searchMeetings($params);
if (! empty($meetings)) {
return $meetings[0];
}
return [];
}
private function getFromToDates(Activity $activity): array
{
$calendarEvent = $activity->calendarEvent()->first();
$from = $calendarEvent?->getStartTime();
$to = $calendarEvent?->getEndTime();
if (! $from || ! $to) {
$from = $activity->hasScheduledStartTime()
? $activity->getScheduledStartTime()
: $activity->getActualStartTime();
$to = $activity->hasScheduledEndTime()
? $activity->getScheduledEndTime()->addMinutes(15)
: $activity->getActualEndTime();
}
return [$from, $to];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45484
|
1628
|
18
|
2026-05-14T14:39:36.997123+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769576997_m2.jpg...
|
PhpStorm
|
faVsco.js – IntegrationApp/Service.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp;
use Carbon\Carbon;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Services\Crm\ClientInterface;
use Jiminny\Contracts\Services\Crm\FetchRelatedActivityInterface;
use Jiminny\Contracts\Services\Crm\ImportsBusinessProcessesInterface;
use Jiminny\Contracts\Services\Crm\LayoutManagementInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityLookupInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\RemoteNoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\SendSummaryToCrmInterface;
use Jiminny\Contracts\Services\Crm\SettingsInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmMetadataInterface;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\SocialAccountNotFoundException;
use Jiminny\Jobs\Crm\NoteObject;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contracts\ActivityContract;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Jiminny\Models\User;
use Jiminny\Services\Crm\BaseService;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationAppProviders;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationConfigFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\FieldMapperInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\LeadFieldMapper;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\GenerateProviderUrlInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\IntegrationAppCrmGeneratorFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\UrlGeneratorInterface;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmFieldsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SystemStateTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\LayoutTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\MatchProspectsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\NotSupportedTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmEntitiesTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmMetadataTrait;
use Psr\Log\LoggerInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\OpportunityFieldMapper;
use Jiminny\Repositories\Crm\ProfileRepository;
use Jiminny\Repositories\Crm\OpportunityRepository;
use Jiminny\Models\Crm\Profile;
use Jiminny\Services\Crm\CrmObjects\CrmObjectsRepository;
class Service extends BaseService implements
IntegrationAppInterface,
SyncCrmEntitiesInterface,
SyncCrmMetadataInterface,
ImportsBusinessProcessesInterface,
RemoteEntityManipulationInterface,
LayoutManagementInterface,
SettingsInterface,
MatchCrmEntitiesInterface,
RemoteEntityLookupInterface,
RemoteNoteEntityManipulationInterface,
SendSummaryToCrmInterface,
UrlGeneratorInterface,
FetchRelatedActivityInterface
{
use SyncCrmMetadataTrait;
use SyncCrmEntitiesTrait;
use SystemStateTrait;
use LayoutTrait;
use NotSupportedTrait;
use MatchProspectsTrait;
use SyncCrmFieldsTrait;
public const string CALL_TYPE_MISSED = 'Missed';
public const string CALL_TYPE_INBOUND = 'Inbound';
public const string CALL_TYPE_OUTBOUND = 'Outbound';
public const string RELATIONSHIP_OPPORTUNITY = 'Deals';
public const string RELATIONSHIP_LEAD = 'Leads';
public const string RELATIONSHIP_ACCOUNT = 'Accounts';
/**
* @var ClientInterface&DataClient
*/
protected $client;
protected ?User $invokedUser = null;
protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;
public function __construct(
DataClient $client,
LoggerInterface $logger,
) {
parent::__construct();
$this->client = $client;
$this->logger = $logger;
}
public function getDisplayName(): string
{
return Providers::getProviderDisplayName(
Providers::getCrmIntegrationSlug($this->config)
);
}
/**
* @throws \Exception
*/
public function setUser(User $user): void
{
$this->configureSentryScope($user);
$this->invokedUser = $user;
$this->team = $user->getTeam();
$teamOwner = $this->team->getOwner();
$this->setConfiguration($user->getTeam()->getCrmConfiguration());
$this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));
$this->setCrmUrlGenerator($this->config);
$this->client->setTeam($this->team);
$socialAccount = $teamOwner?->getSocialAccount('integration-app');
if ($socialAccount === null) {
$this->logger->info('[integration-app] Social account not found', [
'teamId' => $this->team->getId(),
'teamOwnerId' => $teamOwner?->getId(),
'userId' => $user->getId(),
]);
throw new SocialAccountNotFoundException('Social account not found!');
}
$this->client->setSocialAccount($socialAccount);
// The CRM Service is properly bootstrapped, and supports remote operations
$this->connect();
}
public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string
{
return $fieldValue;
}
public function find(string $name, array $scopes): array
{
/** @var LocalSearch $localSearch */
$localSearch = app(LocalSearch::class);
$localSearch->setConfiguration($this->config);
$localSearch->setCountryCode($this->invokedUser->getCountryCode());
return $localSearch->search($name);
// if (! empty($localMatch)) {
// return $localMatch;
// }
//
// /** @var RemoteSearch $remoteSearch */
// $remoteSearch = app(RemoteSearch::class);
// $remoteSearch->setClient($this->client);
// $remoteSearch->setConfiguration($this->config);
//
// return $remoteSearch->search($name);
}
public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array
{
$data = [];
$ownerData = [];
$account = $this->getAccount($crmAccountId, $crmContactId);
if ($account === null) {
return [];
}
$ownerId = $this->getOwnerId($userId);
try {
$opportunityRepository = app(OpportunityRepository::class);
$opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(
$this->config,
$account->getId()
);
foreach ($opportunities as $opportunity) {
/** @var Opportunity $opportunity */
$record = $this->buildOpportunityData($opportunity);
if ($ownerId && $opportunity->getOwnerId() === $ownerId) {
$ownerData[] = $record;
}
$data[] = $record;
}
if (! empty($ownerData)) {
return $ownerData;
}
return $data;
} catch (\Exception $e) {
$this->logger->info('[integration-app] Failed to fetch opportunities', [
'contact' => $crmContactId,
'account' => $crmAccountId,
'owner' => $ownerId,
'error' => $e->getMessage(),
]);
return $data;
}
}
private function getOwnerId(?int $userId = null): ?string
{
if (! $userId) {
return null;
}
$profileRepository = app(ProfileRepository::class);
$profile = $profileRepository->findProfileByUserId($this->config, $userId);
return $profile instanceof Profile ? $profile->getCrmProviderId() : null;
}
private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account
{
$crmRepository = app(CrmObjectsRepository::class);
if ($crmAccountId === null) {
$contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);
return $contact->getAccount();
}
return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);
}
private function buildOpportunityData(Opportunity $opportunity): array
{
$record = [
'crmId' => $opportunity->getCrmProviderId(),
'name' => $opportunity->getName(),
'won' => $opportunity->isWon(),
'closed' => $opportunity->isClosed(),
];
if (! empty($opportunity->getFormattedValueAttribute())) {
$record['value'] = $opportunity->getFormattedValueAttribute();
}
if (! empty($opportunity->getStage())) {
$record['stage'] = [
'id' => $opportunity->getStage()->getUuid(),
'name' => $opportunity->getStage()->getName(),
];
}
return $record;
}
public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void
{
$data = [
'data' => $this->normalizeData($objectType, $data),
];
$this->client->updateRecordById($objectType, $objectId, $data);
}
private function normalizeData(string $objectType, array $data): array
{
$fieldMapper = $this->getFieldMapper($objectType);
if (! $fieldMapper instanceof FieldMapperInterface) {
return $data;
}
return $fieldMapper->mapToCrmFields($data);
}
private function getFieldMapper(string $objectType): ?FieldMapperInterface
{
if ($objectType === self::OBJECT_OPPORTUNITY) {
return app(OpportunityFieldMapper::class);
}
if ($objectType === self::OBJECT_LEAD) {
return app(LeadFieldMapper::class);
}
return null;
}
public function getRecord(string $objectType, string $objectId, array $fields = []): array
{
return $this->client->getRecordById($objectType, $objectId);
}
public function getConfiguration(): Configuration
{
return $this->config;
}
public function setConfiguration(Configuration $config): void
{
$this->clearExternalMapCache();
$this->config = $config;
}
private function setEditionConfiguration(string $provider): void
{
$this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);
}
public function setCrmUrlGenerator(Configuration $config): void
{
$this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);
}
public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface
{
if ($this->crmUrlGenerator === null) {
$this->setCrmUrlGenerator($this->config);
}
return $this->crmUrlGenerator;
}
public function subscribeEntityEvents(bool $enableTrigger = true): void
{
$eventStates = $this->client->updateEntityEventsState($enableTrigger);
$this->logger->info('[integration-app] Change team entity events subscription', [
'teamId' => $this->team->getId(),
'teamName' => $this->team->getName(),
'states' => $eventStates,
'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',
]);
}
#[\Override] public function supportsNotes(): bool
{
return $this->editionConfig->supportsNotes();
}
#[\Override] public function saveNote(
string $title,
string $body,
string $objectId,
?NoteObject $noteObject = null,
): ?string {
if ($noteObject === null) {
return null;
}
$notePayload = [
'title' => $title,
'content' => $body,
'objectId' => $objectId,
'objectType' => $noteObject->value,
];
$result = $this->client->createNote($notePayload);
// debug saving note response
$this->logger->info('[integration-app] createNote response', [
'objectId' => $objectId,
'objectType' => $noteObject->value,
'result' => $result,
'hasId' => isset($result['id']),
]);
return $result['id'] ?? null;
}
/**
* @throws CrmException
*/
#[\Override] public function saveActivity(Activity $activity): Activity
{
$this->logger->info('[integration-app] saveActivity', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
]);
if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {
$crmActivity = $this->saveMeeting($activity);
} elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {
$crmActivity = $this->saveCall($activity);
} else {
throw new CrmException('Unsupported activity type');
}
$crmActivityId = $crmActivity['id'] ?? null;
if ($crmActivityId !== null) {
$activity->crm_provider_id = $crmActivityId;
$activity->save();
$this->logger->info('[integration-app] Activity successfully logged to CRM', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
'crmId' => $crmActivityId,
]);
}
return $activity;
}
public function saveMeeting(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$meetingPayload = [
'Event_Title' => $decorateActivity->generateTitle($activity),
'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),
'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($meetingPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$meeting = $this->client->getMeeting($crmId);
$oldDescription = $meeting['fields']['Description'] ?? null;
$payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update meeting', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateMeeting($crmId, $payload);
}
$payload['Description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log meeting', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createMeeting($payload);
}
public function saveCall(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$callPayload = [
'Call_Type' => $this->getCallType($activity),
'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),
'Call_Duration' => $activity->getDuration(),
'name' => $decorateActivity->generateTitle($activity),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($callPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$call = $this->client->getCall($crmId);
$oldDescription = $call['fields']['Description'] ?? null;
$payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update call', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateCall($crmId, $payload);
}
$payload['description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log call', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createCall($payload);
}
private function getCallType(Activity $activity): string
{
if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {
return self::CALL_TYPE_MISSED;
}
return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;
}
private function attachToProspect(Activity $activity): array
{
$payload = [];
if ($activity->hasContact()) {
$payload['contactId'] = $activity->getContact()->getCrmProviderId();
}
if ($activity->hasOpportunity()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_OPPORTUNITY,
$activity->getOpportunity()->getCrmProviderId()
)
);
}
if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_ACCOUNT,
$activity->getAccount()->getCrmProviderId()
)
);
}
if ($activity->hasLead()) {
$payload = $this->handleLeadPayload($activity);
}
return $payload;
}
private function handleLeadPayload(Activity $activity): array
{
$freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());
$lead = $freshLead ?? $activity->getLead();
if ($lead->getConvertedAt() === null) {
return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());
}
$activity->lead_id = null;
if ($lead->hasAccount()) {
$account = $lead->getAccount();
$activity->account_id = $account->getId();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());
} else {
$payload = [];
}
if ($lead->hasOpportunity()) {
$opportunity = $lead->getOpportunity();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());
$activity->opportunity_id = $opportunity->getId();
$activity->value = $opportunity->value;
$activity->stage_id = $opportunity->stage_id;
} else {
$activity->stage_id = null;
}
if ($lead->hasContact()) {
$contact = $lead->getContact();
$payload['contactId'] = $contact->getCrmProviderId();
$activity->contact_id = $contact->getId();
}
$activity->save();
event(new ActivityLeadConverted($activity, $lead));
$this->logger->info('[integration-app] Lead converted', [
'activityUuid' => $activity->getUuid(),
'leadUuid' => $lead->getUuid(),
]);
return $payload;
}
private function buildBasicPayload(string $type, string $id): array
{
return [
'type' => $type,
'id' => $id,
];
}
private function getActivityOwnerId(Activity $activity): ?string
{
$ownerId = null;
if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {
$ownerId = $activity->getUser()->getProfile()->getCrmProviderId();
}
return $ownerId;
}
#[\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
$taskPayload = [
'subject' => $fields['subject'],
'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,
'ownerId' => $this->getActivityOwnerId($activity),
];
if (isset($fields['status'])) {
$taskPayload['status'] = $fields['status'];
}
if (isset($fields['priority'])) {
$taskPayload['priority'] = $fields['priority'];
}
if (isset($fields['content'])) {
$taskPayload['content'] = $fields['content'];
}
$payload = array_merge($taskPayload, $this->attachToProspect($activity));
$this->logger->info('[integration-app] CRM log follow up task', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
$task = $this->client->createTask($payload);
return $task['id'] ?? null;
}
#[\Override] public function saveTranscriptionSummaryAsNote(
ActivityContract $activity,
string $title,
string $body,
?string $objectId,
?NoteObject $noteObject = null,
): ?string {
// We have to find a way to store the transcription summary
// This might be possible either by Tasks, Events, Engagements & Notes
// Find what the CRM supports and save the note with the appropriate object(eg Notes)
// For now use only Notes as both ZOHO & Salesforce support them.
if ($this->supportsNotes() && $objectId !== null) {
$this->logger->info('[integration-app] saving note', [
'activityId' => $activity->getUuid(),
'objectId' => $objectId,
]);
return $this->saveNote($title, $body, $objectId, $noteObject);
}
$this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [
'activityId' => $activity->getUuid(),
'supportsNotes' => $this->supportsNotes(),
'objectId' => $objectId,
]);
return null;
}
public function generateProviderUrl(string $providerId, string $objectType): ?string
{
return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);
}
public function updateStage($crmObject, Stage $stage): void
{
$objectType = $stage->getType();
$objectId = $crmObject->getCrmProviderId();
$params = ['stageName' => $stage->getCrmProviderId()];
$this->logger->info('[integration-app] updateStage', [
'objectType' => $objectType,
'objectId' => $objectId,
'params' => $params,
]);
$data = [
'data' => $this->normalizeData($objectType, $params),
];
if ($objectType === Stage::TYPE_LEAD) {
$this->client->updateLead($objectId, $data);
} else {
$this->client->updateDeal($objectId, $data);
}
}
/**
* @throws \Exception
*/
public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity
{
if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {
return null;
}
if (! $activity->isTypeConference()) {
return null;
}
// The related activity is already linked.
if ($activity->hasCrmProviderId()) {
return $activity;
}
if ($activity->hasActualStartTime() === false) {
return null;
}
return $this->fetchAndAssociateZohoRelatedActivity($activity);
}
public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity
{
try {
$meeting = $this->fetchRelatedZohoActivity($activity);
if (empty($meeting)) {
$this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [
'activity' => $activity->getUuid(),
]);
return null;
}
$decorateActivity = app(DecorateActivity::class);
$oldDescription = $meeting['Description'] ?? '';
$updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [
'activity' => $activity->getUuid(),
'description' => $updatedDescription,
]);
$this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);
// Update our activity to reflect the remote data.
$activity->update([
'crm_provider_id' => $meeting['id'],
'summary' => $meeting['Description'],
]);
return $activity;
} catch (\Exception $exception) {
\Sentry::captureException($exception);
throw $exception;
}
}
public function fetchRelatedZohoActivity(Activity $activity): array
{
[$from, $to] = $this->getFromToDates($activity);
$start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00
$end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00
if ($start === null || $end === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity missing start or end date',
[
'activity' => $activity->getUuid(),
'start' => $start,
'end' => $end,
'from' => $from,
'to' => $to,
]
);
return [];
}
$whoId = null;
$whatId = null;
$criteriaParts = [];
if ($activity->getContact()) {
$whoId = $activity->getContact()->getCrmProviderId();
$criteriaParts[] = "(Who_Id:equals:$whoId)";
}
if ($activity->getOpportunity()) {
$whatId = $activity->getOpportunity()->getCrmProviderId();
} elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {
$whatId = $activity->getAccount()->getCrmProviderId();
} elseif ($activity->getLead()) {
$whatId = $activity->getLead()->getCrmProviderId();
}
if ($whatId !== null) {
$criteriaParts[] = "(What_Id:equals:$whatId)";
}
if ($whoId === null && $whatId === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity cannot find prospect',
[
'activity' => $activity->getUuid(),
]
);
return [];
}
$criteriaParts[] = "(Start_DateTime:greater_equal:$start)";
$criteriaParts[] = "(End_DateTime:less_equal:$end)";
$criteria = implode(' AND ', $criteriaParts);
$params = [
'criteria' => $criteria,
'sort_by' => 'Modified_Time',
'sort_order' => 'desc',
];
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity searching for related activity',
[
'activity' => $activity->getUuid(),
'params' => $params,
]
);
$meetings = $this->client->searchMeetings($params);
if (! empty($meetings)) {
return $meetings[0];
}
return [];
}
private function getFromToDates(Activity $activity): array
{
$calendarEvent = $activity->calendarEvent()->first();
$from = $calendarEvent?->getStartTime();
$to = $calendarEvent?->getEndTime();
if (! $from || ! $to) {
$from = $activity->hasScheduledStartTime()
? $activity->getScheduledStartTime()
: $activity->getActualStartTime();
$to = $activity->hasScheduledEndTime()
? $activity->getScheduledEndTime()->addMinutes(15)
: $activity->getActualEndTime();
}
return [$from, $to];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.2962101,"top":1.0,"width":0.03856383,"height":-0.019952059},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.33477393,"top":1.0,"width":0.122340426,"height":-0.019952059},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.5731383,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.5884308,"top":1.0,"width":0.076130316,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.66456115,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.67586434,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.6871675,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.7150931,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.72639626,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.73769945,"top":1.0,"width":0.011303191,"height":-0.019952059},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"16","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Services\\Crm\\ClientInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\FetchRelatedActivityInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\ImportsBusinessProcessesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\LayoutManagementInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\MatchCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityLookupInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteNoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SendSummaryToCrmInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SettingsInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmMetadataInterface;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\SocialAccountNotFoundException;\nuse Jiminny\\Jobs\\Crm\\NoteObject;\nuse Jiminny\\Models\\Account;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Contracts\\ActivityContract;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Opportunity;\nuse Jiminny\\Models\\Stage;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Crm\\BaseService;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationAppProviders;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationConfigFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\FieldMapperInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\LeadFieldMapper;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\GenerateProviderUrlInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\IntegrationAppCrmGeneratorFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\UrlGeneratorInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmFieldsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SystemStateTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\LayoutTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\MatchProspectsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\NotSupportedTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmEntitiesTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmMetadataTrait;\nuse Psr\\Log\\LoggerInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\OpportunityFieldMapper;\nuse Jiminny\\Repositories\\Crm\\ProfileRepository;\nuse Jiminny\\Repositories\\Crm\\OpportunityRepository;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Services\\Crm\\CrmObjects\\CrmObjectsRepository;\n\nclass Service extends BaseService implements\n IntegrationAppInterface,\n SyncCrmEntitiesInterface,\n SyncCrmMetadataInterface,\n ImportsBusinessProcessesInterface,\n RemoteEntityManipulationInterface,\n LayoutManagementInterface,\n SettingsInterface,\n MatchCrmEntitiesInterface,\n RemoteEntityLookupInterface,\n RemoteNoteEntityManipulationInterface,\n SendSummaryToCrmInterface,\n UrlGeneratorInterface,\n FetchRelatedActivityInterface\n{\n use SyncCrmMetadataTrait;\n use SyncCrmEntitiesTrait;\n use SystemStateTrait;\n use LayoutTrait;\n use NotSupportedTrait;\n use MatchProspectsTrait;\n use SyncCrmFieldsTrait;\n\n public const string CALL_TYPE_MISSED = 'Missed';\n public const string CALL_TYPE_INBOUND = 'Inbound';\n public const string CALL_TYPE_OUTBOUND = 'Outbound';\n public const string RELATIONSHIP_OPPORTUNITY = 'Deals';\n public const string RELATIONSHIP_LEAD = 'Leads';\n public const string RELATIONSHIP_ACCOUNT = 'Accounts';\n\n /**\n * @var ClientInterface&DataClient\n */\n protected $client;\n\n protected ?User $invokedUser = null;\n\n protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;\n\n public function __construct(\n DataClient $client,\n LoggerInterface $logger,\n ) {\n parent::__construct();\n $this->client = $client;\n $this->logger = $logger;\n }\n\n public function getDisplayName(): string\n {\n return Providers::getProviderDisplayName(\n Providers::getCrmIntegrationSlug($this->config)\n );\n }\n\n /**\n * @throws \\Exception\n */\n public function setUser(User $user): void\n {\n $this->configureSentryScope($user);\n $this->invokedUser = $user;\n\n $this->team = $user->getTeam();\n $teamOwner = $this->team->getOwner();\n\n $this->setConfiguration($user->getTeam()->getCrmConfiguration());\n $this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));\n $this->setCrmUrlGenerator($this->config);\n\n $this->client->setTeam($this->team);\n $socialAccount = $teamOwner?->getSocialAccount('integration-app');\n if ($socialAccount === null) {\n $this->logger->info('[integration-app] Social account not found', [\n 'teamId' => $this->team->getId(),\n 'teamOwnerId' => $teamOwner?->getId(),\n 'userId' => $user->getId(),\n ]);\n\n throw new SocialAccountNotFoundException('Social account not found!');\n }\n $this->client->setSocialAccount($socialAccount);\n\n // The CRM Service is properly bootstrapped, and supports remote operations\n $this->connect();\n }\n\n public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string\n {\n return $fieldValue;\n }\n\n public function find(string $name, array $scopes): array\n {\n /** @var LocalSearch $localSearch */\n $localSearch = app(LocalSearch::class);\n $localSearch->setConfiguration($this->config);\n $localSearch->setCountryCode($this->invokedUser->getCountryCode());\n\n return $localSearch->search($name);\n\n // if (! empty($localMatch)) {\n // return $localMatch;\n // }\n //\n // /** @var RemoteSearch $remoteSearch */\n // $remoteSearch = app(RemoteSearch::class);\n // $remoteSearch->setClient($this->client);\n // $remoteSearch->setConfiguration($this->config);\n //\n // return $remoteSearch->search($name);\n }\n\n public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array\n {\n $data = [];\n $ownerData = [];\n\n $account = $this->getAccount($crmAccountId, $crmContactId);\n if ($account === null) {\n return [];\n }\n\n $ownerId = $this->getOwnerId($userId);\n\n try {\n $opportunityRepository = app(OpportunityRepository::class);\n $opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(\n $this->config,\n $account->getId()\n );\n\n foreach ($opportunities as $opportunity) {\n /** @var Opportunity $opportunity */\n $record = $this->buildOpportunityData($opportunity);\n\n if ($ownerId && $opportunity->getOwnerId() === $ownerId) {\n $ownerData[] = $record;\n }\n\n $data[] = $record;\n }\n\n if (! empty($ownerData)) {\n return $ownerData;\n }\n\n return $data;\n } catch (\\Exception $e) {\n $this->logger->info('[integration-app] Failed to fetch opportunities', [\n 'contact' => $crmContactId,\n 'account' => $crmAccountId,\n 'owner' => $ownerId,\n 'error' => $e->getMessage(),\n ]);\n\n return $data;\n }\n }\n\n private function getOwnerId(?int $userId = null): ?string\n {\n if (! $userId) {\n return null;\n }\n\n $profileRepository = app(ProfileRepository::class);\n $profile = $profileRepository->findProfileByUserId($this->config, $userId);\n\n return $profile instanceof Profile ? $profile->getCrmProviderId() : null;\n }\n\n private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account\n {\n $crmRepository = app(CrmObjectsRepository::class);\n\n if ($crmAccountId === null) {\n $contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);\n\n return $contact->getAccount();\n }\n\n return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);\n }\n\n private function buildOpportunityData(Opportunity $opportunity): array\n {\n $record = [\n 'crmId' => $opportunity->getCrmProviderId(),\n 'name' => $opportunity->getName(),\n 'won' => $opportunity->isWon(),\n 'closed' => $opportunity->isClosed(),\n ];\n\n if (! empty($opportunity->getFormattedValueAttribute())) {\n $record['value'] = $opportunity->getFormattedValueAttribute();\n }\n\n if (! empty($opportunity->getStage())) {\n $record['stage'] = [\n 'id' => $opportunity->getStage()->getUuid(),\n 'name' => $opportunity->getStage()->getName(),\n ];\n }\n\n return $record;\n }\n\n public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void\n {\n $data = [\n 'data' => $this->normalizeData($objectType, $data),\n ];\n\n $this->client->updateRecordById($objectType, $objectId, $data);\n }\n\n private function normalizeData(string $objectType, array $data): array\n {\n $fieldMapper = $this->getFieldMapper($objectType);\n\n if (! $fieldMapper instanceof FieldMapperInterface) {\n return $data;\n }\n\n return $fieldMapper->mapToCrmFields($data);\n }\n\n private function getFieldMapper(string $objectType): ?FieldMapperInterface\n {\n if ($objectType === self::OBJECT_OPPORTUNITY) {\n return app(OpportunityFieldMapper::class);\n }\n\n if ($objectType === self::OBJECT_LEAD) {\n return app(LeadFieldMapper::class);\n }\n\n return null;\n }\n\n public function getRecord(string $objectType, string $objectId, array $fields = []): array\n {\n return $this->client->getRecordById($objectType, $objectId);\n }\n\n public function getConfiguration(): Configuration\n {\n return $this->config;\n }\n\n public function setConfiguration(Configuration $config): void\n {\n $this->clearExternalMapCache();\n\n $this->config = $config;\n }\n\n private function setEditionConfiguration(string $provider): void\n {\n $this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);\n }\n\n public function setCrmUrlGenerator(Configuration $config): void\n {\n $this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);\n }\n\n public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface\n {\n if ($this->crmUrlGenerator === null) {\n $this->setCrmUrlGenerator($this->config);\n }\n\n return $this->crmUrlGenerator;\n }\n\n public function subscribeEntityEvents(bool $enableTrigger = true): void\n {\n $eventStates = $this->client->updateEntityEventsState($enableTrigger);\n\n $this->logger->info('[integration-app] Change team entity events subscription', [\n 'teamId' => $this->team->getId(),\n 'teamName' => $this->team->getName(),\n 'states' => $eventStates,\n 'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',\n ]);\n }\n\n #[\\Override] public function supportsNotes(): bool\n {\n return $this->editionConfig->supportsNotes();\n }\n\n #[\\Override] public function saveNote(\n string $title,\n string $body,\n string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n if ($noteObject === null) {\n return null;\n }\n\n $notePayload = [\n 'title' => $title,\n 'content' => $body,\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n ];\n\n $result = $this->client->createNote($notePayload);\n\n // debug saving note response\n $this->logger->info('[integration-app] createNote response', [\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n 'result' => $result,\n 'hasId' => isset($result['id']),\n ]);\n\n return $result['id'] ?? null;\n }\n\n /**\n * @throws CrmException\n */\n #[\\Override] public function saveActivity(Activity $activity): Activity\n {\n $this->logger->info('[integration-app] saveActivity', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n ]);\n\n if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {\n $crmActivity = $this->saveMeeting($activity);\n } elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {\n $crmActivity = $this->saveCall($activity);\n } else {\n throw new CrmException('Unsupported activity type');\n }\n\n $crmActivityId = $crmActivity['id'] ?? null;\n\n if ($crmActivityId !== null) {\n $activity->crm_provider_id = $crmActivityId;\n $activity->save();\n\n $this->logger->info('[integration-app] Activity successfully logged to CRM', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n 'crmId' => $crmActivityId,\n ]);\n }\n\n return $activity;\n }\n\n public function saveMeeting(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $meetingPayload = [\n 'Event_Title' => $decorateActivity->generateTitle($activity),\n 'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),\n 'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($meetingPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $meeting = $this->client->getMeeting($crmId);\n\n $oldDescription = $meeting['fields']['Description'] ?? null;\n $payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update meeting', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateMeeting($crmId, $payload);\n }\n\n $payload['Description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log meeting', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createMeeting($payload);\n }\n\n public function saveCall(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $callPayload = [\n 'Call_Type' => $this->getCallType($activity),\n 'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),\n 'Call_Duration' => $activity->getDuration(),\n 'name' => $decorateActivity->generateTitle($activity),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($callPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $call = $this->client->getCall($crmId);\n\n $oldDescription = $call['fields']['Description'] ?? null;\n $payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update call', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateCall($crmId, $payload);\n }\n\n $payload['description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log call', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createCall($payload);\n }\n\n private function getCallType(Activity $activity): string\n {\n if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {\n return self::CALL_TYPE_MISSED;\n }\n\n return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;\n }\n\n private function attachToProspect(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->hasContact()) {\n $payload['contactId'] = $activity->getContact()->getCrmProviderId();\n }\n\n if ($activity->hasOpportunity()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_OPPORTUNITY,\n $activity->getOpportunity()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_ACCOUNT,\n $activity->getAccount()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasLead()) {\n $payload = $this->handleLeadPayload($activity);\n }\n\n return $payload;\n }\n\n private function handleLeadPayload(Activity $activity): array\n {\n $freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());\n $lead = $freshLead ?? $activity->getLead();\n\n if ($lead->getConvertedAt() === null) {\n return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());\n }\n\n $activity->lead_id = null;\n\n if ($lead->hasAccount()) {\n $account = $lead->getAccount();\n $activity->account_id = $account->getId();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());\n } else {\n $payload = [];\n }\n\n if ($lead->hasOpportunity()) {\n $opportunity = $lead->getOpportunity();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());\n $activity->opportunity_id = $opportunity->getId();\n $activity->value = $opportunity->value;\n $activity->stage_id = $opportunity->stage_id;\n } else {\n $activity->stage_id = null;\n }\n\n if ($lead->hasContact()) {\n $contact = $lead->getContact();\n $payload['contactId'] = $contact->getCrmProviderId();\n $activity->contact_id = $contact->getId();\n }\n\n $activity->save();\n event(new ActivityLeadConverted($activity, $lead));\n\n $this->logger->info('[integration-app] Lead converted', [\n 'activityUuid' => $activity->getUuid(),\n 'leadUuid' => $lead->getUuid(),\n ]);\n\n return $payload;\n }\n\n private function buildBasicPayload(string $type, string $id): array\n {\n return [\n 'type' => $type,\n 'id' => $id,\n ];\n }\n private function getActivityOwnerId(Activity $activity): ?string\n {\n $ownerId = null;\n if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {\n $ownerId = $activity->getUser()->getProfile()->getCrmProviderId();\n }\n\n return $ownerId;\n }\n\n #[\\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n $taskPayload = [\n 'subject' => $fields['subject'],\n 'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n if (isset($fields['status'])) {\n $taskPayload['status'] = $fields['status'];\n }\n\n if (isset($fields['priority'])) {\n $taskPayload['priority'] = $fields['priority'];\n }\n\n if (isset($fields['content'])) {\n $taskPayload['content'] = $fields['content'];\n }\n\n $payload = array_merge($taskPayload, $this->attachToProspect($activity));\n\n $this->logger->info('[integration-app] CRM log follow up task', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n $task = $this->client->createTask($payload);\n\n return $task['id'] ?? null;\n }\n\n #[\\Override] public function saveTranscriptionSummaryAsNote(\n ActivityContract $activity,\n string $title,\n string $body,\n ?string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n // We have to find a way to store the transcription summary\n // This might be possible either by Tasks, Events, Engagements & Notes\n // Find what the CRM supports and save the note with the appropriate object(eg Notes)\n\n // For now use only Notes as both ZOHO & Salesforce support them.\n if ($this->supportsNotes() && $objectId !== null) {\n $this->logger->info('[integration-app] saving note', [\n 'activityId' => $activity->getUuid(),\n 'objectId' => $objectId,\n ]);\n\n return $this->saveNote($title, $body, $objectId, $noteObject);\n }\n\n $this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [\n 'activityId' => $activity->getUuid(),\n 'supportsNotes' => $this->supportsNotes(),\n 'objectId' => $objectId,\n ]);\n\n return null;\n }\n\n public function generateProviderUrl(string $providerId, string $objectType): ?string\n {\n return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);\n }\n\n public function updateStage($crmObject, Stage $stage): void\n {\n $objectType = $stage->getType();\n $objectId = $crmObject->getCrmProviderId();\n $params = ['stageName' => $stage->getCrmProviderId()];\n\n $this->logger->info('[integration-app] updateStage', [\n 'objectType' => $objectType,\n 'objectId' => $objectId,\n 'params' => $params,\n ]);\n\n $data = [\n 'data' => $this->normalizeData($objectType, $params),\n ];\n\n\n if ($objectType === Stage::TYPE_LEAD) {\n $this->client->updateLead($objectId, $data);\n } else {\n $this->client->updateDeal($objectId, $data);\n }\n }\n\n /**\n * @throws \\Exception\n */\n public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity\n {\n if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {\n return null;\n }\n\n if (! $activity->isTypeConference()) {\n return null;\n }\n\n // The related activity is already linked.\n if ($activity->hasCrmProviderId()) {\n return $activity;\n }\n\n if ($activity->hasActualStartTime() === false) {\n return null;\n }\n\n return $this->fetchAndAssociateZohoRelatedActivity($activity);\n }\n\n public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity\n {\n try {\n $meeting = $this->fetchRelatedZohoActivity($activity);\n if (empty($meeting)) {\n $this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [\n 'activity' => $activity->getUuid(),\n ]);\n\n return null;\n }\n\n $decorateActivity = app(DecorateActivity::class);\n $oldDescription = $meeting['Description'] ?? '';\n $updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [\n 'activity' => $activity->getUuid(),\n 'description' => $updatedDescription,\n ]);\n\n $this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);\n\n // Update our activity to reflect the remote data.\n $activity->update([\n 'crm_provider_id' => $meeting['id'],\n 'summary' => $meeting['Description'],\n ]);\n\n return $activity;\n } catch (\\Exception $exception) {\n \\Sentry::captureException($exception);\n\n throw $exception;\n }\n }\n\n public function fetchRelatedZohoActivity(Activity $activity): array\n {\n [$from, $to] = $this->getFromToDates($activity);\n\n $start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00\n $end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00\n if ($start === null || $end === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity missing start or end date',\n [\n 'activity' => $activity->getUuid(),\n 'start' => $start,\n 'end' => $end,\n 'from' => $from,\n 'to' => $to,\n ]\n );\n\n return [];\n }\n\n $whoId = null;\n $whatId = null;\n $criteriaParts = [];\n\n if ($activity->getContact()) {\n $whoId = $activity->getContact()->getCrmProviderId();\n $criteriaParts[] = \"(Who_Id:equals:$whoId)\";\n }\n\n if ($activity->getOpportunity()) {\n $whatId = $activity->getOpportunity()->getCrmProviderId();\n } elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {\n $whatId = $activity->getAccount()->getCrmProviderId();\n } elseif ($activity->getLead()) {\n $whatId = $activity->getLead()->getCrmProviderId();\n }\n\n if ($whatId !== null) {\n $criteriaParts[] = \"(What_Id:equals:$whatId)\";\n }\n\n if ($whoId === null && $whatId === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity cannot find prospect',\n [\n 'activity' => $activity->getUuid(),\n ]\n );\n\n return [];\n }\n\n $criteriaParts[] = \"(Start_DateTime:greater_equal:$start)\";\n $criteriaParts[] = \"(End_DateTime:less_equal:$end)\";\n\n $criteria = implode(' AND ', $criteriaParts);\n\n $params = [\n 'criteria' => $criteria,\n 'sort_by' => 'Modified_Time',\n 'sort_order' => 'desc',\n ];\n\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity searching for related activity',\n [\n 'activity' => $activity->getUuid(),\n 'params' => $params,\n ]\n );\n\n $meetings = $this->client->searchMeetings($params);\n if (! empty($meetings)) {\n return $meetings[0];\n }\n\n return [];\n }\n\n private function getFromToDates(Activity $activity): array\n {\n $calendarEvent = $activity->calendarEvent()->first();\n\n $from = $calendarEvent?->getStartTime();\n $to = $calendarEvent?->getEndTime();\n\n if (! $from || ! $to) {\n $from = $activity->hasScheduledStartTime()\n ? $activity->getScheduledStartTime()\n : $activity->getActualStartTime();\n\n $to = $activity->hasScheduledEndTime()\n ? $activity->getScheduledEndTime()->addMinutes(15)\n : $activity->getActualEndTime();\n }\n\n return [$from, $to];\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Services\\Crm\\IntegrationApp;\n\nuse Carbon\\Carbon;\nuse Jiminny\\Contracts\\Crm\\Providers;\nuse Jiminny\\Contracts\\Services\\Crm\\ClientInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\FetchRelatedActivityInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\ImportsBusinessProcessesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\LayoutManagementInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\MatchCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\Provider\\IntegrationAppInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityLookupInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\RemoteNoteEntityManipulationInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SendSummaryToCrmInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SettingsInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmEntitiesInterface;\nuse Jiminny\\Contracts\\Services\\Crm\\SyncCrmMetadataInterface;\nuse Jiminny\\Events\\Activities\\Crm\\ActivityLeadConverted;\nuse Jiminny\\Exceptions\\CrmException;\nuse Jiminny\\Exceptions\\SocialAccountNotFoundException;\nuse Jiminny\\Jobs\\Crm\\NoteObject;\nuse Jiminny\\Models\\Account;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Contracts\\ActivityContract;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Opportunity;\nuse Jiminny\\Models\\Stage;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Crm\\BaseService;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationAppProviders;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\Config\\IntegrationConfigFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\FieldMapperInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\LeadFieldMapper;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\GenerateProviderUrlInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\IntegrationAppCrmGeneratorFactory;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Utils\\UrlGeneratorInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmFieldsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SystemStateTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\LayoutTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\MatchProspectsTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\NotSupportedTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmEntitiesTrait;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\ServiceTraits\\SyncCrmMetadataTrait;\nuse Psr\\Log\\LoggerInterface;\nuse Jiminny\\Services\\Crm\\IntegrationApp\\DTO\\Mappers\\OpportunityFieldMapper;\nuse Jiminny\\Repositories\\Crm\\ProfileRepository;\nuse Jiminny\\Repositories\\Crm\\OpportunityRepository;\nuse Jiminny\\Models\\Crm\\Profile;\nuse Jiminny\\Services\\Crm\\CrmObjects\\CrmObjectsRepository;\n\nclass Service extends BaseService implements\n IntegrationAppInterface,\n SyncCrmEntitiesInterface,\n SyncCrmMetadataInterface,\n ImportsBusinessProcessesInterface,\n RemoteEntityManipulationInterface,\n LayoutManagementInterface,\n SettingsInterface,\n MatchCrmEntitiesInterface,\n RemoteEntityLookupInterface,\n RemoteNoteEntityManipulationInterface,\n SendSummaryToCrmInterface,\n UrlGeneratorInterface,\n FetchRelatedActivityInterface\n{\n use SyncCrmMetadataTrait;\n use SyncCrmEntitiesTrait;\n use SystemStateTrait;\n use LayoutTrait;\n use NotSupportedTrait;\n use MatchProspectsTrait;\n use SyncCrmFieldsTrait;\n\n public const string CALL_TYPE_MISSED = 'Missed';\n public const string CALL_TYPE_INBOUND = 'Inbound';\n public const string CALL_TYPE_OUTBOUND = 'Outbound';\n public const string RELATIONSHIP_OPPORTUNITY = 'Deals';\n public const string RELATIONSHIP_LEAD = 'Leads';\n public const string RELATIONSHIP_ACCOUNT = 'Accounts';\n\n /**\n * @var ClientInterface&DataClient\n */\n protected $client;\n\n protected ?User $invokedUser = null;\n\n protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;\n\n public function __construct(\n DataClient $client,\n LoggerInterface $logger,\n ) {\n parent::__construct();\n $this->client = $client;\n $this->logger = $logger;\n }\n\n public function getDisplayName(): string\n {\n return Providers::getProviderDisplayName(\n Providers::getCrmIntegrationSlug($this->config)\n );\n }\n\n /**\n * @throws \\Exception\n */\n public function setUser(User $user): void\n {\n $this->configureSentryScope($user);\n $this->invokedUser = $user;\n\n $this->team = $user->getTeam();\n $teamOwner = $this->team->getOwner();\n\n $this->setConfiguration($user->getTeam()->getCrmConfiguration());\n $this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));\n $this->setCrmUrlGenerator($this->config);\n\n $this->client->setTeam($this->team);\n $socialAccount = $teamOwner?->getSocialAccount('integration-app');\n if ($socialAccount === null) {\n $this->logger->info('[integration-app] Social account not found', [\n 'teamId' => $this->team->getId(),\n 'teamOwnerId' => $teamOwner?->getId(),\n 'userId' => $user->getId(),\n ]);\n\n throw new SocialAccountNotFoundException('Social account not found!');\n }\n $this->client->setSocialAccount($socialAccount);\n\n // The CRM Service is properly bootstrapped, and supports remote operations\n $this->connect();\n }\n\n public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string\n {\n return $fieldValue;\n }\n\n public function find(string $name, array $scopes): array\n {\n /** @var LocalSearch $localSearch */\n $localSearch = app(LocalSearch::class);\n $localSearch->setConfiguration($this->config);\n $localSearch->setCountryCode($this->invokedUser->getCountryCode());\n\n return $localSearch->search($name);\n\n // if (! empty($localMatch)) {\n // return $localMatch;\n // }\n //\n // /** @var RemoteSearch $remoteSearch */\n // $remoteSearch = app(RemoteSearch::class);\n // $remoteSearch->setClient($this->client);\n // $remoteSearch->setConfiguration($this->config);\n //\n // return $remoteSearch->search($name);\n }\n\n public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array\n {\n $data = [];\n $ownerData = [];\n\n $account = $this->getAccount($crmAccountId, $crmContactId);\n if ($account === null) {\n return [];\n }\n\n $ownerId = $this->getOwnerId($userId);\n\n try {\n $opportunityRepository = app(OpportunityRepository::class);\n $opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(\n $this->config,\n $account->getId()\n );\n\n foreach ($opportunities as $opportunity) {\n /** @var Opportunity $opportunity */\n $record = $this->buildOpportunityData($opportunity);\n\n if ($ownerId && $opportunity->getOwnerId() === $ownerId) {\n $ownerData[] = $record;\n }\n\n $data[] = $record;\n }\n\n if (! empty($ownerData)) {\n return $ownerData;\n }\n\n return $data;\n } catch (\\Exception $e) {\n $this->logger->info('[integration-app] Failed to fetch opportunities', [\n 'contact' => $crmContactId,\n 'account' => $crmAccountId,\n 'owner' => $ownerId,\n 'error' => $e->getMessage(),\n ]);\n\n return $data;\n }\n }\n\n private function getOwnerId(?int $userId = null): ?string\n {\n if (! $userId) {\n return null;\n }\n\n $profileRepository = app(ProfileRepository::class);\n $profile = $profileRepository->findProfileByUserId($this->config, $userId);\n\n return $profile instanceof Profile ? $profile->getCrmProviderId() : null;\n }\n\n private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account\n {\n $crmRepository = app(CrmObjectsRepository::class);\n\n if ($crmAccountId === null) {\n $contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);\n\n return $contact->getAccount();\n }\n\n return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);\n }\n\n private function buildOpportunityData(Opportunity $opportunity): array\n {\n $record = [\n 'crmId' => $opportunity->getCrmProviderId(),\n 'name' => $opportunity->getName(),\n 'won' => $opportunity->isWon(),\n 'closed' => $opportunity->isClosed(),\n ];\n\n if (! empty($opportunity->getFormattedValueAttribute())) {\n $record['value'] = $opportunity->getFormattedValueAttribute();\n }\n\n if (! empty($opportunity->getStage())) {\n $record['stage'] = [\n 'id' => $opportunity->getStage()->getUuid(),\n 'name' => $opportunity->getStage()->getName(),\n ];\n }\n\n return $record;\n }\n\n public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void\n {\n $data = [\n 'data' => $this->normalizeData($objectType, $data),\n ];\n\n $this->client->updateRecordById($objectType, $objectId, $data);\n }\n\n private function normalizeData(string $objectType, array $data): array\n {\n $fieldMapper = $this->getFieldMapper($objectType);\n\n if (! $fieldMapper instanceof FieldMapperInterface) {\n return $data;\n }\n\n return $fieldMapper->mapToCrmFields($data);\n }\n\n private function getFieldMapper(string $objectType): ?FieldMapperInterface\n {\n if ($objectType === self::OBJECT_OPPORTUNITY) {\n return app(OpportunityFieldMapper::class);\n }\n\n if ($objectType === self::OBJECT_LEAD) {\n return app(LeadFieldMapper::class);\n }\n\n return null;\n }\n\n public function getRecord(string $objectType, string $objectId, array $fields = []): array\n {\n return $this->client->getRecordById($objectType, $objectId);\n }\n\n public function getConfiguration(): Configuration\n {\n return $this->config;\n }\n\n public function setConfiguration(Configuration $config): void\n {\n $this->clearExternalMapCache();\n\n $this->config = $config;\n }\n\n private function setEditionConfiguration(string $provider): void\n {\n $this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);\n }\n\n public function setCrmUrlGenerator(Configuration $config): void\n {\n $this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);\n }\n\n public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface\n {\n if ($this->crmUrlGenerator === null) {\n $this->setCrmUrlGenerator($this->config);\n }\n\n return $this->crmUrlGenerator;\n }\n\n public function subscribeEntityEvents(bool $enableTrigger = true): void\n {\n $eventStates = $this->client->updateEntityEventsState($enableTrigger);\n\n $this->logger->info('[integration-app] Change team entity events subscription', [\n 'teamId' => $this->team->getId(),\n 'teamName' => $this->team->getName(),\n 'states' => $eventStates,\n 'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',\n ]);\n }\n\n #[\\Override] public function supportsNotes(): bool\n {\n return $this->editionConfig->supportsNotes();\n }\n\n #[\\Override] public function saveNote(\n string $title,\n string $body,\n string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n if ($noteObject === null) {\n return null;\n }\n\n $notePayload = [\n 'title' => $title,\n 'content' => $body,\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n ];\n\n $result = $this->client->createNote($notePayload);\n\n // debug saving note response\n $this->logger->info('[integration-app] createNote response', [\n 'objectId' => $objectId,\n 'objectType' => $noteObject->value,\n 'result' => $result,\n 'hasId' => isset($result['id']),\n ]);\n\n return $result['id'] ?? null;\n }\n\n /**\n * @throws CrmException\n */\n #[\\Override] public function saveActivity(Activity $activity): Activity\n {\n $this->logger->info('[integration-app] saveActivity', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n ]);\n\n if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {\n $crmActivity = $this->saveMeeting($activity);\n } elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {\n $crmActivity = $this->saveCall($activity);\n } else {\n throw new CrmException('Unsupported activity type');\n }\n\n $crmActivityId = $crmActivity['id'] ?? null;\n\n if ($crmActivityId !== null) {\n $activity->crm_provider_id = $crmActivityId;\n $activity->save();\n\n $this->logger->info('[integration-app] Activity successfully logged to CRM', [\n 'activity' => $activity->getUuid(),\n 'type' => $activity->getType(),\n 'crmId' => $crmActivityId,\n ]);\n }\n\n return $activity;\n }\n\n public function saveMeeting(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $meetingPayload = [\n 'Event_Title' => $decorateActivity->generateTitle($activity),\n 'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),\n 'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($meetingPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $meeting = $this->client->getMeeting($crmId);\n\n $oldDescription = $meeting['fields']['Description'] ?? null;\n $payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update meeting', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateMeeting($crmId, $payload);\n }\n\n $payload['Description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log meeting', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createMeeting($payload);\n }\n\n public function saveCall(Activity $activity): array\n {\n $decorateActivity = app(DecorateActivity::class);\n\n $callPayload = [\n 'Call_Type' => $this->getCallType($activity),\n 'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),\n 'Call_Duration' => $activity->getDuration(),\n 'name' => $decorateActivity->generateTitle($activity),\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n $payload = array_merge($callPayload, $this->attachToProspect($activity));\n\n if ($activity->hasCrmProviderId()) {\n $crmId = $activity->getCrmProviderId();\n $call = $this->client->getCall($crmId);\n\n $oldDescription = $call['fields']['Description'] ?? null;\n $payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] CRM update call', [\n 'activity' => $activity->getUuid(),\n 'crm_id' => $crmId,\n 'payload' => $payload,\n ]);\n\n return $this->client->updateCall($crmId, $payload);\n }\n\n $payload['description'] = $decorateActivity->generateDescription($activity);\n\n $this->logger->info('[integration-app] CRM log call', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n return $this->client->createCall($payload);\n }\n\n private function getCallType(Activity $activity): string\n {\n if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {\n return self::CALL_TYPE_MISSED;\n }\n\n return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;\n }\n\n private function attachToProspect(Activity $activity): array\n {\n $payload = [];\n\n if ($activity->hasContact()) {\n $payload['contactId'] = $activity->getContact()->getCrmProviderId();\n }\n\n if ($activity->hasOpportunity()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_OPPORTUNITY,\n $activity->getOpportunity()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {\n return array_merge(\n $payload,\n $this->buildBasicPayload(\n self::RELATIONSHIP_ACCOUNT,\n $activity->getAccount()->getCrmProviderId()\n )\n );\n }\n\n if ($activity->hasLead()) {\n $payload = $this->handleLeadPayload($activity);\n }\n\n return $payload;\n }\n\n private function handleLeadPayload(Activity $activity): array\n {\n $freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());\n $lead = $freshLead ?? $activity->getLead();\n\n if ($lead->getConvertedAt() === null) {\n return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());\n }\n\n $activity->lead_id = null;\n\n if ($lead->hasAccount()) {\n $account = $lead->getAccount();\n $activity->account_id = $account->getId();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());\n } else {\n $payload = [];\n }\n\n if ($lead->hasOpportunity()) {\n $opportunity = $lead->getOpportunity();\n $payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());\n $activity->opportunity_id = $opportunity->getId();\n $activity->value = $opportunity->value;\n $activity->stage_id = $opportunity->stage_id;\n } else {\n $activity->stage_id = null;\n }\n\n if ($lead->hasContact()) {\n $contact = $lead->getContact();\n $payload['contactId'] = $contact->getCrmProviderId();\n $activity->contact_id = $contact->getId();\n }\n\n $activity->save();\n event(new ActivityLeadConverted($activity, $lead));\n\n $this->logger->info('[integration-app] Lead converted', [\n 'activityUuid' => $activity->getUuid(),\n 'leadUuid' => $lead->getUuid(),\n ]);\n\n return $payload;\n }\n\n private function buildBasicPayload(string $type, string $id): array\n {\n return [\n 'type' => $type,\n 'id' => $id,\n ];\n }\n private function getActivityOwnerId(Activity $activity): ?string\n {\n $ownerId = null;\n if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {\n $ownerId = $activity->getUser()->getProfile()->getCrmProviderId();\n }\n\n return $ownerId;\n }\n\n #[\\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string\n {\n $taskPayload = [\n 'subject' => $fields['subject'],\n 'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,\n 'ownerId' => $this->getActivityOwnerId($activity),\n ];\n\n if (isset($fields['status'])) {\n $taskPayload['status'] = $fields['status'];\n }\n\n if (isset($fields['priority'])) {\n $taskPayload['priority'] = $fields['priority'];\n }\n\n if (isset($fields['content'])) {\n $taskPayload['content'] = $fields['content'];\n }\n\n $payload = array_merge($taskPayload, $this->attachToProspect($activity));\n\n $this->logger->info('[integration-app] CRM log follow up task', [\n 'activity' => $activity->getUuid(),\n 'payload' => $payload,\n ]);\n\n $task = $this->client->createTask($payload);\n\n return $task['id'] ?? null;\n }\n\n #[\\Override] public function saveTranscriptionSummaryAsNote(\n ActivityContract $activity,\n string $title,\n string $body,\n ?string $objectId,\n ?NoteObject $noteObject = null,\n ): ?string {\n // We have to find a way to store the transcription summary\n // This might be possible either by Tasks, Events, Engagements & Notes\n // Find what the CRM supports and save the note with the appropriate object(eg Notes)\n\n // For now use only Notes as both ZOHO & Salesforce support them.\n if ($this->supportsNotes() && $objectId !== null) {\n $this->logger->info('[integration-app] saving note', [\n 'activityId' => $activity->getUuid(),\n 'objectId' => $objectId,\n ]);\n\n return $this->saveNote($title, $body, $objectId, $noteObject);\n }\n\n $this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [\n 'activityId' => $activity->getUuid(),\n 'supportsNotes' => $this->supportsNotes(),\n 'objectId' => $objectId,\n ]);\n\n return null;\n }\n\n public function generateProviderUrl(string $providerId, string $objectType): ?string\n {\n return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);\n }\n\n public function updateStage($crmObject, Stage $stage): void\n {\n $objectType = $stage->getType();\n $objectId = $crmObject->getCrmProviderId();\n $params = ['stageName' => $stage->getCrmProviderId()];\n\n $this->logger->info('[integration-app] updateStage', [\n 'objectType' => $objectType,\n 'objectId' => $objectId,\n 'params' => $params,\n ]);\n\n $data = [\n 'data' => $this->normalizeData($objectType, $params),\n ];\n\n\n if ($objectType === Stage::TYPE_LEAD) {\n $this->client->updateLead($objectId, $data);\n } else {\n $this->client->updateDeal($objectId, $data);\n }\n }\n\n /**\n * @throws \\Exception\n */\n public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity\n {\n if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {\n return null;\n }\n\n if (! $activity->isTypeConference()) {\n return null;\n }\n\n // The related activity is already linked.\n if ($activity->hasCrmProviderId()) {\n return $activity;\n }\n\n if ($activity->hasActualStartTime() === false) {\n return null;\n }\n\n return $this->fetchAndAssociateZohoRelatedActivity($activity);\n }\n\n public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity\n {\n try {\n $meeting = $this->fetchRelatedZohoActivity($activity);\n if (empty($meeting)) {\n $this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [\n 'activity' => $activity->getUuid(),\n ]);\n\n return null;\n }\n\n $decorateActivity = app(DecorateActivity::class);\n $oldDescription = $meeting['Description'] ?? '';\n $updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);\n\n $this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [\n 'activity' => $activity->getUuid(),\n 'description' => $updatedDescription,\n ]);\n\n $this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);\n\n // Update our activity to reflect the remote data.\n $activity->update([\n 'crm_provider_id' => $meeting['id'],\n 'summary' => $meeting['Description'],\n ]);\n\n return $activity;\n } catch (\\Exception $exception) {\n \\Sentry::captureException($exception);\n\n throw $exception;\n }\n }\n\n public function fetchRelatedZohoActivity(Activity $activity): array\n {\n [$from, $to] = $this->getFromToDates($activity);\n\n $start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00\n $end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00\n if ($start === null || $end === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity missing start or end date',\n [\n 'activity' => $activity->getUuid(),\n 'start' => $start,\n 'end' => $end,\n 'from' => $from,\n 'to' => $to,\n ]\n );\n\n return [];\n }\n\n $whoId = null;\n $whatId = null;\n $criteriaParts = [];\n\n if ($activity->getContact()) {\n $whoId = $activity->getContact()->getCrmProviderId();\n $criteriaParts[] = \"(Who_Id:equals:$whoId)\";\n }\n\n if ($activity->getOpportunity()) {\n $whatId = $activity->getOpportunity()->getCrmProviderId();\n } elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {\n $whatId = $activity->getAccount()->getCrmProviderId();\n } elseif ($activity->getLead()) {\n $whatId = $activity->getLead()->getCrmProviderId();\n }\n\n if ($whatId !== null) {\n $criteriaParts[] = \"(What_Id:equals:$whatId)\";\n }\n\n if ($whoId === null && $whatId === null) {\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity cannot find prospect',\n [\n 'activity' => $activity->getUuid(),\n ]\n );\n\n return [];\n }\n\n $criteriaParts[] = \"(Start_DateTime:greater_equal:$start)\";\n $criteriaParts[] = \"(End_DateTime:less_equal:$end)\";\n\n $criteria = implode(' AND ', $criteriaParts);\n\n $params = [\n 'criteria' => $criteria,\n 'sort_by' => 'Modified_Time',\n 'sort_order' => 'desc',\n ];\n\n $this->logger->info(\n '[integration-app] fetchRelatedZohoActivity searching for related activity',\n [\n 'activity' => $activity->getUuid(),\n 'params' => $params,\n ]\n );\n\n $meetings = $this->client->searchMeetings($params);\n if (! empty($meetings)) {\n return $meetings[0];\n }\n\n return [];\n }\n\n private function getFromToDates(Activity $activity): array\n {\n $calendarEvent = $activity->calendarEvent()->first();\n\n $from = $calendarEvent?->getStartTime();\n $to = $calendarEvent?->getEndTime();\n\n if (! $from || ! $to) {\n $from = $activity->hasScheduledStartTime()\n ? $activity->getScheduledStartTime()\n : $activity->getActualStartTime();\n\n $to = $activity->hasScheduledEndTime()\n ? $activity->getScheduledEndTime()->addMinutes(15)\n : $activity->getActualEndTime();\n }\n\n return [$from, $to];\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-83063113985008946
|
6524477667414250461
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm\IntegrationApp;
use Carbon\Carbon;
use Jiminny\Contracts\Crm\Providers;
use Jiminny\Contracts\Services\Crm\ClientInterface;
use Jiminny\Contracts\Services\Crm\FetchRelatedActivityInterface;
use Jiminny\Contracts\Services\Crm\ImportsBusinessProcessesInterface;
use Jiminny\Contracts\Services\Crm\LayoutManagementInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\Provider\IntegrationAppInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityLookupInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\RemoteNoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\SendSummaryToCrmInterface;
use Jiminny\Contracts\Services\Crm\SettingsInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmMetadataInterface;
use Jiminny\Events\Activities\Crm\ActivityLeadConverted;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\SocialAccountNotFoundException;
use Jiminny\Jobs\Crm\NoteObject;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contracts\ActivityContract;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Jiminny\Models\User;
use Jiminny\Services\Crm\BaseService;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationAppProviders;
use Jiminny\Services\Crm\IntegrationApp\Config\IntegrationConfigFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\FieldMapperInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\LeadFieldMapper;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\GenerateProviderUrlInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\IntegrationAppCrmGeneratorFactory;
use Jiminny\Services\Crm\IntegrationApp\DTO\Utils\UrlGeneratorInterface;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmFieldsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SystemStateTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\LayoutTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\MatchProspectsTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\NotSupportedTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmEntitiesTrait;
use Jiminny\Services\Crm\IntegrationApp\ServiceTraits\SyncCrmMetadataTrait;
use Psr\Log\LoggerInterface;
use Jiminny\Services\Crm\IntegrationApp\DTO\Mappers\OpportunityFieldMapper;
use Jiminny\Repositories\Crm\ProfileRepository;
use Jiminny\Repositories\Crm\OpportunityRepository;
use Jiminny\Models\Crm\Profile;
use Jiminny\Services\Crm\CrmObjects\CrmObjectsRepository;
class Service extends BaseService implements
IntegrationAppInterface,
SyncCrmEntitiesInterface,
SyncCrmMetadataInterface,
ImportsBusinessProcessesInterface,
RemoteEntityManipulationInterface,
LayoutManagementInterface,
SettingsInterface,
MatchCrmEntitiesInterface,
RemoteEntityLookupInterface,
RemoteNoteEntityManipulationInterface,
SendSummaryToCrmInterface,
UrlGeneratorInterface,
FetchRelatedActivityInterface
{
use SyncCrmMetadataTrait;
use SyncCrmEntitiesTrait;
use SystemStateTrait;
use LayoutTrait;
use NotSupportedTrait;
use MatchProspectsTrait;
use SyncCrmFieldsTrait;
public const string CALL_TYPE_MISSED = 'Missed';
public const string CALL_TYPE_INBOUND = 'Inbound';
public const string CALL_TYPE_OUTBOUND = 'Outbound';
public const string RELATIONSHIP_OPPORTUNITY = 'Deals';
public const string RELATIONSHIP_LEAD = 'Leads';
public const string RELATIONSHIP_ACCOUNT = 'Accounts';
/**
* @var ClientInterface&DataClient
*/
protected $client;
protected ?User $invokedUser = null;
protected ?GenerateProviderUrlInterface $crmUrlGenerator = null;
public function __construct(
DataClient $client,
LoggerInterface $logger,
) {
parent::__construct();
$this->client = $client;
$this->logger = $logger;
}
public function getDisplayName(): string
{
return Providers::getProviderDisplayName(
Providers::getCrmIntegrationSlug($this->config)
);
}
/**
* @throws \Exception
*/
public function setUser(User $user): void
{
$this->configureSentryScope($user);
$this->invokedUser = $user;
$this->team = $user->getTeam();
$teamOwner = $this->team->getOwner();
$this->setConfiguration($user->getTeam()->getCrmConfiguration());
$this->setEditionConfiguration(Providers::getCrmIntegrationSlug($this->config));
$this->setCrmUrlGenerator($this->config);
$this->client->setTeam($this->team);
$socialAccount = $teamOwner?->getSocialAccount('integration-app');
if ($socialAccount === null) {
$this->logger->info('[integration-app] Social account not found', [
'teamId' => $this->team->getId(),
'teamOwnerId' => $teamOwner?->getId(),
'userId' => $user->getId(),
]);
throw new SocialAccountNotFoundException('Social account not found!');
}
$this->client->setSocialAccount($socialAccount);
// The CRM Service is properly bootstrapped, and supports remote operations
$this->connect();
}
public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string
{
return $fieldValue;
}
public function find(string $name, array $scopes): array
{
/** @var LocalSearch $localSearch */
$localSearch = app(LocalSearch::class);
$localSearch->setConfiguration($this->config);
$localSearch->setCountryCode($this->invokedUser->getCountryCode());
return $localSearch->search($name);
// if (! empty($localMatch)) {
// return $localMatch;
// }
//
// /** @var RemoteSearch $remoteSearch */
// $remoteSearch = app(RemoteSearch::class);
// $remoteSearch->setClient($this->client);
// $remoteSearch->setConfiguration($this->config);
//
// return $remoteSearch->search($name);
}
public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array
{
$data = [];
$ownerData = [];
$account = $this->getAccount($crmAccountId, $crmContactId);
if ($account === null) {
return [];
}
$ownerId = $this->getOwnerId($userId);
try {
$opportunityRepository = app(OpportunityRepository::class);
$opportunities = $opportunityRepository->findAllByConfigurationAndAccountId(
$this->config,
$account->getId()
);
foreach ($opportunities as $opportunity) {
/** @var Opportunity $opportunity */
$record = $this->buildOpportunityData($opportunity);
if ($ownerId && $opportunity->getOwnerId() === $ownerId) {
$ownerData[] = $record;
}
$data[] = $record;
}
if (! empty($ownerData)) {
return $ownerData;
}
return $data;
} catch (\Exception $e) {
$this->logger->info('[integration-app] Failed to fetch opportunities', [
'contact' => $crmContactId,
'account' => $crmAccountId,
'owner' => $ownerId,
'error' => $e->getMessage(),
]);
return $data;
}
}
private function getOwnerId(?int $userId = null): ?string
{
if (! $userId) {
return null;
}
$profileRepository = app(ProfileRepository::class);
$profile = $profileRepository->findProfileByUserId($this->config, $userId);
return $profile instanceof Profile ? $profile->getCrmProviderId() : null;
}
private function getAccount(?string $crmAccountId = null, ?string $crmContactId = null): ?Account
{
$crmRepository = app(CrmObjectsRepository::class);
if ($crmAccountId === null) {
$contact = $crmRepository->findContactByCrmProviderId($this->config, $crmContactId);
return $contact->getAccount();
}
return $crmRepository->findAccountByCrmProviderId($this->config, $crmAccountId);
}
private function buildOpportunityData(Opportunity $opportunity): array
{
$record = [
'crmId' => $opportunity->getCrmProviderId(),
'name' => $opportunity->getName(),
'won' => $opportunity->isWon(),
'closed' => $opportunity->isClosed(),
];
if (! empty($opportunity->getFormattedValueAttribute())) {
$record['value'] = $opportunity->getFormattedValueAttribute();
}
if (! empty($opportunity->getStage())) {
$record['stage'] = [
'id' => $opportunity->getStage()->getUuid(),
'name' => $opportunity->getStage()->getName(),
];
}
return $record;
}
public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void
{
$data = [
'data' => $this->normalizeData($objectType, $data),
];
$this->client->updateRecordById($objectType, $objectId, $data);
}
private function normalizeData(string $objectType, array $data): array
{
$fieldMapper = $this->getFieldMapper($objectType);
if (! $fieldMapper instanceof FieldMapperInterface) {
return $data;
}
return $fieldMapper->mapToCrmFields($data);
}
private function getFieldMapper(string $objectType): ?FieldMapperInterface
{
if ($objectType === self::OBJECT_OPPORTUNITY) {
return app(OpportunityFieldMapper::class);
}
if ($objectType === self::OBJECT_LEAD) {
return app(LeadFieldMapper::class);
}
return null;
}
public function getRecord(string $objectType, string $objectId, array $fields = []): array
{
return $this->client->getRecordById($objectType, $objectId);
}
public function getConfiguration(): Configuration
{
return $this->config;
}
public function setConfiguration(Configuration $config): void
{
$this->clearExternalMapCache();
$this->config = $config;
}
private function setEditionConfiguration(string $provider): void
{
$this->editionConfig = app(IntegrationConfigFactory::class)->create($provider);
}
public function setCrmUrlGenerator(Configuration $config): void
{
$this->crmUrlGenerator = app(IntegrationAppCrmGeneratorFactory::class)->create($config);
}
public function getCrmUrlGenerator(): ?GenerateProviderUrlInterface
{
if ($this->crmUrlGenerator === null) {
$this->setCrmUrlGenerator($this->config);
}
return $this->crmUrlGenerator;
}
public function subscribeEntityEvents(bool $enableTrigger = true): void
{
$eventStates = $this->client->updateEntityEventsState($enableTrigger);
$this->logger->info('[integration-app] Change team entity events subscription', [
'teamId' => $this->team->getId(),
'teamName' => $this->team->getName(),
'states' => $eventStates,
'action' => $enableTrigger ? 'subscribe' : 'unsubscribe',
]);
}
#[\Override] public function supportsNotes(): bool
{
return $this->editionConfig->supportsNotes();
}
#[\Override] public function saveNote(
string $title,
string $body,
string $objectId,
?NoteObject $noteObject = null,
): ?string {
if ($noteObject === null) {
return null;
}
$notePayload = [
'title' => $title,
'content' => $body,
'objectId' => $objectId,
'objectType' => $noteObject->value,
];
$result = $this->client->createNote($notePayload);
// debug saving note response
$this->logger->info('[integration-app] createNote response', [
'objectId' => $objectId,
'objectType' => $noteObject->value,
'result' => $result,
'hasId' => isset($result['id']),
]);
return $result['id'] ?? null;
}
/**
* @throws CrmException
*/
#[\Override] public function saveActivity(Activity $activity): Activity
{
$this->logger->info('[integration-app] saveActivity', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
]);
if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {
$crmActivity = $this->saveMeeting($activity);
} elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUND])) {
$crmActivity = $this->saveCall($activity);
} else {
throw new CrmException('Unsupported activity type');
}
$crmActivityId = $crmActivity['id'] ?? null;
if ($crmActivityId !== null) {
$activity->crm_provider_id = $crmActivityId;
$activity->save();
$this->logger->info('[integration-app] Activity successfully logged to CRM', [
'activity' => $activity->getUuid(),
'type' => $activity->getType(),
'crmId' => $crmActivityId,
]);
}
return $activity;
}
public function saveMeeting(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$meetingPayload = [
'Event_Title' => $decorateActivity->generateTitle($activity),
'Start_DateTime' => $activity->getActualStartTime()->toIso8601String(),
'End_DateTime' => $activity->getActualEndTime()->toIso8601String(),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($meetingPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$meeting = $this->client->getMeeting($crmId);
$oldDescription = $meeting['fields']['Description'] ?? null;
$payload['Description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update meeting', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateMeeting($crmId, $payload);
}
$payload['Description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log meeting', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createMeeting($payload);
}
public function saveCall(Activity $activity): array
{
$decorateActivity = app(DecorateActivity::class);
$callPayload = [
'Call_Type' => $this->getCallType($activity),
'Call_Start_Time' => $activity->getActualStartTime()->toIso8601String(),
'Call_Duration' => $activity->getDuration(),
'name' => $decorateActivity->generateTitle($activity),
'ownerId' => $this->getActivityOwnerId($activity),
];
$payload = array_merge($callPayload, $this->attachToProspect($activity));
if ($activity->hasCrmProviderId()) {
$crmId = $activity->getCrmProviderId();
$call = $this->client->getCall($crmId);
$oldDescription = $call['fields']['Description'] ?? null;
$payload['description'] = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] CRM update call', [
'activity' => $activity->getUuid(),
'crm_id' => $crmId,
'payload' => $payload,
]);
return $this->client->updateCall($crmId, $payload);
}
$payload['description'] = $decorateActivity->generateDescription($activity);
$this->logger->info('[integration-app] CRM log call', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
return $this->client->createCall($payload);
}
private function getCallType(Activity $activity): string
{
if ($activity->getStatus() === Activity::STATUS_NO_ANSWER) {
return self::CALL_TYPE_MISSED;
}
return $activity->getType() === Activity::TYPE_SOFTPHONE_INBOUND ? self::CALL_TYPE_INBOUND : self::CALL_TYPE_OUTBOUND;
}
private function attachToProspect(Activity $activity): array
{
$payload = [];
if ($activity->hasContact()) {
$payload['contactId'] = $activity->getContact()->getCrmProviderId();
}
if ($activity->hasOpportunity()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_OPPORTUNITY,
$activity->getOpportunity()->getCrmProviderId()
)
);
}
if ($activity->hasAccount() && ! $activity->getAccount()->getIsInternal()) {
return array_merge(
$payload,
$this->buildBasicPayload(
self::RELATIONSHIP_ACCOUNT,
$activity->getAccount()->getCrmProviderId()
)
);
}
if ($activity->hasLead()) {
$payload = $this->handleLeadPayload($activity);
}
return $payload;
}
private function handleLeadPayload(Activity $activity): array
{
$freshLead = $this->syncLead($activity->getLead()->getCrmProviderId());
$lead = $freshLead ?? $activity->getLead();
if ($lead->getConvertedAt() === null) {
return $this->buildBasicPayload(self::RELATIONSHIP_LEAD, $lead->getCrmProviderId());
}
$activity->lead_id = null;
if ($lead->hasAccount()) {
$account = $lead->getAccount();
$activity->account_id = $account->getId();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_ACCOUNT, $account->getCrmProviderId());
} else {
$payload = [];
}
if ($lead->hasOpportunity()) {
$opportunity = $lead->getOpportunity();
$payload = $this->buildBasicPayload(self::RELATIONSHIP_OPPORTUNITY, $opportunity->getCrmProviderId());
$activity->opportunity_id = $opportunity->getId();
$activity->value = $opportunity->value;
$activity->stage_id = $opportunity->stage_id;
} else {
$activity->stage_id = null;
}
if ($lead->hasContact()) {
$contact = $lead->getContact();
$payload['contactId'] = $contact->getCrmProviderId();
$activity->contact_id = $contact->getId();
}
$activity->save();
event(new ActivityLeadConverted($activity, $lead));
$this->logger->info('[integration-app] Lead converted', [
'activityUuid' => $activity->getUuid(),
'leadUuid' => $lead->getUuid(),
]);
return $payload;
}
private function buildBasicPayload(string $type, string $id): array
{
return [
'type' => $type,
'id' => $id,
];
}
private function getActivityOwnerId(Activity $activity): ?string
{
$ownerId = null;
if ($activity->hasUser() && $activity->getUser()->getProfile() !== null) {
$ownerId = $activity->getUser()->getProfile()->getCrmProviderId();
}
return $ownerId;
}
#[\Override] public function saveFollowupActivity(Activity $activity, array $fields): ?string
{
$taskPayload = [
'subject' => $fields['subject'],
'dueTime' => isset($fields['dueDate']) ? Carbon::parse($fields['dueDate'])->format('Y-m-d') : null,
'ownerId' => $this->getActivityOwnerId($activity),
];
if (isset($fields['status'])) {
$taskPayload['status'] = $fields['status'];
}
if (isset($fields['priority'])) {
$taskPayload['priority'] = $fields['priority'];
}
if (isset($fields['content'])) {
$taskPayload['content'] = $fields['content'];
}
$payload = array_merge($taskPayload, $this->attachToProspect($activity));
$this->logger->info('[integration-app] CRM log follow up task', [
'activity' => $activity->getUuid(),
'payload' => $payload,
]);
$task = $this->client->createTask($payload);
return $task['id'] ?? null;
}
#[\Override] public function saveTranscriptionSummaryAsNote(
ActivityContract $activity,
string $title,
string $body,
?string $objectId,
?NoteObject $noteObject = null,
): ?string {
// We have to find a way to store the transcription summary
// This might be possible either by Tasks, Events, Engagements & Notes
// Find what the CRM supports and save the note with the appropriate object(eg Notes)
// For now use only Notes as both ZOHO & Salesforce support them.
if ($this->supportsNotes() && $objectId !== null) {
$this->logger->info('[integration-app] saving note', [
'activityId' => $activity->getUuid(),
'objectId' => $objectId,
]);
return $this->saveNote($title, $body, $objectId, $noteObject);
}
$this->logger->info('[integration-app] skip saveTranscriptionSummaryAsNote', [
'activityId' => $activity->getUuid(),
'supportsNotes' => $this->supportsNotes(),
'objectId' => $objectId,
]);
return null;
}
public function generateProviderUrl(string $providerId, string $objectType): ?string
{
return $this->getCrmUrlGenerator()?->generateProviderUrl($providerId, $objectType);
}
public function updateStage($crmObject, Stage $stage): void
{
$objectType = $stage->getType();
$objectId = $crmObject->getCrmProviderId();
$params = ['stageName' => $stage->getCrmProviderId()];
$this->logger->info('[integration-app] updateStage', [
'objectType' => $objectType,
'objectId' => $objectId,
'params' => $params,
]);
$data = [
'data' => $this->normalizeData($objectType, $params),
];
if ($objectType === Stage::TYPE_LEAD) {
$this->client->updateLead($objectId, $data);
} else {
$this->client->updateDeal($objectId, $data);
}
}
/**
* @throws \Exception
*/
public function fetchAndAssociateRelatedActivity(Activity $activity): ?Activity
{
if ($activity->getCrm()?->getEdition() !== IntegrationAppProviders::ZOHO_CRM) {
return null;
}
if (! $activity->isTypeConference()) {
return null;
}
// The related activity is already linked.
if ($activity->hasCrmProviderId()) {
return $activity;
}
if ($activity->hasActualStartTime() === false) {
return null;
}
return $this->fetchAndAssociateZohoRelatedActivity($activity);
}
public function fetchAndAssociateZohoRelatedActivity(Activity $activity): ?Activity
{
try {
$meeting = $this->fetchRelatedZohoActivity($activity);
if (empty($meeting)) {
$this->logger->info('[integration-app] fetchRelatedZohoActivity No related activity found', [
'activity' => $activity->getUuid(),
]);
return null;
}
$decorateActivity = app(DecorateActivity::class);
$oldDescription = $meeting['Description'] ?? '';
$updatedDescription = $decorateActivity->generateUpdatedDescription($oldDescription, $activity);
$this->logger->info('[integration-app] fetchAndAssociateZohoRelatedActivity updating related activity', [
'activity' => $activity->getUuid(),
'description' => $updatedDescription,
]);
$this->client->updateMeeting($meeting['id'], ['Description' => $updatedDescription]);
// Update our activity to reflect the remote data.
$activity->update([
'crm_provider_id' => $meeting['id'],
'summary' => $meeting['Description'],
]);
return $activity;
} catch (\Exception $exception) {
\Sentry::captureException($exception);
throw $exception;
}
}
public function fetchRelatedZohoActivity(Activity $activity): array
{
[$from, $to] = $this->getFromToDates($activity);
$start = $from?->toIso8601String(); // e.g., 2025-07-01T00:00:00+00:00
$end = $to?->toIso8601String(); // e.g., 2025-07-14T23:59:59+00:00
if ($start === null || $end === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity missing start or end date',
[
'activity' => $activity->getUuid(),
'start' => $start,
'end' => $end,
'from' => $from,
'to' => $to,
]
);
return [];
}
$whoId = null;
$whatId = null;
$criteriaParts = [];
if ($activity->getContact()) {
$whoId = $activity->getContact()->getCrmProviderId();
$criteriaParts[] = "(Who_Id:equals:$whoId)";
}
if ($activity->getOpportunity()) {
$whatId = $activity->getOpportunity()->getCrmProviderId();
} elseif ($activity->getAccount() && $activity->getAccount()->getIsInternal() === false) {
$whatId = $activity->getAccount()->getCrmProviderId();
} elseif ($activity->getLead()) {
$whatId = $activity->getLead()->getCrmProviderId();
}
if ($whatId !== null) {
$criteriaParts[] = "(What_Id:equals:$whatId)";
}
if ($whoId === null && $whatId === null) {
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity cannot find prospect',
[
'activity' => $activity->getUuid(),
]
);
return [];
}
$criteriaParts[] = "(Start_DateTime:greater_equal:$start)";
$criteriaParts[] = "(End_DateTime:less_equal:$end)";
$criteria = implode(' AND ', $criteriaParts);
$params = [
'criteria' => $criteria,
'sort_by' => 'Modified_Time',
'sort_order' => 'desc',
];
$this->logger->info(
'[integration-app] fetchRelatedZohoActivity searching for related activity',
[
'activity' => $activity->getUuid(),
'params' => $params,
]
);
$meetings = $this->client->searchMeetings($params);
if (! empty($meetings)) {
return $meetings[0];
}
return [];
}
private function getFromToDates(Activity $activity): array
{
$calendarEvent = $activity->calendarEvent()->first();
$from = $calendarEvent?->getStartTime();
$to = $calendarEvent?->getEndTime();
if (! $from || ! $to) {
$from = $activity->hasScheduledStartTime()
? $activity->getScheduledStartTime()
: $activity->getActualStartTime();
$to = $activity->hasScheduledEndTime()
? $activity->getScheduledEndTime()->addMinutes(15)
: $activity->getActualEndTime();
}
return [$from, $to];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
8
1
3
4
Previous Highlighted Error
Next Highlighted Error
SELECT
# DISTINCT
opp.id as opp_id, opp.uuid, opp.name,
# COUNT(dr.id) AS deal_risk_count,
# dr.id,
# cfd.value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id
# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id
LEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 1
AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
GROUP BY opp.id, cfd.value
ORDER BY
# cfd.value
CAST(cfd.value AS UNSIGNED)
# owner_name
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1
# AND gdrt.is_enabled = 1)
DESC
LIMIT 25
# OFFSET 0
;
select * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';
select * from crm_layout_entities where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4584045;
SELECT * FROM crm_field_data WHERE object_id = 4584045;
SELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'
SELECT
opp.id as opportunity_id,
opp.name,
COUNT(dr.id) as risk_count
FROM opportunities opp
LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id
WHERE opp.id IN (
6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788
)
GROUP BY opp.id;
SELECT COUNT(dr.id)
FROM deal_risks dr
JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
WHERE dr.opportunity_id = 5563344
# AND gdrt.group_id = usr.group_id
EXPLAIN SELECT
opp.id as opp_id, opp.uuid, opp.name,
cfd.value,
cfv.sequence,
cfv.value,
# MAX(cfd.value) AS max_cfd_value,
usr.name AS owner_name,
opp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,
usr.uuid as owner_uuid,
usr.photo_path as owner_photo,
usr.id AS owner_id,
jt.name as owner_job,
opp.stage_id, opp.stage_updated_at,
acc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,
rt.business_process_id AS pipeline_id
FROM opportunities opp
LEFT JOIN record_types rt ON opp.record_type_id = rt.id
LEFT JOIN users usr ON opp.user_id = usr.id
LEFT JOIN accounts acc ON opp.account_id = acc.id
LEFT JOIN job_titles jt ON usr.job_title_id = jt.id
LEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id
FROM crm_field_data sub_cfd
WHERE sub_cfd.object_id = opp.id
AND sub_cfd.crm_field_id = 66810
ORDER BY sub_cfd.updated_at DESC
LIMIT 1)
LEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value
WHERE opp.user_id IS NOT NULL
AND opp.deleted_at IS NULL
AND opp.is_closed = 0
# AND opp.is_closed = 1
# AND opp.is_won = 0
AND opp.close_date >= '2024-01-01 00:00:00'
AND opp.close_date <= '2024-12-31 23:59:59'
AND usr.team_id = 1
# and opp.id = 4823179
# GROUP BY opp.id
ORDER BY
cfv.sequence DESC,
# opp.name
# owner_name
cfd.value
# CAST(cfd.value AS UNSIGNED)
# CAST(MAX(cfd.value) AS UNSIGNED)
# (SELECT COUNT(dr.id)
# FROM deal_risks dr
# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id
# WHERE dr.opportunity_id = opp.id
# AND dr.is_active = 1 AND gdrt.is_enabled = 1)
DESC
# LIMIT 75, 25
;
SELECT * FROM crm_field_values WHERE crm_field_id = 66810;
SELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at
FROM crm_fields f
INNER JOIN crm_field_data fd ON fd.crm_field_id = f.id
WHERE (f.crm_configuration_id = 1)
AND (f.object_type = 'opportunity')
# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))
AND (fd.object_id IN (4158460))
AND (f.crm_provider_id IN ('ForecastCategoryName'))
ORDER BY fd.object_id ASC, fd.updated_at DESC;
select * from crm_layouts where crm_configuration_id = 1;
select cf.* from crm_fields cf
join crm_layout_entities cle on cf.id = cle.crm_field_id
where crm_layout_id = 1493;
SELECT * FROM opportunities WHERE id = 4158460;
SELECT * FROM crm_field_data WHERE object_id = 4158460;
select * from users where team_id = 1;
SELECT * FROM users WHERE id = 7160;
select * from role_user where user_id = 3248;
select * from crm_field_values where crm_field_id = 66824;
SELECT * FROM users WHERE id = 23470;
select * from crm_configurations;
# [PASSWORD_DOTS]
select * from teams where id = 1038; # 23521, 966
select * from users where team_id = 1038;
select * from crm_configurations where id = 966;
SELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762
SELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764
SELECT * FROM participants WHERE activity_id = 54965764;
SELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075
SELECT * FROM participants WHERE activity_id = 54964075;
select f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id
where tf.team_id = 1038;
# [PASSWORD_DOTS] PD [PASSWORD_DOTS]
select * from teams where id = 1029;
SELECT * FROM crm_configurations WHERE id = 957;
SELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421
# [PASSWORD_DOTS] Close [PASSWORD_DOTS]
select * from teams where id = 1031;
SELECT * FROM crm_configurations WHERE id = 959;
SELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517
SELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433
SELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009
# [PASSWORD_DOTS] SF [PASSWORD_DOTS]
SELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;
select * from roles;
select * from permissions;
select * from permission_role where permission_id = 136;
select * from migrations order by id desc;
select * from teams where id IN (1, 1037);
select * from crm_layouts where crm_configuration_id = 1;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;
SELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);
select * from features;
select * from team_features where feature_id = 33;
select * from opportunities;
select * from teams;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1052 and sa.provider = 'hubspot';
SELECT * FROM accounts where id = 11512582;
select * from activities where account_id = 11512582;...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45485
|
1627
|
22
|
2026-05-14T14:39:37.003173+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769577003_m1.jpg...
|
PhpStorm
|
faVsco.js – IntegrationApp/Service.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"16","depth":4,"bounds":{"left":0.77708334,"top":0.3122222,"width":0.02013889,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.80138886,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-7903400416253054810
|
-8781927421094687800
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
16
2
Previous Highlighted Error
Next Highlighted Error
PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelplhl100% C•FV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest8• Thu 14 May 17:39:36* :QProjectvTrackAutomatedReportGeneratedEvent.phpAutomatedReportResult.phpSendReportJob.phpDeleteCrmEntityTrait.php:=custom.log> D WebhookDeleteAccountJob.phpImportActivitylypes.php0 WriteCrmTrait.phpBatchSyncCollector.phpDecorateActivity.phpIntegrationAppServiceTrait.php= laravel.log© BatchSyncRedisService.php© IntegrationApp/Service.php XActivity.phpSalesforce/Service.phpT LogActivityTrait.php© Playbook.phpSF [jiminny@localhost]© Client.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.phpBullhornService.php© PlainTextDecorateActivity.phpA HS_local [jiminny@localho:© ClosedDealStagesService.php© ActivityPlaybookTrait.phpCrmHelperRepository.php© AccountController.php=.env.staging=.env4 console [QAI PROD] X18C DealFieldsService.php© DecorateActivity.phpDetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.phpClient.php4 console [PROD]© FieldDefinitions.php© FieldTypeConverter.php© HubspotPaginationService.phpHandleHubspotRateLimit.phpA console (EU]55classService extendsBaseService implements• HubspotClientinterface.phpB16 x 2© HubspotTokenManager.php354): ?string {...}378© PayloadBuilder.php© RemoteCrmObjectManipulatoi379380© ResponseNormalize.php381© Service.php382 €© SyncFieldAction.php383/***/1* @throws CrmException#[\Override] public function saveActivity(Activity $activity): Activity.id = 33;© SyncRelatedActivityManager.|© WebhookSyncBatchProcessol384v IntegrationApp385386$this->logger-›info('[integration-app] saveActivity', ['activity' => $activity->getUvidO,'type' => $activity->getType(),> O AccessorsD Арі3871):id THEN •(ownD Config388DDTO389390D FiltersD Jobs391D ProspectSearchStrategy392393• ServiceTraits© DataClient.php394© DecorateActivity.php395396© LocalSearch.php397• LocalSearchlnterface.phpC RemoteSearch.php398399DGo jiminny084143 ×4 л215•m_layout_id =2162,1661,66799,66217218219220221-222223224— 225if ($activity->getCrmType() === Activity::TYPE_CONFERENCE) {226$crmActivity = $this->saveMeeting($activity);.2277 elseif (in_array($activity->getType(), [Activity::TYPE_SOFTPHONE, Activity::TYPE_SOFTPHONE_INBOUNDI228$crmActivity = $this->saveCall($activity);229} else 1230231232233V-234=hubspot':-throw new CrmException( message:'Unsupported activity type');= 11512582;$crmActivityId = $crmActivity['id'] ?? null;© Service.php400v • Listeners401if ($crmActivityId |== null) 1$activity->crm_provider_id = $crmActivityId;Sactivity->saveO);C ConvertLeadActivities.php=402© Purnel onkunCache nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)W Windsurf Teams389:61UTF-8Ca 4 spaces...
|
45482
|
NULL
|
NULL
|
NULL
|
|
45488
|
1628
|
19
|
2026-05-14T14:39:40.757233+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769580757_m2.jpg...
|
PhpStorm
|
faVsco.js – Activity.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIAl Notes: OffLeavev Q SearchDate ModifiedYesterdav at 13.36Yesterday at 13:36Yesterday at 13.30Yesterdav at 13:34Yesterday at 13:34resterday at 15.3sYesterdav at 13:3kYesterday at 13:32Yesterday at 13.31Yesterdav at 13:31Yesterday at 13:30resterday at 15.30Yesterdav at 13:29Yesterday at 13:29Yesterday at 13:28Yesterday at 13:28Yesterdav at 13:27resterday at 13-40Yesterdav at 13:26Yesterday at 13:25Yesterday at 13:25Yesterday at 13:24Voctorday at 12:01Yesterday at 13.22Yesterdav at 13:21Yesterday at 13:20Yesterday at 13:19Yesterday at 13.18Yecterdav at 12:19Yesterday at 13-1/Yesterdav at 13:16Yesterday at 13:16Yesterday at 13:15Yecterdav at 12:1/Yesterdav at 13:14Yesterday at 13.13Yecterdav at 13:10Yesterday at 13:12Yesterday at 13:11Yoctorday at 12:11Yesterdav at 13:10Yesterday at 13.10Yecterdav at 12:091Yesterdav at 13:09Yesterdav at 13:0823K:MPEG-4 movie9 KB13 KB16 Kb17 KE29 KB6 KB12 K:MDEG-A movieMPEG-4 movieMPEG-4 movieMPE0"4 movie9 KBMDSG-A movie7 KEMP2G-4 movie37 KB10 KBI KD8 KEMPEG-4 movieMPEG"4 movie9 KBMoEeh movio8 KB72 KBMPEG-4 movie14 KBI13 KB9 KBMPEG-1 movieMPEG-4 movie18 KEMPEG-4 movie12 KB10 KBMPEG-4 movie16 K:MPEG-4 movieAkpMDEG.A movic12 KBMPEG-4 movie23 KB8 KBMPEG-4 movieMPEG-4 movie6 KBMPEG-4 movie16 K:11 KPMDECA movid20 KBMPEG-4 movie21 KPMDEG-A movie10 KB MPEG-4 movie7 KBMPEG-4 movie5 KB111 KB26 KB111 KBMPEG-4 movieMDEC.A movialMPEG-4 movie102 KR88 KB59 KBMDEG-A movieMPEG-4 movie08 KBIMPEG-A movie97 KB MPEG-4 movie66 KB44 KB02 KpMPEG-4 movieMDEG.A movio78 KB50 KBMPEG-4 movie58 KГMPEG-A movid27 KBMPEG-4 movie7 KB12K8MPEG-4 movieFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc tolde0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zipreport(2).xmlAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence hettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentPDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archive5KRMarkdo…..umentWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 Mау 1/.39.40Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
1740868812721988848
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIAl Notes: OffLeavev Q SearchDate ModifiedYesterdav at 13.36Yesterday at 13:36Yesterday at 13.30Yesterdav at 13:34Yesterday at 13:34resterday at 15.3sYesterdav at 13:3kYesterday at 13:32Yesterday at 13.31Yesterdav at 13:31Yesterday at 13:30resterday at 15.30Yesterdav at 13:29Yesterday at 13:29Yesterday at 13:28Yesterday at 13:28Yesterdav at 13:27resterday at 13-40Yesterdav at 13:26Yesterday at 13:25Yesterday at 13:25Yesterday at 13:24Voctorday at 12:01Yesterday at 13.22Yesterdav at 13:21Yesterday at 13:20Yesterday at 13:19Yesterday at 13.18Yecterdav at 12:19Yesterday at 13-1/Yesterdav at 13:16Yesterday at 13:16Yesterday at 13:15Yecterdav at 12:1/Yesterdav at 13:14Yesterday at 13.13Yecterdav at 13:10Yesterday at 13:12Yesterday at 13:11Yoctorday at 12:11Yesterdav at 13:10Yesterday at 13.10Yecterdav at 12:091Yesterdav at 13:09Yesterdav at 13:0823K:MPEG-4 movie9 KB13 KB16 Kb17 KE29 KB6 KB12 K:MDEG-A movieMPEG-4 movieMPEG-4 movieMPE0"4 movie9 KBMDSG-A movie7 KEMP2G-4 movie37 KB10 KBI KD8 KEMPEG-4 movieMPEG"4 movie9 KBMoEeh movio8 KB72 KBMPEG-4 movie14 KBI13 KB9 KBMPEG-1 movieMPEG-4 movie18 KEMPEG-4 movie12 KB10 KBMPEG-4 movie16 K:MPEG-4 movieAkpMDEG.A movic12 KBMPEG-4 movie23 KB8 KBMPEG-4 movieMPEG-4 movie6 KBMPEG-4 movie16 K:11 KPMDECA movid20 KBMPEG-4 movie21 KPMDEG-A movie10 KB MPEG-4 movie7 KBMPEG-4 movie5 KB111 KB26 KB111 KBMPEG-4 movieMDEC.A movialMPEG-4 movie102 KR88 KB59 KBMDEG-A movieMPEG-4 movie08 KBIMPEG-A movie97 KB MPEG-4 movie66 KB44 KB02 KpMPEG-4 movieMDEG.A movio78 KB50 KBMPEG-4 movie58 KГMPEG-A movid27 KBMPEG-4 movie7 KB12K8MPEG-4 movieFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc tolde0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zipreport(2).xmlAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence hettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentPDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archive5KRMarkdo…..umentWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 Mау 1/.39.40Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
45484
|
NULL
|
NULL
|
NULL
|
|
45486
|
1627
|
23
|
2026-05-14T14:39:40.766709+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769580766_m1.jpg...
|
PhpStorm
|
faVsco.js – Activity.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpabl100% С•FV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTestv8• Thu 14 May 17:39:40* :QProject vTrackAutomatedReportGeneratedEvent.phpAutomatedReportResult.php© SendReportJob.php> C WebhookDeleteAccountJob.phpImportActivitylypes.php0 WriteCrmTrait.phpDecorateActivity.php© Account.php© IntegrationApp/Service.phpActivity.php XSalesforce/Service.phpT LogActivityTrait.php© Activity.php© Address.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.php© AiPrompt.php© ActivityPlaybookTrait.phpCrmHelperRepository.php© AccountController.php=.env.staging18© AutomatedReport.php© AutomatedReportResult.php•DetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.php© Calendar.php© HubspotPaginationService.php© CallImport.php© CoachingFeedback.php© HandleHubspotRateLimit.phpclass Activity extendsModel implementsX OEt UCt CONSEIt TeCOrUS USSOcacea wIc cis accecg© CoachingFeedbackVisibility.php© CoachingSection.php© CoachingSectionCriterion.php303J00335733583359* @return lIlluminate|DatabaselEloquent|Relations|HasMany© CoachingSectionCriterionFeedback.*/8 usages© CoachingSectionFeedback.php© CommentAbstract.php33603364public function participantConsents(): HasMany{...}© Commentinterface.php1 usage© Contact.php© Device.php3365 € >3377public function isDiallerCall(): boolf...}© EmailMessage.php3 usages© GenericAiPrompt.php© Group.php© Inbox.php© InboxEmail.php© InboxEmailBatch.php© Invitation.php© JobLog.php© JobTitle.php© Language.php© LanguageDialect.php© Lead.php© MobileSetting.php© Model.php337833903391 € public function getActivityDateWithFallback(): Carbon{...}public function getCrmType(): ?string// Treat uploader activities as conferencesif ($this->getProvider() === Activity::PROVIDER_UPLOADER) {return Activity: :TYPE_CONFERENCE;}return $this->getType():}© Moment.php© Nudge.phpA MudnaDun nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DeleteCrmEntityTrait.php:=custom.logIntegrationAppServiceTrait.php= laravel.log© Playbook.phpSF [jiminny@localhost]PlainTextDecorateActivity.phpA HS_local [jiminny@localho:=.env4 console [QAI PROD] XClient.php4 console [PROD]A console (EU]A4 A169 X4 X 102 2,4 ^DGo jiminny084143 ×4 л215•m_layout_id =2162,1661, 66799,66217=218-219.id = 33;220=221222223.224id THEN •(own=225226227228229230hubspot":231232233 V11512582;234=W Windsurf Teams3391:21UTF-8Ca 4 spaces...
|
NULL
|
-8399148374995298077
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpabl100% С•FV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTestv8• Thu 14 May 17:39:40* :QProject vTrackAutomatedReportGeneratedEvent.phpAutomatedReportResult.php© SendReportJob.php> C WebhookDeleteAccountJob.phpImportActivitylypes.php0 WriteCrmTrait.phpDecorateActivity.php© Account.php© IntegrationApp/Service.phpActivity.php XSalesforce/Service.phpT LogActivityTrait.php© Activity.php© Address.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.php© AiPrompt.php© ActivityPlaybookTrait.phpCrmHelperRepository.php© AccountController.php=.env.staging18© AutomatedReport.php© AutomatedReportResult.php•DetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.php© Calendar.php© HubspotPaginationService.php© CallImport.php© CoachingFeedback.php© HandleHubspotRateLimit.phpclass Activity extendsModel implementsX OEt UCt CONSEIt TeCOrUS USSOcacea wIc cis accecg© CoachingFeedbackVisibility.php© CoachingSection.php© CoachingSectionCriterion.php303J00335733583359* @return lIlluminate|DatabaselEloquent|Relations|HasMany© CoachingSectionCriterionFeedback.*/8 usages© CoachingSectionFeedback.php© CommentAbstract.php33603364public function participantConsents(): HasMany{...}© Commentinterface.php1 usage© Contact.php© Device.php3365 € >3377public function isDiallerCall(): boolf...}© EmailMessage.php3 usages© GenericAiPrompt.php© Group.php© Inbox.php© InboxEmail.php© InboxEmailBatch.php© Invitation.php© JobLog.php© JobTitle.php© Language.php© LanguageDialect.php© Lead.php© MobileSetting.php© Model.php337833903391 € public function getActivityDateWithFallback(): Carbon{...}public function getCrmType(): ?string// Treat uploader activities as conferencesif ($this->getProvider() === Activity::PROVIDER_UPLOADER) {return Activity: :TYPE_CONFERENCE;}return $this->getType():}© Moment.php© Nudge.phpA MudnaDun nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DeleteCrmEntityTrait.php:=custom.logIntegrationAppServiceTrait.php= laravel.log© Playbook.phpSF [jiminny@localhost]PlainTextDecorateActivity.phpA HS_local [jiminny@localho:=.env4 console [QAI PROD] XClient.php4 console [PROD]A console (EU]A4 A169 X4 X 102 2,4 ^DGo jiminny084143 ×4 л215•m_layout_id =2162,1661, 66799,66217=218-219.id = 33;220=221222223.224id THEN •(own=225226227228229230hubspot":231232233 V11512582;234=W Windsurf Teams3391:21UTF-8Ca 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45487
|
1627
|
24
|
2026-05-14T14:39:43.307502+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769583307_m1.jpg...
|
PhpStorm
|
faVsco.js – Activity.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
169
4
102
4
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Models;
use Carbon\Carbon;
use Database\Factories\ActivityFactory;
use DateTimeInterface;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use InvalidArgumentException;
use Jiminny\Component\ElasticSearch;
use Jiminny\Component\MeetingBot;
use Jiminny\Component\Model\BitwiseFlagTrait;
use Jiminny\Component\PlaybackPage\Comments\Services\ActivityCommentService;
use Jiminny\Component\Sidekick\SidekickService;
use Jiminny\Component\Uuid\UuidAwareInterface;
use Jiminny\Component\Workflow;
use Jiminny\Contracts;
use Jiminny\Contracts\Crm\ProspectInterface;
use Jiminny\DTO\ImportCall\Call;
use Jiminny\Events\Activities\ActivityTypeUpdated;
use Jiminny\Events\Activities\ActivityUpdated;
use Jiminny\Events\Activities\ProspectUpdated;
use Jiminny\Events\Activities\StageUpdated;
use Jiminny\Events\Activities\StatusUpdated;
use Jiminny\Events\Activities\TitleUpdated;
use Jiminny\Exceptions\InvalidArgumentException as InvalidArgumentJiminnyException;
use Jiminny\Exceptions\LogicException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models;
use Jiminny\Models\Activity\ActivitySummaryLog;
use Jiminny\Models\Activity\ActivityUploadSetting;
use Jiminny\Models\Activity\AvailabilityNotification;
use Jiminny\Models\Activity\CoachRequest;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\Activity\Log;
use Jiminny\Models\Activity\Message;
use Jiminny\Models\Activity\Moment;
use Jiminny\Models\Activity\Note;
use Jiminny\Models\Activity\ParticipantSpeech;
use Jiminny\Models\Activity\Play;
use Jiminny\Models\Activity\Question;
use Jiminny\Models\Activity\Share;
use Jiminny\Models\Activity\Snapshot;
use Jiminny\Models\Activity\Stats;
use Jiminny\Models\Activity\SubscriptionSet;
use Jiminny\Models\Activity\TopicTrigger;
use Jiminny\Models\Activity\Transcription;
use Jiminny\Models\Calendar\CalendarEvent;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\FieldData;
use Jiminny\Models\ElasticSearch\ActivityElasticSearchTrait;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Participant\Connection;
use Jiminny\Models\Playlist\Activity as PlaylistActivity;
use Jiminny\Services\Activity\ActivityProviderRegistry;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataByStrategy;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverFactory;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverInterface;
use Jiminny\Traits\Enums;
use Jiminny\Traits\RequiresUUID;
use Jiminny\Utils\CurrencyFormatter;
use NumberFormatter;
use function in_array;
/**
* Jiminny\Models\Activity
*
* @property null|int $auto_score filled from ES hydrator, not in DB!
* @property-read Account|null $account
* @property-read CalendarEvent|null $calendarEvent
* @property-read Contact|null $contact
* @property-read Lead|null $lead
* @property-read Opportunity|null $opportunity
* @property-read Stage|null $stage
* @property int $id
* @property mixed|null $uuid
* @property string|null $source
* @property string|null $external_id
* @property string $provider
* @property string|null $location
* @property string|null $telephony_provider_id
* @property int|null $from_participant_id
* @property int|null $to_participant_id
* @property int|null $device_id
* @property string|null $type
* @property int|null $playbook_category_id
* @property int $user_id
* @property int|null $lead_id
* @property int|null $account_id
* @property int|null $contact_id
* @property int|null $opportunity_id
* @property int|null $stage_id
* @property string|null $value
* @property int|null $crm_configuration_id
* @property string|null $crm_provider_id
* @property string|null $language
* @property int|null $transcription_id
* @property int $duration
* @property string $status
* @property int|null $on_air
* @property int|null $calendar_event_id
* @property string $recording_state
* @property bool|null $recording_preference
* @property int $recording_reason_code
* @property int $summary_reminder_sent
* @property \Illuminate\Support\Carbon|null $log_reminder_sent_at
* @property \Illuminate\Support\Carbon|null $organizer_notified_at
* @property bool|null $has_recording_prompt
* @property bool $is_internal
* @property int $is_locked
* @property int $is_recording
* @property bool|null $is_processed
* @property bool $is_private
* @property bool $is_instant_invite
* @property string|null $poster_path
* @property string|null $summary
* @property string|null $title
* @property string|null $description
* @property \Illuminate\Support\Carbon|null $scheduled_start_time
* @property \Illuminate\Support\Carbon|null $scheduled_end_time
* @property \Illuminate\Support\Carbon|null $actual_start_time
* @property \Illuminate\Support\Carbon|null $actual_end_time
* @property int|null $uploaded_by
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $average_score
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $activeParticipants
* @property-read int|null $active_participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers
* @property-read int|null $activity_scorecard_rule_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRule> $activityScorecardRules
* @property-read int|null $activity_scorecard_rules_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, AvailabilityNotification> $availabilityNotifications
* @property-read int|null $availability_notifications_count
* @property-read \Jiminny\Models\PlaybookCategory|null $category
* @property-read \Illuminate\Database\Eloquent\Collection<int, CoachRequest> $coachRequests
* @property-read int|null $coach_requests_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $coachingFeedbacks
* @property-read int|null $coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $coachingMessages
* @property-read int|null $coaching_messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $comments
* @property-read int|null $comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Connection> $connections
* @property-read int|null $connections_count
* @property-read Configuration|null $crm
* @property-read \Illuminate\Database\Eloquent\Collection<int, FieldData> $data
* @property-read int|null $data_count
* @property-read \Jiminny\Models\Device|null $device
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $favoritePlaylists
* @property-read int|null $favorite_playlists_count
* @property-read \Jiminny\Models\Participant|null $from
* @property-read string|null $activity_title
* @property-read mixed $comment_count
* @property-read mixed $duration_for_humans
* @property-read string $duration_for_humans_short
* @property-read int $favorite_count
* @property-read mixed $favorites_count
* @property-read mixed $formatted_value
* @property-read string $id_string
* @property-read \Jiminny\Models\Participant|null $organizer
* @property-read mixed $play_count
* @property-read int|null $plays_count
* @property-read ?ProspectInterface $prospect
* @property-read string|null $prospect_name
* @property-read mixed $prospect_type
* @property-read mixed $share_count
* @property-read int|null $shares_count
* @property-read int|null $tracks_with_telephony_count
* @property-read int|null $visible_comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $latestCoachingFeedbacks
* @property-read int|null $latest_coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Log> $logs
* @property-read int|null $logs_count
* @property-read \Jiminny\Models\Track|null $masterTrack
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $messages
* @property-read int|null $messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Moment> $moments
* @property-read int|null $moments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Note> $notes
* @property-read int|null $notes_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\Share> $participantShares
* @property-read int|null $participant_shares_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, ParticipantSpeech> $participantSpeeches
* @property-read int|null $participant_speeches_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\ParticipantStats> $participantStats
* @property-read int|null $participant_stats_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $participants
* @property-read int|null $participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, PlaylistActivity> $playlistActivities
* @property-read int|null $playlist_activities_count
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $playlists
* @property-read int|null $playlists_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Play> $plays
* @property-read \Illuminate\Database\Eloquent\Collection<int, Question> $questions
* @property-read int|null $questions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Session> $sessions
* @property-read int|null $sessions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Share> $shares
* @property-read \Illuminate\Database\Eloquent\Collection<int, Snapshot> $snapshots
* @property-read int|null $snapshots_count
* @property-read Stats|null $stats
* @property-read \Jiminny\Models\Participant|null $to
* @property-read \Illuminate\Database\Eloquent\Collection<int, TopicTrigger> $topicTriggers
* @property-read int|null $topic_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracks
* @property-read int|null $tracks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracksWithTelephony
* @property-read Transcription|null $transcription
* @property-read \Jiminny\Models\User $user
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $visibleComments
*
* @method static \Illuminate\Database\Eloquent\Collection<int, static> all($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)
* @method static \Database\Factories\ActivityFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Collection<int, static> get($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity heldBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity idOrUuId($idOrUuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity newModelQuery()
* @method static \Jiminny\Component\Eloquent\Builder|Activity newQuery()
* @method static Builder|Activity onlyTrashed()
* @method static \Jiminny\Component\Eloquent\Builder|Activity query()
* @method static \Jiminny\Component\Eloquent\Builder|Activity scheduledBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity inOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity notInOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity forTeam(int $teamId)
* @method static \Jiminny\Component\Eloquent\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity uuid(string $uuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAccountId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAverageScore($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCalendarEventId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereContactId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCreatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmConfigurationId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeletedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDescription($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeviceId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDuration($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereFromParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereHasRecordingPrompt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInstantInvite($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInternal($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsLocked($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsPrivate($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsProcessed($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsRecording($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLanguage($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLeadId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLocation($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLogReminderSentAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOnAir($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOpportunityId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOrganizerNotifiedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePlaybookCategoryId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePosterPath($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereProvider($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingPreference($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingReasonCode($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingState($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSource($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereExternalId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStageId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStatus($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummary($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummaryReminderSent($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTelephonyProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTitle($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereToParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTranscriptionId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereType($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUpdatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUploadedBy($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUserId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUuid($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereValue($value)
* @method static Builder|Activity withTrashed()
* @method static Builder|Activity withoutTrashed()
*
* @mixin \Eloquent
*/
class Activity extends Model implements
ElasticSearch\Contract\Searchable,
Workflow\Workflow\WorkflowAwareInterface,
Models\Contracts\ActivityContract,
Contracts\Model\ActivityInterface,
UuidAwareInterface
{
use HasFactory;
use Enums;
use SoftDeletes;
use RequiresUUID;
use BitwiseFlagTrait;
use ElasticSearch\Model\Searchable;
use ActivityElasticSearchTrait;
use Workflow\Workflow\WorkflowAware {
transitionTo as traitTransitionTo;
}
public const int FLAG_RECORDING_REASON_DEFAULT = 0;
// Recording Prompted but never started
public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;
public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;
// Recording Disabled by Organization
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;
// Recording was restricted to one-side recordings only
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;
// Recording was not started because it was internal and team setting disabled that.
public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;
// Recording was not started because it was internal and user setting disabled that.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;
// Recording was not started because user setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;
// Recording was not started because team setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;
// Recording was not started because user has overriden default.
public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;
// Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;
// Recording was not started because their team setting does excludes the meeting type.
public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;
// Recording was not started because the external provider disabled it (or recording is missing etc).
public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;
// Recording was stopped externally ("exit-meeting" Pusher event)
public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;
// Recording couldn't be started due to Zoom hosting conflict error
public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;
// meeting.failed event with reason code BOT_DENIED_FROM_LOBBY
public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;
// meeting.failed event with reason code LOBBY_TIMEOUT
public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;
// meeting.failed event with reason code BOT_KICKED
public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;
// meeting.failed event with reason code UNKNOWN
public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;
public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;
// Invalid meeting (e.g. URL is invalid, or the meeting is not found)
public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;
// The host stopped the recording.
public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;
// Recording was not started because an alternative vendor disabled it (or overrode it).
public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;
// Login required meeting.failed code
public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;
// Password for meeting was not provided - meeting.failed code
public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;
// meeting.failed - when the meeting is locked
public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;
// max recording duration reached
public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;
// recording size is too small
public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;
// meeting.failed - when bot is redirected to sign in page multiple times
public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;
// meeting.failed event with reason code CONNECTION_LOST
public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;
// recording is corrupted.
public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;
// meeting ended in lobby
public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;
// meeting not started
public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;
// unfinished zoom custom disclaimer
public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;
// recording download failed - server error
public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;
// recording download failed - client code 404
public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;
// recording download failed - client code 401, 403
public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;
// recording download failed - client code 429
public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;
// recording download failed - unknown client error
public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;
// recording download failed - unknown error
public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;
// It has been setup ahead of time through calendar
public const string STATUS_SCHEDULED = 'scheduled';
// It is awaiting audio.
public const string STATUS_PENDING = 'pending';
// Participant(s) dialed in, awaiting organizer.
public const string STATUS_RINGING = 'ringing';
// Call is in progress.
public const string STATUS_IN_PROGRESS = 'in-progress';
// It has ended.
public const string STATUS_COMPLETED = 'completed';
// Cancelled prior to starting.
public const string STATUS_CANCELLED = 'canceled';
public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference
public const string STATUS_STARTING_SOON = 'starting-soon';
public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';
public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';
public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';
// When bot instance is waiting in lobby
public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';
public const string STATUS_BUSY = 'busy';
public const string STATUS_NO_ANSWER = 'no-answer';
public const string STATUS_FAILED = 'failed'; // Used by SMS too
// SMS related
public const string STATUS_ACCEPTED = 'accepted';
public const string STATUS_QUEUED = 'queued';
public const string STATUS_SENDING = 'sending';
public const string STATUS_SENT = 'sent';
public const string STATUS_DELIVERED = 'delivered';
public const string STATUS_UNDELIVERED = 'undelivered';
public const string STATUS_RECEIVING = 'receiving';
public const string STATUS_RECEIVED = 'received';
public const string STATUS_RESENT = 'resent';
public const array SMS_STATUSES = [
Activity::STATUS_RECEIVED,
Activity::STATUS_SENT,
Activity::STATUS_DELIVERED,
];
public const array SOFT_PHONE_CONFERENCE_STATUSES = [
Activity::STATUS_IN_PROGRESS,
Activity::STATUS_COMPLETED,
];
// @todo refactor prefix from `TYPE_` to `CHANNEL_`
public const string TYPE_SOFTPHONE = 'softphone';
public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';
public const string TYPE_CONFERENCE = 'conference';
public const string TYPE_SMS_INBOUND = 'sms-inbound';
public const string TYPE_SMS_OUTBOUND = 'sms-outbound';
public const string TYPE_EMAIL_INBOUND = 'email-inbound';
public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';
public const array CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
public const array PLAYABLE_CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
];
// Recording States
public const string RECORDING_OFF = 'off'; // Default state
public const string RECORDING_IN_PROGRESS = 'in-progress';
public const string RECORDING_PAUSED = 'paused';
public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.
public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.
public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.
// Live Stream States
public const int ON_AIR_DEFAULT = 0;
public const int ON_AIR_READY = 1;
public const int ON_AIR_PREPARING = 2;
public const int ON_AIR_STREAMING = 3;
public const int ON_AIR_FINISHED = 4;
public const int ON_AIR_NOT_STREAMED = 5;
public const int ON_AIR_ERROR = -1;
public const string SOURCE_GONG = 'gong';
public const string SOURCE_CHORUS = 'chorus';
public const string SOURCE_OUTLOOK = 'outlook';
public const string SOURCE_GOOGLE = 'google';
// Activity Providers
public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.
public const string PROVIDER_OUTREACH = 'outreach';
public const string PROVIDER_ZOOM_BOT = 'zoom-bot';
public const string PROVIDER_SALESLOFT = 'salesloft';
public const string PROVIDER_GOOGLE = 'google';
public const string PROVIDER_AIRCALL = 'aircall';
public const string PROVIDER_JUSTCALL = 'justcall';
public const string PROVIDER_GOOGLE_MEET = 'google-meet';
public const string PROVIDER_GONG = 'gong';
public const string PROVIDER_HUBSPOT = 'hubspot';
public const string PROVIDER_CLOSE = 'close';
public const string PROVIDER_TEAMS = 'ms-teams';
public const string PROVIDER_SALESFORCE = 'salesforce';
public const string PROVIDER_GROOVE = 'groove';
public const string PROVIDER_XANT = 'xant';
public const string PROVIDER_OFFICE = 'office';
public const string PROVIDER_NATTERBOX = 'natterbox';
public const string PROVIDER_RINGCENTRAL = 'ringcentral';
public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';
public const string PROVIDER_GOTOMEETING = 'go-to-meeting';
public const string PROVIDER_DEMODESK = 'demo-desk';
public const string PROVIDER_DIALPAD = 'dialpad';
public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';
public const string PROVIDER_CLOUDCALL = 'cloudcall';
public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';
public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // "8x8" UK
public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // "8x8" Canada
public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // "8x8" Australia
public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // "8x8" US East
public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // "8x8" US West
public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';
public const string PROVIDER_CLOUD_TALK = 'cloud-talk';
public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';
public const string PROVIDER_VONAGE = 'vonage';
public const string PROVIDER_MIGRATOR = 'migrator';
public const string PROVIDER_UPLOADER = 'uploader';
public const string PROVIDER_TALKDESK = 'talkdesk';
public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';
public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';
public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';
public const string PROVIDER_AVAYA = 'avaya';
public const string PROVIDER_TELUS = 'telus';
public const string PROVIDER_FIVE_NINE = 'five-nine';
public const string PROVIDER_APOLLO = 'apollo';
public const string PROVIDER_ORUM = 'orum';
public const string PROVIDER_BLOOBIRDS = 'bloobirds';
/**
* @const API_PROVIDERS
* A list of integrations that import calls via API instead of webhooks
*/
public const array API_PROVIDERS = [
self::PROVIDER_OUTREACH,
self::PROVIDER_SALESLOFT,
self::PROVIDER_HUBSPOT,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_NATTERBOX,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
];
public const array FINITE_STATES = [
self::TYPE_SOFTPHONE => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_SOFTPHONE_INBOUND => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,
];
public const array FINITE_STATES_CONFERENCE = [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_CANCELLED,
];
public const array MEETING_BOT_JOIN_ATTEMPTED = [
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_BOT_INSTANCE_STARTED,
];
public static array $enumStatuses = [
self::STATUS_SCHEDULED,
self::STATUS_PENDING,
self::STATUS_RINGING,
self::STATUS_IN_PROGRESS,
self::STATUS_COMPLETED,
self::STATUS_CANCELLED,
self::STATUS_BUSY,
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_ACCEPTED,
self::STATUS_QUEUED,
self::STATUS_SENDING,
self::STATUS_SENT,
self::STATUS_RESENT,
self::STATUS_DELIVERED,
self::STATUS_UNDELIVERED,
self::STATUS_RECEIVING,
self::STATUS_RECEIVED,
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_STARTING_SOON,
self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,
self::STATUS_BOT_INSTANCE_STARTED,
self::STATUS_DUPLICATED,
];
public static array $enumProviders = [
self::PROVIDER_TWILIO,
self::PROVIDER_OUTREACH,
self::PROVIDER_ZOOM_BOT,
self::PROVIDER_SALESLOFT,
self::PROVIDER_AIRCALL,
self::PROVIDER_JUSTCALL,
self::PROVIDER_GOOGLE_MEET,
self::PROVIDER_GONG,
self::PROVIDER_HUBSPOT,
self::PROVIDER_CLOSE,
self::PROVIDER_TEAMS,
self::PROVIDER_SALESFORCE,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_GOOGLE,
self::PROVIDER_OFFICE,
self::PROVIDER_NATTERBOX,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_RINGCENTRAL_VIDEO,
self::PROVIDER_GOTOMEETING,
self::PROVIDER_DEMODESK,
self::PROVIDER_DIALPAD,
self::PROVIDER_ZOOM_PHONE,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
];
public static $enumRecordingStates = [
self::RECORDING_OFF, // Default state
self::RECORDING_IN_PROGRESS,
self::RECORDING_PAUSED,
self::RECORDING_STOPPED,
self::RECORDING_RECORDED,
self::RECORDING_FAILED,
];
// @Important:
// This collection is not used anywhere, and is fully duplicated by the Channels const.
// Validate if it is referred somehow via the enum trait, and if not, remove it entirely.
// An even better strategy will be to move all those constants to a dedicated class
protected array $enumTypes = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
protected static $enumFailedStatuses = [
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_BUSY,
self::STATUS_CANCELLED,
];
protected $table = 'activities';
protected $fillable = [
// Type of activity.
'type', // @todo refactor to `channel`
// The activity type.
'playbook_category_id',
// User who hosts the activity.
'user_id',
// Related Lead record (if applicable)
'lead_id',
// Related Account record (if applicable)
'account_id',
// Related Contact record (if applicable)
'contact_id',
// Related Opportunity record (if applicable)
'opportunity_id',
// Stage of activity.
'stage_id',
// Value of opportunity.
'value',
// If the activity relates to a CRM task.
'crm_provider_id',
// If the activity was created through an external device.
'device_id',
// the activity's language code
'language',
// transcription id
'transcription_id',
// Duration of the call, with microseconds precision.
'duration',
// One of enumStatuses above.
'status',
// Have we reminded them to log the call?
'log_reminder_sent_at',
// If activity is private or inter-org, flagged here.
'is_internal',
// Managers and above can mark a call as private, to exclude it from other team members
'is_private',
'is_processed',
// Boolean for this activity being instant invite handled.
'is_instant_invite',
// If activity is in recording state, flagged here.
'recording_state',
// If activity recording is overidden from default.
'recording_preference',
// if recording did (not) happen, why that is
'recording_reason_code',
// Average score, updated during
'average_score',
// Summary that the organizer has taken after the call.
'summary',
// Subject of the activity, usually taken from calendar event.
'title',
// Description of the activity, usually taken from calendar event.
'description',
// Start time, usually taken from calendar event.
'scheduled_start_time',
// End time, usually taken from calendar event.
'scheduled_end_time',
// When the call actually started.
'actual_start_time',
// When the call actually ended.
'actual_end_time',
// SMS: Message reference
'telephony_provider_id',
// SMS: Participant who sent message
'from_participant_id',
// SMS: Participant who should receive the message
'to_participant_id',
// When an external guest joins an organizers meeting room and the organizer is not present,
// send them an SMS notification that someone has joined.
'organizer_notified_at',
// where was the activity imported from
'source',
// The id in the source system (e.g. the bot id in Recall.ai)
'external_id',
// The provider, by default it is twilio.
'provider',
// Meeting location url
'location',
// The snapshot for displaying a poster image.
'poster_path',
'crm_configuration_id',
// If there is an automated message that the conversation is being recorded
'has_recording_prompt',
// If the activity is being live-streamed
'on_air',
'calendar_event_id',
];
protected $appends = [
'id_string',
'organizer',
];
protected $hidden = [
'uuid',
];
protected $visible = [
'id_string',
'type',
'duration',
'average_score',
'status',
'log_reminder_sent_at',
'title',
'description',
'is_internal',
'scheduled_start_time',
'scheduled_end_time',
'actual_start_time',
'actual_end_time',
'user',
'category',
'account',
'contact',
'opportunity',
'lead',
'stage',
'stats',
'participants',
'playlists',
'tracks',
'comments',
'plays',
'coachingFeedbacks',
'shares',
'favorites',
'language',
'transcription',
'is_private',
'is_instant_invite',
'on_air',
'calendar_event_id',
];
protected function casts(): array
{
return [
'scheduled_start_time' => 'datetime',
'scheduled_end_time' => 'datetime',
'actual_start_time' => 'datetime',
'actual_end_time' => 'datetime',
'organizer_notified_at' => 'datetime',
'log_reminder_sent_at' => 'datetime',
'is_internal' => 'boolean',
'duration' => 'integer',
'average_score' => 'decimal:2',
'is_private' => 'boolean',
'is_processed' => 'boolean',
'is_instant_invite' => 'boolean',
'value' => 'decimal:2',
'recording_preference' => 'boolean',
'recording_reason_code' => 'integer',
'has_recording_prompt' => 'boolean',
'on_air' => 'integer',
];
}
protected static function boot()
{
parent::boot();
static::updated(static function (Activity $activity) {
// If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week
if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||
($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {
if ($activity->isDirty('status')) {
event(new StatusUpdated($activity));
}
if ($activity->isDirty('stage_id')) {
event(new StageUpdated($activity));
}
if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {
event(new ProspectUpdated($activity));
}
if ($activity->isDirty('opportunity_id')) {
event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));
}
if ($activity->isDirty('title')) {
event(new TitleUpdated($activity));
}
}
if ($activity->isDirty('playbook_category_id')) {
event(new ActivityTypeUpdated($activity));
}
});
static::deleted(static function (Activity $activity) {
// Hard delete associated playlistActivities
$activity->playlistActivities()->delete();
});
}
public function getOrganizerAttribute(): ?Participant
{
$participant = $this->participants()->where('user_id', $this->user_id)->first();
if (! $participant instanceof Participant && $participant !== null) {
throw new RuntimeException(sprintf('$participant must be an instance of "%s" or null', Participant::class));
}
return $participant;
}
public function getFormattedValueAttribute()
{
$currencyCode = 'USD';
if ($this->opportunity) {
$currencyCode = $this->opportunity->getCurrencyCode();
}
$formatter = new CurrencyFormatter();
$formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
return $formatter->format($this->value, $currencyCode);
}
public function getProspectNameAttribute(): ?string
{
$prospectName = null;
if ($this->lead_id) {
$prospectName = $this->lead->name;
} elseif ($this->contact_id) {
$prospectName = $this->contact->name;
} elseif ($this->account_id) {
$prospectName = $this->account->name;
}
return $prospectName;
}
public function getProspectName(): ?string
{
/** @var string|null */
return $this->getAttribute('prospect_name');
}
/**
* Get activity title depending on prospect or title
*/
public function getActivityTitleAttribute(): ?string
{
$activityTitle = null;
if ($this->prospect && $this->prospect->getName()) {
if ($this->account_id) {
$activityTitle = $this->account->name;
} elseif ($this->lead_id) {
$activityTitle = $this->lead->company;
} elseif ($this->contact_id) {
$activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;
}
} elseif ($this->title) {
$activityTitle = $this->title;
}
return $activityTitle;
}
public function wasRecentlyCreated(): bool
{
return $this->wasRecentlyCreated;
}
public function getProspectTypeAttribute()
{
$prospectType = null;
if ($this->lead_id) {
$prospectType = 'Lead';
} elseif ($this->contact_id) {
$prospectType = 'Contact';
} elseif ($this->account_id) {
$prospectType = 'Account';
}
return $prospectType;
}
/**
* Return the best match for prospect. Results are in the following order of priority:
* 1. Lead
* 2. Contact
* 3. Account
* 4. NULL
*/
public function getProspectAttribute(): ?ProspectInterface
{
if ($this->hasLead()) {
return $this->getLead();
}
if ($this->hasContact()) {
return $this->getContact();
}
if ($this->hasAccount()) {
return $this->getAccount();
}
return null;
}
public function getTitleAttribute($value): ?string
{
return \getActivityTitleAttribute(
$this->user->name,
$this->getType(),
$value,
$this->prospect->name ?? null,
$this->from->national_phone_number ?? null
);
}
public function getTitle(): ?string
{
return $this->getAttribute('title');
}
public function getSummary(): ?string
{
return $this->getAttribute('summary');
}
public function isInternal(): bool
{
return $this->getAttribute('is_internal');
}
public function getIsPrivate(): bool
{
return $this->getAttribute('is_private');
}
public function getDescription(): ?string
{
return $this->getAttribute('description');
}
public function hasTitle(): bool
{
return $this->getOriginal('title') !== null;
}
public function getPlayCountAttribute()
{
return $this->getPlaysCountAttribute();
}
public function getPlaysCountAttribute()
{
if (! isset($this->attributes['plays_count'])) {
$this->loadCount('plays');
}
return $this->attributes['plays_count'];
}
public function getCommentCountAttribute()
{
return $this->getCommentsCountAttribute();
}
public function getCommentsCountAttribute()
{
if (! isset($this->attributes['comments_count'])) {
$this->loadCount('comments');
}
return $this->attributes['comments_count'];
}
public function getVisibleCommentsCountAttribute()
{
if (! isset($this->attributes['visible_comments_count'])) {
$activityCommentsService = app(ActivityCommentService::class);
$user = Auth::user() instanceof User ? Auth::user() : null;
$this->attributes['visible_comments_count'] = $activityCommentsService
->getVisibleCommentsCount($this, $user);
}
return $this->attributes['visible_comments_count'];
}
public function getShareCountAttribute()
{
return $this->getSharesCountAttribute();
}
public function getSharesCountAttribute()
{
if (! isset($this->attributes['shares_count'])) {
$this->loadCount('shares');
}
return $this->attributes['shares_count'];
}
/**
* Get the count of favorites playlists this activity appears in
*/
public function getFavoriteCountAttribute(): int
{
return $this->getFavoritesCountAttribute();
}
public function getFavoritesCountAttribute()
{
if (! isset($this->attributes['favorites_count'])) {
$this->loadCount('favorites');
}
return $this->attributes['favorites_count'];
}
public function getActiveParticipantsCountAttribute()
{
if (! isset($this->attributes['active_participants_count'])) {
$this->loadCount('activeParticipants');
}
return $this->attributes['active_participants_count'];
}
public function getTracksWithTelephonyCountAttribute()
{
if (! isset($this->attributes['tracks_with_telephony_count'])) {
$this->loadCount('tracksWithTelephony');
}
return $this->attributes['tracks_with_telephony_count'];
}
/**
* @TEMP
* $this->loadCount('tracksWithTelephony') throws null pointer exception
*/
public function countTracksWithTelephony(): int
{
return $this->tracks()->whereNotNull('telephony_provider_id')->count();
}
public function getDuration(): float
{
return $this->getAttribute('duration');
}
public function getDurationForHumansAttribute()
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);
}
public function getDurationForHumansShortAttribute(): string
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);
}
public function has...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.054166667,"top":0.027777778,"width":0.08055556,"height":0.035555556},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"#12066 on JY-20725-handle-HS-search-rate-limit, menu","depth":5,"bounds":{"left":0.13472222,"top":0.027777778,"width":0.25555557,"height":0.035555556},"on_screen":true,"help_text":"Pull request #12066 exists for current branch JY-20725-handle-HS-search-rate-limit, but local branch is out of sync with remote","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.6326389,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"HandleHubspotRateLimitTest","depth":6,"bounds":{"left":0.6645833,"top":0.027777778,"width":0.15902779,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.82361114,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'HandleHubspotRateLimitTest'","depth":6,"bounds":{"left":0.8472222,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.87083334,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.9291667,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9527778,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9763889,"top":0.027777778,"width":0.023611112,"height":0.035555556},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.7013889,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"169","depth":4,"bounds":{"left":0.7222222,"top":0.3122222,"width":0.025,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.7513889,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"102","depth":4,"bounds":{"left":0.7722222,"top":0.3122222,"width":0.025,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.80138886,"top":0.3122222,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.8215278,"top":0.31,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.8368056,"top":0.31,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\nnamespace Jiminny\\Models;\n\nuse Carbon\\Carbon;\nuse Database\\Factories\\ActivityFactory;\nuse DateTimeInterface;\nuse Exception;\nuse Illuminate\\Contracts\\Auth\\Authenticatable;\nuse Illuminate\\Database\\Eloquent;\nuse Illuminate\\Database\\Eloquent\\Attributes\\Scope;\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse Illuminate\\Database\\Eloquent\\Factories\\Factory;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasManyThrough;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasOne;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Auth;\nuse InvalidArgumentException;\nuse Jiminny\\Component\\ElasticSearch;\nuse Jiminny\\Component\\MeetingBot;\nuse Jiminny\\Component\\Model\\BitwiseFlagTrait;\nuse Jiminny\\Component\\PlaybackPage\\Comments\\Services\\ActivityCommentService;\nuse Jiminny\\Component\\Sidekick\\SidekickService;\nuse Jiminny\\Component\\Uuid\\UuidAwareInterface;\nuse Jiminny\\Component\\Workflow;\nuse Jiminny\\Contracts;\nuse Jiminny\\Contracts\\Crm\\ProspectInterface;\nuse Jiminny\\DTO\\ImportCall\\Call;\nuse Jiminny\\Events\\Activities\\ActivityTypeUpdated;\nuse Jiminny\\Events\\Activities\\ActivityUpdated;\nuse Jiminny\\Events\\Activities\\ProspectUpdated;\nuse Jiminny\\Events\\Activities\\StageUpdated;\nuse Jiminny\\Events\\Activities\\StatusUpdated;\nuse Jiminny\\Events\\Activities\\TitleUpdated;\nuse Jiminny\\Exceptions\\InvalidArgumentException as InvalidArgumentJiminnyException;\nuse Jiminny\\Exceptions\\LogicException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Activity\\ActivitySummaryLog;\nuse Jiminny\\Models\\Activity\\ActivityUploadSetting;\nuse Jiminny\\Models\\Activity\\AvailabilityNotification;\nuse Jiminny\\Models\\Activity\\CoachRequest;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\Activity\\Log;\nuse Jiminny\\Models\\Activity\\Message;\nuse Jiminny\\Models\\Activity\\Moment;\nuse Jiminny\\Models\\Activity\\Note;\nuse Jiminny\\Models\\Activity\\ParticipantSpeech;\nuse Jiminny\\Models\\Activity\\Play;\nuse Jiminny\\Models\\Activity\\Question;\nuse Jiminny\\Models\\Activity\\Share;\nuse Jiminny\\Models\\Activity\\Snapshot;\nuse Jiminny\\Models\\Activity\\Stats;\nuse Jiminny\\Models\\Activity\\SubscriptionSet;\nuse Jiminny\\Models\\Activity\\TopicTrigger;\nuse Jiminny\\Models\\Activity\\Transcription;\nuse Jiminny\\Models\\Calendar\\CalendarEvent;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\FieldData;\nuse Jiminny\\Models\\ElasticSearch\\ActivityElasticSearchTrait;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Participant\\Connection;\nuse Jiminny\\Models\\Playlist\\Activity as PlaylistActivity;\nuse Jiminny\\Services\\Activity\\ActivityProviderRegistry;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataByStrategy;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverFactory;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverInterface;\nuse Jiminny\\Traits\\Enums;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Jiminny\\Utils\\CurrencyFormatter;\nuse NumberFormatter;\n\nuse function in_array;\n\n/**\n * Jiminny\\Models\\Activity\n *\n * @property null|int $auto_score filled from ES hydrator, not in DB!\n * @property-read Account|null $account\n * @property-read CalendarEvent|null $calendarEvent\n * @property-read Contact|null $contact\n * @property-read Lead|null $lead\n * @property-read Opportunity|null $opportunity\n * @property-read Stage|null $stage\n * @property int $id\n * @property mixed|null $uuid\n * @property string|null $source\n * @property string|null $external_id\n * @property string $provider\n * @property string|null $location\n * @property string|null $telephony_provider_id\n * @property int|null $from_participant_id\n * @property int|null $to_participant_id\n * @property int|null $device_id\n * @property string|null $type\n * @property int|null $playbook_category_id\n * @property int $user_id\n * @property int|null $lead_id\n * @property int|null $account_id\n * @property int|null $contact_id\n * @property int|null $opportunity_id\n * @property int|null $stage_id\n * @property string|null $value\n * @property int|null $crm_configuration_id\n * @property string|null $crm_provider_id\n * @property string|null $language\n * @property int|null $transcription_id\n * @property int $duration\n * @property string $status\n * @property int|null $on_air\n * @property int|null $calendar_event_id\n * @property string $recording_state\n * @property bool|null $recording_preference\n * @property int $recording_reason_code\n * @property int $summary_reminder_sent\n * @property \\Illuminate\\Support\\Carbon|null $log_reminder_sent_at\n * @property \\Illuminate\\Support\\Carbon|null $organizer_notified_at\n * @property bool|null $has_recording_prompt\n * @property bool $is_internal\n * @property int $is_locked\n * @property int $is_recording\n * @property bool|null $is_processed\n * @property bool $is_private\n * @property bool $is_instant_invite\n * @property string|null $poster_path\n * @property string|null $summary\n * @property string|null $title\n * @property string|null $description\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_start_time\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_end_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_start_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_end_time\n * @property int|null $uploaded_by\n * @property \\Illuminate\\Support\\Carbon|null $deleted_at\n * @property \\Illuminate\\Support\\Carbon|null $created_at\n * @property \\Illuminate\\Support\\Carbon|null $updated_at\n * @property string|null $average_score\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $activeParticipants\n * @property-read int|null $active_participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers\n * @property-read int|null $activity_scorecard_rule_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRule> $activityScorecardRules\n * @property-read int|null $activity_scorecard_rules_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, AvailabilityNotification> $availabilityNotifications\n * @property-read int|null $availability_notifications_count\n * @property-read \\Jiminny\\Models\\PlaybookCategory|null $category\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, CoachRequest> $coachRequests\n * @property-read int|null $coach_requests_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $coachingFeedbacks\n * @property-read int|null $coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $coachingMessages\n * @property-read int|null $coaching_messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $comments\n * @property-read int|null $comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Connection> $connections\n * @property-read int|null $connections_count\n * @property-read Configuration|null $crm\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, FieldData> $data\n * @property-read int|null $data_count\n * @property-read \\Jiminny\\Models\\Device|null $device\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $favoritePlaylists\n * @property-read int|null $favorite_playlists_count\n * @property-read \\Jiminny\\Models\\Participant|null $from\n * @property-read string|null $activity_title\n * @property-read mixed $comment_count\n * @property-read mixed $duration_for_humans\n * @property-read string $duration_for_humans_short\n * @property-read int $favorite_count\n * @property-read mixed $favorites_count\n * @property-read mixed $formatted_value\n * @property-read string $id_string\n * @property-read \\Jiminny\\Models\\Participant|null $organizer\n * @property-read mixed $play_count\n * @property-read int|null $plays_count\n * @property-read ?ProspectInterface $prospect\n * @property-read string|null $prospect_name\n * @property-read mixed $prospect_type\n * @property-read mixed $share_count\n * @property-read int|null $shares_count\n * @property-read int|null $tracks_with_telephony_count\n * @property-read int|null $visible_comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $latestCoachingFeedbacks\n * @property-read int|null $latest_coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Log> $logs\n * @property-read int|null $logs_count\n * @property-read \\Jiminny\\Models\\Track|null $masterTrack\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $messages\n * @property-read int|null $messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Moment> $moments\n * @property-read int|null $moments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Note> $notes\n * @property-read int|null $notes_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\Share> $participantShares\n * @property-read int|null $participant_shares_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, ParticipantSpeech> $participantSpeeches\n * @property-read int|null $participant_speeches_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\ParticipantStats> $participantStats\n * @property-read int|null $participant_stats_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $participants\n * @property-read int|null $participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, PlaylistActivity> $playlistActivities\n * @property-read int|null $playlist_activities_count\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $playlists\n * @property-read int|null $playlists_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Play> $plays\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Question> $questions\n * @property-read int|null $questions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Session> $sessions\n * @property-read int|null $sessions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Share> $shares\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Snapshot> $snapshots\n * @property-read int|null $snapshots_count\n * @property-read Stats|null $stats\n * @property-read \\Jiminny\\Models\\Participant|null $to\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, TopicTrigger> $topicTriggers\n * @property-read int|null $topic_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracks\n * @property-read int|null $tracks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracksWithTelephony\n * @property-read Transcription|null $transcription\n * @property-read \\Jiminny\\Models\\User $user\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $visibleComments\n *\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> all($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)\n * @method static \\Database\\Factories\\ActivityFactory factory(...$parameters)\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> get($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity heldBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity idOrUuId($idOrUuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newModelQuery()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newQuery()\n * @method static Builder|Activity onlyTrashed()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity query()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity scheduledBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity inOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity notInOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity forTeam(int $teamId)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity uuid(string $uuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAccountId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAverageScore($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCalendarEventId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereContactId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCreatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmConfigurationId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeletedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDescription($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeviceId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDuration($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereFromParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereHasRecordingPrompt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInstantInvite($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInternal($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsLocked($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsPrivate($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsProcessed($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsRecording($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLanguage($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLeadId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLocation($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLogReminderSentAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOnAir($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOpportunityId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOrganizerNotifiedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePlaybookCategoryId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePosterPath($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereProvider($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingPreference($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingReasonCode($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingState($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSource($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereExternalId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStageId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStatus($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummary($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummaryReminderSent($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTelephonyProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTitle($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereToParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTranscriptionId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereType($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUpdatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUploadedBy($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUserId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUuid($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereValue($value)\n * @method static Builder|Activity withTrashed()\n * @method static Builder|Activity withoutTrashed()\n *\n * @mixin \\Eloquent\n */\nclass Activity extends Model implements\n ElasticSearch\\Contract\\Searchable,\n Workflow\\Workflow\\WorkflowAwareInterface,\n Models\\Contracts\\ActivityContract,\n Contracts\\Model\\ActivityInterface,\n UuidAwareInterface\n{\n use HasFactory;\n\n use Enums;\n use SoftDeletes;\n use RequiresUUID;\n use BitwiseFlagTrait;\n use ElasticSearch\\Model\\Searchable;\n use ActivityElasticSearchTrait;\n\n use Workflow\\Workflow\\WorkflowAware {\n transitionTo as traitTransitionTo;\n }\n\n public const int FLAG_RECORDING_REASON_DEFAULT = 0;\n\n // Recording Prompted but never started\n public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;\n public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;\n\n // Recording Disabled by Organization\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;\n\n // Recording was restricted to one-side recordings only\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;\n\n // Recording was not started because it was internal and team setting disabled that.\n public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;\n\n // Recording was not started because it was internal and user setting disabled that.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;\n\n // Recording was not started because user setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;\n\n // Recording was not started because team setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;\n\n // Recording was not started because user has overriden default.\n public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;\n\n // Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;\n\n // Recording was not started because their team setting does excludes the meeting type.\n public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;\n\n // Recording was not started because the external provider disabled it (or recording is missing etc).\n public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;\n\n // Recording was stopped externally (\"exit-meeting\" Pusher event)\n public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;\n\n // Recording couldn't be started due to Zoom hosting conflict error\n public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;\n\n // meeting.failed event with reason code BOT_DENIED_FROM_LOBBY\n public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;\n\n // meeting.failed event with reason code LOBBY_TIMEOUT\n public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;\n\n // meeting.failed event with reason code BOT_KICKED\n public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;\n\n // meeting.failed event with reason code UNKNOWN\n public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;\n\n public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;\n\n // Invalid meeting (e.g. URL is invalid, or the meeting is not found)\n public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;\n\n // The host stopped the recording.\n public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;\n\n // Recording was not started because an alternative vendor disabled it (or overrode it).\n public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;\n\n // Login required meeting.failed code\n public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;\n\n // Password for meeting was not provided - meeting.failed code\n public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;\n\n // meeting.failed - when the meeting is locked\n public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;\n\n // max recording duration reached\n public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;\n\n // recording size is too small\n public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;\n\n // meeting.failed - when bot is redirected to sign in page multiple times\n public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;\n\n // meeting.failed event with reason code CONNECTION_LOST\n public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;\n\n // recording is corrupted.\n public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;\n\n // meeting ended in lobby\n public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;\n\n // meeting not started\n public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;\n\n // unfinished zoom custom disclaimer\n public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;\n\n // recording download failed - server error\n public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;\n\n // recording download failed - client code 404\n public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;\n\n // recording download failed - client code 401, 403\n public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;\n\n // recording download failed - client code 429\n public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;\n\n // recording download failed - unknown client error\n public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;\n\n // recording download failed - unknown error\n public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;\n\n // It has been setup ahead of time through calendar\n public const string STATUS_SCHEDULED = 'scheduled';\n\n // It is awaiting audio.\n public const string STATUS_PENDING = 'pending';\n\n // Participant(s) dialed in, awaiting organizer.\n public const string STATUS_RINGING = 'ringing';\n\n // Call is in progress.\n public const string STATUS_IN_PROGRESS = 'in-progress';\n\n // It has ended.\n public const string STATUS_COMPLETED = 'completed';\n\n // Cancelled prior to starting.\n public const string STATUS_CANCELLED = 'canceled';\n\n public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference\n\n public const string STATUS_STARTING_SOON = 'starting-soon';\n\n public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';\n\n public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';\n\n public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';\n\n // When bot instance is waiting in lobby\n public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';\n\n public const string STATUS_BUSY = 'busy';\n public const string STATUS_NO_ANSWER = 'no-answer';\n public const string STATUS_FAILED = 'failed'; // Used by SMS too\n\n // SMS related\n public const string STATUS_ACCEPTED = 'accepted';\n public const string STATUS_QUEUED = 'queued';\n public const string STATUS_SENDING = 'sending';\n public const string STATUS_SENT = 'sent';\n public const string STATUS_DELIVERED = 'delivered';\n public const string STATUS_UNDELIVERED = 'undelivered';\n public const string STATUS_RECEIVING = 'receiving';\n public const string STATUS_RECEIVED = 'received';\n public const string STATUS_RESENT = 'resent';\n\n public const array SMS_STATUSES = [\n Activity::STATUS_RECEIVED,\n Activity::STATUS_SENT,\n Activity::STATUS_DELIVERED,\n ];\n\n public const array SOFT_PHONE_CONFERENCE_STATUSES = [\n Activity::STATUS_IN_PROGRESS,\n Activity::STATUS_COMPLETED,\n ];\n\n // @todo refactor prefix from `TYPE_` to `CHANNEL_`\n public const string TYPE_SOFTPHONE = 'softphone';\n public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';\n public const string TYPE_CONFERENCE = 'conference';\n public const string TYPE_SMS_INBOUND = 'sms-inbound';\n public const string TYPE_SMS_OUTBOUND = 'sms-outbound';\n public const string TYPE_EMAIL_INBOUND = 'email-inbound';\n public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';\n\n public const array CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n public const array PLAYABLE_CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n ];\n\n // Recording States\n public const string RECORDING_OFF = 'off'; // Default state\n public const string RECORDING_IN_PROGRESS = 'in-progress';\n public const string RECORDING_PAUSED = 'paused';\n public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.\n public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.\n public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.\n\n // Live Stream States\n public const int ON_AIR_DEFAULT = 0;\n public const int ON_AIR_READY = 1;\n public const int ON_AIR_PREPARING = 2;\n public const int ON_AIR_STREAMING = 3;\n public const int ON_AIR_FINISHED = 4;\n public const int ON_AIR_NOT_STREAMED = 5;\n public const int ON_AIR_ERROR = -1;\n\n public const string SOURCE_GONG = 'gong';\n public const string SOURCE_CHORUS = 'chorus';\n public const string SOURCE_OUTLOOK = 'outlook';\n public const string SOURCE_GOOGLE = 'google';\n\n // Activity Providers\n public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.\n public const string PROVIDER_OUTREACH = 'outreach';\n public const string PROVIDER_ZOOM_BOT = 'zoom-bot';\n public const string PROVIDER_SALESLOFT = 'salesloft';\n public const string PROVIDER_GOOGLE = 'google';\n public const string PROVIDER_AIRCALL = 'aircall';\n public const string PROVIDER_JUSTCALL = 'justcall';\n public const string PROVIDER_GOOGLE_MEET = 'google-meet';\n public const string PROVIDER_GONG = 'gong';\n public const string PROVIDER_HUBSPOT = 'hubspot';\n public const string PROVIDER_CLOSE = 'close';\n public const string PROVIDER_TEAMS = 'ms-teams';\n public const string PROVIDER_SALESFORCE = 'salesforce';\n public const string PROVIDER_GROOVE = 'groove';\n public const string PROVIDER_XANT = 'xant';\n public const string PROVIDER_OFFICE = 'office';\n public const string PROVIDER_NATTERBOX = 'natterbox';\n public const string PROVIDER_RINGCENTRAL = 'ringcentral';\n public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';\n public const string PROVIDER_GOTOMEETING = 'go-to-meeting';\n public const string PROVIDER_DEMODESK = 'demo-desk';\n public const string PROVIDER_DIALPAD = 'dialpad';\n public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';\n public const string PROVIDER_CLOUDCALL = 'cloudcall';\n public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';\n public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // \"8x8\" UK\n public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // \"8x8\" Canada\n public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // \"8x8\" Australia\n public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // \"8x8\" US East\n public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // \"8x8\" US West\n public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';\n public const string PROVIDER_CLOUD_TALK = 'cloud-talk';\n public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';\n public const string PROVIDER_VONAGE = 'vonage';\n public const string PROVIDER_MIGRATOR = 'migrator';\n public const string PROVIDER_UPLOADER = 'uploader';\n public const string PROVIDER_TALKDESK = 'talkdesk';\n public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';\n public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';\n public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';\n public const string PROVIDER_AVAYA = 'avaya';\n public const string PROVIDER_TELUS = 'telus';\n public const string PROVIDER_FIVE_NINE = 'five-nine';\n public const string PROVIDER_APOLLO = 'apollo';\n public const string PROVIDER_ORUM = 'orum';\n public const string PROVIDER_BLOOBIRDS = 'bloobirds';\n\n /**\n * @const API_PROVIDERS\n * A list of integrations that import calls via API instead of webhooks\n */\n public const array API_PROVIDERS = [\n self::PROVIDER_OUTREACH,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n ];\n\n public const array FINITE_STATES = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,\n ];\n\n public const array FINITE_STATES_CONFERENCE = [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_CANCELLED,\n ];\n\n public const array MEETING_BOT_JOIN_ATTEMPTED = [\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_BOT_INSTANCE_STARTED,\n ];\n\n public static array $enumStatuses = [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_ACCEPTED,\n self::STATUS_QUEUED,\n self::STATUS_SENDING,\n self::STATUS_SENT,\n self::STATUS_RESENT,\n self::STATUS_DELIVERED,\n self::STATUS_UNDELIVERED,\n self::STATUS_RECEIVING,\n self::STATUS_RECEIVED,\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_STARTING_SOON,\n self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,\n self::STATUS_BOT_INSTANCE_STARTED,\n self::STATUS_DUPLICATED,\n ];\n\n public static array $enumProviders = [\n self::PROVIDER_TWILIO,\n self::PROVIDER_OUTREACH,\n self::PROVIDER_ZOOM_BOT,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_AIRCALL,\n self::PROVIDER_JUSTCALL,\n self::PROVIDER_GOOGLE_MEET,\n self::PROVIDER_GONG,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_CLOSE,\n self::PROVIDER_TEAMS,\n self::PROVIDER_SALESFORCE,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_GOOGLE,\n self::PROVIDER_OFFICE,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_RINGCENTRAL_VIDEO,\n self::PROVIDER_GOTOMEETING,\n self::PROVIDER_DEMODESK,\n self::PROVIDER_DIALPAD,\n self::PROVIDER_ZOOM_PHONE,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n ];\n\n public static $enumRecordingStates = [\n self::RECORDING_OFF, // Default state\n self::RECORDING_IN_PROGRESS,\n self::RECORDING_PAUSED,\n self::RECORDING_STOPPED,\n self::RECORDING_RECORDED,\n self::RECORDING_FAILED,\n ];\n\n // @Important:\n // This collection is not used anywhere, and is fully duplicated by the Channels const.\n // Validate if it is referred somehow via the enum trait, and if not, remove it entirely.\n // An even better strategy will be to move all those constants to a dedicated class\n protected array $enumTypes = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n protected static $enumFailedStatuses = [\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n self::STATUS_CANCELLED,\n ];\n\n protected $table = 'activities';\n\n protected $fillable = [\n // Type of activity.\n 'type', // @todo refactor to `channel`\n // The activity type.\n 'playbook_category_id',\n // User who hosts the activity.\n 'user_id',\n // Related Lead record (if applicable)\n 'lead_id',\n // Related Account record (if applicable)\n 'account_id',\n // Related Contact record (if applicable)\n 'contact_id',\n // Related Opportunity record (if applicable)\n 'opportunity_id',\n // Stage of activity.\n 'stage_id',\n // Value of opportunity.\n 'value',\n // If the activity relates to a CRM task.\n 'crm_provider_id',\n // If the activity was created through an external device.\n 'device_id',\n // the activity's language code\n 'language',\n // transcription id\n 'transcription_id',\n // Duration of the call, with microseconds precision.\n 'duration',\n // One of enumStatuses above.\n 'status',\n // Have we reminded them to log the call?\n 'log_reminder_sent_at',\n // If activity is private or inter-org, flagged here.\n 'is_internal',\n // Managers and above can mark a call as private, to exclude it from other team members\n 'is_private',\n 'is_processed',\n // Boolean for this activity being instant invite handled.\n 'is_instant_invite',\n // If activity is in recording state, flagged here.\n 'recording_state',\n // If activity recording is overidden from default.\n 'recording_preference',\n // if recording did (not) happen, why that is\n 'recording_reason_code',\n // Average score, updated during\n 'average_score',\n // Summary that the organizer has taken after the call.\n 'summary',\n // Subject of the activity, usually taken from calendar event.\n 'title',\n // Description of the activity, usually taken from calendar event.\n 'description',\n // Start time, usually taken from calendar event.\n 'scheduled_start_time',\n // End time, usually taken from calendar event.\n 'scheduled_end_time',\n // When the call actually started.\n 'actual_start_time',\n // When the call actually ended.\n 'actual_end_time',\n // SMS: Message reference\n 'telephony_provider_id',\n // SMS: Participant who sent message\n 'from_participant_id',\n // SMS: Participant who should receive the message\n 'to_participant_id',\n // When an external guest joins an organizers meeting room and the organizer is not present,\n // send them an SMS notification that someone has joined.\n 'organizer_notified_at',\n // where was the activity imported from\n 'source',\n // The id in the source system (e.g. the bot id in Recall.ai)\n 'external_id',\n // The provider, by default it is twilio.\n 'provider',\n // Meeting location url\n 'location',\n // The snapshot for displaying a poster image.\n 'poster_path',\n 'crm_configuration_id',\n // If there is an automated message that the conversation is being recorded\n 'has_recording_prompt',\n // If the activity is being live-streamed\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected $appends = [\n 'id_string',\n 'organizer',\n ];\n\n protected $hidden = [\n 'uuid',\n ];\n\n protected $visible = [\n 'id_string',\n 'type',\n 'duration',\n 'average_score',\n 'status',\n 'log_reminder_sent_at',\n 'title',\n 'description',\n 'is_internal',\n 'scheduled_start_time',\n 'scheduled_end_time',\n 'actual_start_time',\n 'actual_end_time',\n 'user',\n 'category',\n 'account',\n 'contact',\n 'opportunity',\n 'lead',\n 'stage',\n 'stats',\n 'participants',\n 'playlists',\n 'tracks',\n 'comments',\n 'plays',\n 'coachingFeedbacks',\n 'shares',\n 'favorites',\n 'language',\n 'transcription',\n 'is_private',\n 'is_instant_invite',\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'scheduled_start_time' => 'datetime',\n 'scheduled_end_time' => 'datetime',\n 'actual_start_time' => 'datetime',\n 'actual_end_time' => 'datetime',\n 'organizer_notified_at' => 'datetime',\n 'log_reminder_sent_at' => 'datetime',\n 'is_internal' => 'boolean',\n 'duration' => 'integer',\n 'average_score' => 'decimal:2',\n 'is_private' => 'boolean',\n 'is_processed' => 'boolean',\n 'is_instant_invite' => 'boolean',\n 'value' => 'decimal:2',\n 'recording_preference' => 'boolean',\n 'recording_reason_code' => 'integer',\n 'has_recording_prompt' => 'boolean',\n 'on_air' => 'integer',\n ];\n }\n\n protected static function boot()\n {\n parent::boot();\n\n static::updated(static function (Activity $activity) {\n // If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week\n if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||\n ($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {\n if ($activity->isDirty('status')) {\n event(new StatusUpdated($activity));\n }\n\n if ($activity->isDirty('stage_id')) {\n event(new StageUpdated($activity));\n }\n\n if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {\n event(new ProspectUpdated($activity));\n }\n\n if ($activity->isDirty('opportunity_id')) {\n event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));\n }\n\n if ($activity->isDirty('title')) {\n event(new TitleUpdated($activity));\n }\n }\n\n if ($activity->isDirty('playbook_category_id')) {\n event(new ActivityTypeUpdated($activity));\n }\n });\n\n static::deleted(static function (Activity $activity) {\n // Hard delete associated playlistActivities\n $activity->playlistActivities()->delete();\n });\n }\n\n public function getOrganizerAttribute(): ?Participant\n {\n $participant = $this->participants()->where('user_id', $this->user_id)->first();\n\n if (! $participant instanceof Participant && $participant !== null) {\n throw new RuntimeException(sprintf('$participant must be an instance of \"%s\" or null', Participant::class));\n }\n\n return $participant;\n }\n\n public function getFormattedValueAttribute()\n {\n $currencyCode = 'USD';\n if ($this->opportunity) {\n $currencyCode = $this->opportunity->getCurrencyCode();\n }\n\n $formatter = new CurrencyFormatter();\n $formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);\n $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);\n\n return $formatter->format($this->value, $currencyCode);\n }\n\n public function getProspectNameAttribute(): ?string\n {\n $prospectName = null;\n\n if ($this->lead_id) {\n $prospectName = $this->lead->name;\n } elseif ($this->contact_id) {\n $prospectName = $this->contact->name;\n } elseif ($this->account_id) {\n $prospectName = $this->account->name;\n }\n\n return $prospectName;\n }\n\n public function getProspectName(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('prospect_name');\n }\n\n /**\n * Get activity title depending on prospect or title\n */\n public function getActivityTitleAttribute(): ?string\n {\n $activityTitle = null;\n if ($this->prospect && $this->prospect->getName()) {\n if ($this->account_id) {\n $activityTitle = $this->account->name;\n } elseif ($this->lead_id) {\n $activityTitle = $this->lead->company;\n } elseif ($this->contact_id) {\n $activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;\n }\n } elseif ($this->title) {\n $activityTitle = $this->title;\n }\n\n return $activityTitle;\n }\n\n public function wasRecentlyCreated(): bool\n {\n return $this->wasRecentlyCreated;\n }\n\n public function getProspectTypeAttribute()\n {\n $prospectType = null;\n\n if ($this->lead_id) {\n $prospectType = 'Lead';\n } elseif ($this->contact_id) {\n $prospectType = 'Contact';\n } elseif ($this->account_id) {\n $prospectType = 'Account';\n }\n\n return $prospectType;\n }\n\n /**\n * Return the best match for prospect. Results are in the following order of priority:\n * 1. Lead\n * 2. Contact\n * 3. Account\n * 4. NULL\n */\n public function getProspectAttribute(): ?ProspectInterface\n {\n if ($this->hasLead()) {\n return $this->getLead();\n }\n\n if ($this->hasContact()) {\n return $this->getContact();\n }\n\n if ($this->hasAccount()) {\n return $this->getAccount();\n }\n\n return null;\n }\n\n public function getTitleAttribute($value): ?string\n {\n return \\getActivityTitleAttribute(\n $this->user->name,\n $this->getType(),\n $value,\n $this->prospect->name ?? null,\n $this->from->national_phone_number ?? null\n );\n }\n\n public function getTitle(): ?string\n {\n return $this->getAttribute('title');\n }\n\n public function getSummary(): ?string\n {\n return $this->getAttribute('summary');\n }\n\n public function isInternal(): bool\n {\n return $this->getAttribute('is_internal');\n }\n\n public function getIsPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n public function getDescription(): ?string\n {\n return $this->getAttribute('description');\n }\n\n public function hasTitle(): bool\n {\n return $this->getOriginal('title') !== null;\n }\n\n public function getPlayCountAttribute()\n {\n return $this->getPlaysCountAttribute();\n }\n\n public function getPlaysCountAttribute()\n {\n if (! isset($this->attributes['plays_count'])) {\n $this->loadCount('plays');\n }\n\n return $this->attributes['plays_count'];\n }\n\n public function getCommentCountAttribute()\n {\n return $this->getCommentsCountAttribute();\n }\n\n public function getCommentsCountAttribute()\n {\n if (! isset($this->attributes['comments_count'])) {\n $this->loadCount('comments');\n }\n\n return $this->attributes['comments_count'];\n }\n\n public function getVisibleCommentsCountAttribute()\n {\n if (! isset($this->attributes['visible_comments_count'])) {\n $activityCommentsService = app(ActivityCommentService::class);\n $user = Auth::user() instanceof User ? Auth::user() : null;\n $this->attributes['visible_comments_count'] = $activityCommentsService\n ->getVisibleCommentsCount($this, $user);\n }\n\n return $this->attributes['visible_comments_count'];\n }\n\n public function getShareCountAttribute()\n {\n return $this->getSharesCountAttribute();\n }\n\n public function getSharesCountAttribute()\n {\n if (! isset($this->attributes['shares_count'])) {\n $this->loadCount('shares');\n }\n\n return $this->attributes['shares_count'];\n }\n\n\n /**\n * Get the count of favorites playlists this activity appears in\n */\n public function getFavoriteCountAttribute(): int\n {\n return $this->getFavoritesCountAttribute();\n }\n\n public function getFavoritesCountAttribute()\n {\n if (! isset($this->attributes['favorites_count'])) {\n $this->loadCount('favorites');\n }\n\n return $this->attributes['favorites_count'];\n }\n\n public function getActiveParticipantsCountAttribute()\n {\n if (! isset($this->attributes['active_participants_count'])) {\n $this->loadCount('activeParticipants');\n }\n\n return $this->attributes['active_participants_count'];\n }\n\n public function getTracksWithTelephonyCountAttribute()\n {\n if (! isset($this->attributes['tracks_with_telephony_count'])) {\n $this->loadCount('tracksWithTelephony');\n }\n\n return $this->attributes['tracks_with_telephony_count'];\n }\n\n /**\n * @TEMP\n * $this->loadCount('tracksWithTelephony') throws null pointer exception\n */\n public function countTracksWithTelephony(): int\n {\n return $this->tracks()->whereNotNull('telephony_provider_id')->count();\n }\n\n public function getDuration(): float\n {\n return $this->getAttribute('duration');\n }\n\n public function getDurationForHumansAttribute()\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);\n }\n\n public function getDurationForHumansShortAttribute(): string\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);\n }\n\n public function hasRecordingPreference(): bool\n {\n return $this->getAttribute('recording_preference') !== null;\n }\n\n public function getRecordingPreference()\n {\n return $this->getAttribute('recording_preference');\n }\n\n /** @return BelongsTo<User, self> */\n public function user(): BelongsTo\n {\n return $this->belongsTo(User::class)->with('group');\n }\n\n public function device()\n {\n return $this->belongsTo(Device::class);\n }\n\n public function category()\n {\n return $this->belongsTo(PlaybookCategory::class, 'playbook_category_id');\n }\n\n public function getCategory(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function getPlaybookCategoryId(): ?int\n {\n return $this->getAttribute('playbook_category_id');\n }\n\n public function hasStats(): bool\n {\n return $this->getAttribute('stats') !== null;\n }\n\n public function getStats(): ?Stats\n {\n return $this->getAttribute('stats');\n }\n\n public function stats(): HasOne\n {\n return $this->hasOne(Stats::class);\n }\n\n public function participantStats(): Eloquent\\Relations\\HasManyThrough\n {\n return $this->hasManyThrough(\n Models\\Participant\\ParticipantStats::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantStats(): Eloquent\\Collection\n {\n return $this->getAttribute('participantStats');\n }\n\n public function account()\n {\n return $this->belongsTo(Account::class);\n }\n\n public function contact()\n {\n return $this->belongsTo(Contact::class)->with(['account']);\n }\n\n public function lead()\n {\n return $this->belongsTo(Lead::class)->with(['stage', 'recordType']);\n }\n\n /**\n * @return BelongsTo<Opportunity, self>\n */\n public function opportunity(): BelongsTo\n {\n /** @var BelongsTo<Opportunity, self> */\n return $this->belongsTo(Opportunity::class);\n }\n\n public function stage()\n {\n return $this->belongsTo(Stage::class);\n }\n\n /**\n * @return HasMany<Session>\n */\n public function sessions(): HasMany\n {\n return $this->hasMany(Session::class);\n }\n\n /**\n * @return HasMany|ParticipantSpeech[]|Eloquent\\Collection\n */\n public function participantSpeeches()\n {\n return $this->hasMany(ParticipantSpeech::class);\n }\n\n public function getParticipantSpeeches(): Eloquent\\Collection\n {\n return $this->getAttribute('participantSpeeches');\n }\n\n /**\n * @return HasMany|Log[]|Eloquent\\Collection\n */\n public function logs()\n {\n return $this->hasMany(Log::class);\n }\n\n /**\n * @return HasMany|Moment[]|Eloquent\\Collection\n */\n public function moments()\n {\n return $this->hasMany(Moment::class);\n }\n\n /**\n * @return HasMany|Note[]|Eloquent\\Collection\n */\n public function notes()\n {\n return $this->hasMany(Note::class);\n }\n\n /**\n * @return Eloquent\\Collection|Note[]\n */\n public function getNotes(): Eloquent\\Collection\n {\n return $this->getAttribute('notes');\n }\n\n /**\n * @return HasMany|Message[]|Eloquent\\Collection\n */\n public function messages()\n {\n return $this->hasMany(Message::class);\n }\n\n public function coachingMessages(): HasMany\n {\n return $this->hasMany(Message::class)\n ->where('is_private', 1);\n }\n\n public function getCoachingMessages(): Eloquent\\Collection\n {\n return $this->getAttribute('coachingMessages');\n }\n\n public function participants(): HasMany\n {\n return $this->hasMany(Participant::class);\n }\n\n public function getSnapshots(): Eloquent\\Collection\n {\n return $this->getAttribute('snapshots');\n }\n\n /** @return HasMany<Track> */\n public function tracks(): HasMany\n {\n return $this->hasMany(Track::class);\n }\n\n public function tracksWithTelephony(): HasMany\n {\n return $this->hasMany(Track::class)->whereNotNull('telephony_provider_id');\n }\n\n public function getTracksWithTelephony(): Eloquent\\Collection\n {\n return $this->getAttribute('tracksWithTelephony');\n }\n\n /** @return Collection|Track[] */\n public function getTracks(): Eloquent\\Collection\n {\n return $this->getAttribute('tracks');\n }\n\n public function masterTrack(): HasOne\n {\n return $this->hasOne(Track::class)->where('is_master', 1)\n ->whereIn('format', [Track::FORMAT_WAV, Track::FORMAT_M3U8])\n ->latest();\n }\n\n public function getMasterTrack(): ?Track\n {\n /** @var Track|null */\n return $this->getAttribute('masterTrack');\n }\n\n public function transcription(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Transcription::class, 'transcription_id');\n }\n\n public function findTranscriptionPromptSummaries(): Collection\n {\n $transcriptionId = $this->getTranscriptionId();\n if (is_null($transcriptionId)) {\n return new Collection();\n }\n\n return Models\\AiPrompt::query()\n ->where('transcription_id', $transcriptionId)\n ->get();\n }\n\n public function getTranscription(): Transcription\n {\n return $this->getAttribute('transcription');\n }\n\n public function hasTranscription(): bool\n {\n return $this->getAttribute('transcription') !== null;\n }\n\n public function setTranscriptionId(int $transcriptionId): Activity\n {\n $this->setAttribute('transcription_id', $transcriptionId);\n\n return $this;\n }\n\n public function unsetTranscriptionId(): self\n {\n $this->setAttribute('transcription_id', null);\n\n return $this;\n }\n\n public function getTranscriptionId(): ?int\n {\n return $this->getAttribute('transcription_id');\n }\n\n /** @deprecated */\n public function hasTranscriptionId(): bool\n {\n return $this->getAttribute('transcription_id') !== null;\n }\n\n public function coachRequests()\n {\n return $this->hasMany(CoachRequest::class);\n }\n\n public function availabilityNotifications()\n {\n return $this->hasMany(AvailabilityNotification::class);\n }\n\n public function processingStates()\n {\n return $this->hasMany(Models\\Activity\\ActivityProcessingState::class);\n }\n\n public function uploadSettings()\n {\n return $this->hasMany(ActivityUploadSetting::class);\n }\n\n public function comments()\n {\n return $this->hasMany(Comment::class);\n }\n\n public function getComments(): Eloquent\\Collection\n {\n return $this->getAttribute('comments');\n }\n\n public function visibleComments()\n {\n $rel = $this->hasMany(Comment::class);\n // Doesn't have auth()->user() in some tests, breaks the build\n if ($user = auth()->user()) {\n return $rel->visibleThreads($user->id);\n }\n\n return $rel;\n }\n\n public function snapshots(): HasMany\n {\n return $this->hasMany(Snapshot::class);\n }\n\n public function calendarEvent()\n {\n return $this->belongsTo(CalendarEvent::class);\n }\n\n public function getCalendarEvent(): ?CalendarEvent\n {\n return $this->getAttribute('calendarEvent');\n }\n\n public function latestCoachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class)->latest();\n }\n\n public function playlists(): BelongsToMany\n {\n return $this->belongsToMany(Playlist::class, 'playlist_activities')\n ->withPivot('id', 'uuid', 'user_id', 'start_time', 'end_time')\n ->using(PlaylistActivity::class)\n ->withTimestamps();\n }\n\n public function coachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class);\n }\n\n /**\n * @return Eloquent\\Collection|CoachingFeedback[]\n */\n public function getCoachingFeedback(?int $visibility = null): Eloquent\\Collection\n {\n $feedbacks = $this->coachingFeedbacks();\n if ($visibility !== null) {\n $feedbacks = $feedbacks->where('visibility', $visibility);\n }\n\n return $feedbacks->get();\n }\n\n /** @return Eloquent\\Collection<int, PlaylistActivity> */\n public function favoritedBy(User $user): Eloquent\\Collection\n {\n return $this->favorites()->where('user_id', $user->getId())->get();\n }\n\n /**\n * Checks whether consumer has added this activity to their favorites playlist\n * In addition a default playlist gets created if not already present\n */\n public function wasFavoritedBy(User $user): bool\n {\n $playlist = $user->favoritePlaylist();\n\n return $playlist\n ->activities()\n ->where('activity_id', '=', $this->getId())\n ->exists();\n }\n\n /**\n * @return HasMany<PlaylistActivity>\n */\n public function playlistActivities(): HasMany\n {\n return $this->hasMany(PlaylistActivity::class);\n }\n\n /**\n * @return HasManyThrough<Playlist>\n */\n public function favoritePlaylists(): HasManyThrough\n {\n return $this->hasManyThrough(\n Playlist::class,\n PlaylistActivity::class,\n 'activity_id',\n 'id',\n 'id',\n 'playlist_id'\n )->where('is_default', 1);\n }\n\n /**\n * @return Eloquent\\Collection<int, Playlist>\n */\n public function getFavoritePlaylists(): Eloquent\\Collection\n {\n return $this->getAttribute('favoritePlaylists');\n }\n\n /**\n * Get activities from the default/favorite playlist\n *\n * @return Eloquent\\Builder|static\n */\n public function favorites()\n {\n return $this->playlistActivities()->whereHas('playlist', function ($query) {\n $query->where('is_default', 1);\n });\n }\n\n /**\n * @return Model|SubscriptionSet|null|object\n */\n public function subscribedBy(User $user)\n {\n if ($this->prospect === null) {\n return null;\n }\n\n return SubscriptionSet::select('activity_subscription_sets.*')\n ->where('user_id', $user->id)\n ->join('activity_subscriptions', function ($join) {\n $join\n ->on('subscription_set_id', '=', 'activity_subscription_sets.id');\n\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $join\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $join\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $join\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $join\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n }\n })\n ->first();\n }\n\n /**\n * @return array|Eloquent\\Builder[]|Eloquent\\Collection|SubscriptionSet[]\n */\n public function subscribers()\n {\n if ($this->prospect === null) {\n return [];\n }\n\n return SubscriptionSet::with(['subscriptions', 'user'])\n ->whereHas('subscriptions', function ($query) {\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $query\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $query\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $query\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $query\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n } else {\n // Nothing to join on?\n // refactor - use Jiminny specific exception\n throw new InvalidArgumentException('Cannot join on a specific customer filter.');\n }\n })\n ->whereHas('user', function ($query) {\n $query\n ->where('team_id', $this->user->team_id)\n ->where('status', User::STATUS_ACTIVE);\n })\n ->get();\n }\n\n /**\n * @return HasMany|Builder|Eloquent\\Collection|Play[]\n */\n public function plays()\n {\n return $this->hasMany(Play::class);\n }\n\n public function getPlays(): Eloquent\\Collection\n {\n return $this->getAttribute('plays');\n }\n\n public function playsBy(User $user)\n {\n /** @var Builder $builder */\n $builder = $this->plays()->where('user_id', $user->id);\n\n return $builder->get();\n }\n\n /**\n * Check if activity was played by a user\n */\n public function wasPlayedBy(User $user): bool\n {\n return $this->plays()->where('user_id', $user->id)->exists();\n }\n\n public function shares()\n {\n return $this->hasMany(Share::class);\n }\n\n /** @return BelongsTo<Participant, self> */\n public function from(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'from_participant_id');\n }\n\n /** @return BelongsTo<Participant, self> */\n public function to(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'to_participant_id');\n }\n\n /**\n * Get all of the connections through the participants.\n */\n public function connections()\n {\n return $this->hasManyThrough(\n Connection::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getConnections(): Eloquent\\Collection\n {\n return $this->getAttribute('connections');\n }\n\n /**\n * Get all of the shares through the participants.\n */\n public function participantShares()\n {\n return $this->hasManyThrough(\n Participant\\Share::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantShares(): Eloquent\\Collection\n {\n return $this->getAttribute('participantShares');\n }\n\n public function topicTriggers(): HasMany\n {\n return $this->hasMany(TopicTrigger::class);\n }\n\n public function activityScorecardRuleTriggers(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRuleTrigger::class);\n }\n\n public function activityScorecardRules(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRule::class);\n }\n\n public function questions(): HasMany\n {\n return $this->hasMany(Question::class);\n }\n\n /**\n * Get all the custom data attached to it.\n */\n public function data(): HasMany\n {\n return $this->hasMany(FieldData::class);\n }\n\n public function getData(): Eloquent\\Collection\n {\n /** @var Eloquent\\Collection */\n return $this->getAttribute('data');\n }\n\n #[Scope]\n protected function heldBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('actual_start_date', '>=', $from)\n ->where('actual_end_date', '<=', $until);\n }\n\n #[Scope]\n protected function scheduledBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('scheduled_start_date', '>=', $from)\n ->where('scheduled_end_date', '<=', $until);\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function forTeam(Builder $query, int $teamId): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas('user', static function (Builder $query) use ($teamId): void {\n $query->where('team_id', $teamId);\n });\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function inOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query\n ->where('is_closed', false)\n ->where('deleted_at', '=', null),\n );\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function notInOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->where(\n static fn (Builder $query): Builder => $query->whereNull('opportunity_id')\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->where('is_closed', true),\n )\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->withTrashed()->where('deleted_at', '!=', null),\n ),\n );\n }\n\n /**\n * Finds a participant and updates it with data. If participant doesn't exist creates a new participant from data.\n *\n * @param array $data participant data used to identify the participant and update it\n * @param bool $enterRoom true if participant is entering the room. false if we just want to update some participant data\n * @param Carbon|null $enterTime if $enterNow is true then this is the join time when the actual enter has occurred\n */\n public function updateOrCreateParticipant(\n array $data,\n bool $enterRoom = true,\n ?Carbon $enterTime = null,\n bool $nameMatching = false,\n ): Participant {\n $search = [];\n $participant = null;\n\n if (isset($data['user_id'])) {\n // Check if they already exist based on their ID.\n $search['user_id'] = $data['user_id'];\n } elseif (isset($data['provider_id'])) {\n $search['provider_id'] = $data['provider_id'];\n } elseif ($nameMatching && isset($data['name'])) {\n $search['name'] = $data['name'];\n }\n\n if (! empty($data['email'])) {\n $search['email'] = $data['email'];\n\n // If we have their email, this should be unique enough to lookup (e.g. calendar event based participant).\n unset($search['provider_id']);\n }\n\n // Search by phone number only in case nothing else is available to search by.\n if (array_key_exists('phone_number', $data) && empty($search)) {\n $search['phone_number'] = $data['phone_number'];\n }\n\n if (! empty($search)) {\n // Do a lookup now to see if we have a match on the provided data.\n $lookup = array_map(static function ($key, $value): array {\n return [$key, $value];\n }, array_keys($search), $search);\n\n $participant = $this->participants()->withTrashed()->where($lookup)->first();\n }\n\n // Do a partial match on the name and search in the team members.\n if (! $participant instanceof Participant && $nameMatching && ! empty($data['name'])) {\n $participantMatcher = app(MeetingBot\\Service\\ParticipantMatcher::class);\n\n if (! $participantMatcher instanceof MeetingBot\\Service\\ParticipantMatcher) {\n throw new LogicException('Expecting ParticipantMatcher service instance');\n }\n\n $participant = $participantMatcher->match($this, $data['name']);\n\n // If we've found good participant, avoid data overwrite in `$participant->fill($data)` below.\n if ($participant instanceof Models\\Participant && $participant->hasName()) {\n unset($data['name']); // Thoughts: should we unset also $data['user_id'] and $data['email'] ?\n }\n }\n\n if (! $participant instanceof Participant) {\n // If no match, create a new participant.\n if (empty($search)) {\n $participant = $this->participants()->create();\n } else {\n // If no match, create a new participant but avoid creating duplicates\n $participant = $this->participants()->withTrashed()->firstOrNew($search);\n }\n }\n\n // If we have just recycled a deleted participant\n if ($participant->trashed()) {\n $participant->deleted_at = null;\n }\n\n // Deal with the case when calendar syncs the event while it's in progress.\n // We should prevent change of the participant name, because speeches mapping will fail.\n if ($enterRoom === false\n && $this->isInProgress()\n && $participant->hasName()\n && isset($data['name'])\n && $data['name'] !== $participant->getName()\n ) {\n unset($data['name']);\n }\n\n // Upsert with new data.\n $participant->fill($data);\n\n if ($enterRoom) {\n if ($enterTime === null) {\n $enterTime = now();\n }\n\n // Participant enters room for the first time\n if ($participant->enter_time === null) {\n $participant->enter_time = $enterTime;\n }\n\n // If there is an exit time and it's prior to new enter_time\n if ($participant->exit_time && $participant->exit_time->lt($enterTime)) {\n // Participant has re-joined\n $participant->exit_time = null;\n }\n }\n\n $participant->save();\n\n return $participant;\n }\n\n /**\n * Updates participant CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n * @param Participant $participant participant the CRM data is associated with\n */\n public function updateParticipantCrmData(array $records, Participant $participant): void\n {\n // Extract the records.\n [$lead, , , $contact] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForParticipant($lead, $contact);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n if (! $participant->hasName()) {\n $participant->name = $lead->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $lead->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $lead->phone;\n }\n\n $participant->lead_id = $lead->id;\n $participant->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n if (! $participant->hasName()) {\n $participant->name = $contact->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $contact->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $contact->phone;\n }\n\n $participant->contact_id = $contact->id;\n $participant->save();\n }\n }\n\n /**\n * Updates activity CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n */\n public function updateActivityCrmData(array $records): void\n {\n // Extract the records.\n [$lead, $account, $opportunity, $contact, $stage] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForActivity($lead, $contact, $account);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n if ($this->account_id === null && $this->contact_id === null && $this->lead_id === null) {\n $this->lead_id = $lead->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n $this->save();\n }\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Don't trust previous matched account_id as it might have been changed in the CRM\n if ($account && $account->id !== $this->account_id) {\n $this->account_id = $account->id;\n }\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($opportunity && $this->opportunity_id !== $opportunity->id) {\n $this->opportunity_id = $opportunity->id;\n }\n\n if ($opportunity && $this->value !== $opportunity->value) {\n $this->value = $opportunity->value;\n }\n\n // Always set contact_id when available, regardless of account_id status\n if ($this->contact_id === null && $contact) {\n $this->contact_id = $contact->id;\n }\n\n $this->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Account && $this->account_id === null) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Update the account and opportunity on the activity record if possible.\n $this->account_id = $account->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($this->opportunity_id === null && $opportunity) {\n $this->opportunity_id = $opportunity->id;\n $this->value = $opportunity->value;\n }\n\n $this->save();\n }\n }\n\n public function getActivityProspectData(): array\n {\n return [\n 'lead' => $this->lead_id,\n 'contact' => $this->contact_id,\n 'account' => $this->account_id,\n 'opportunity' => $this->opportunity_id,\n 'stage' => $this->stage_id,\n ];\n }\n\n public function isOrganizer(User $user): bool\n {\n return $this->user_id && $this->user_id === $user->id;\n }\n\n public function isJoinable(): bool\n {\n return \\in_array($this->status, [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n ], true);\n }\n\n public function isAttemptedForBotJoin(): bool\n {\n return in_array($this->getAttribute('status'), self::MEETING_BOT_JOIN_ATTEMPTED, true);\n }\n\n /**\n * Check if the activity can be saved to CRM (manual or autolog)\n */\n public function isLoggable(): bool\n {\n if ($this->getUser()->getTeam()->hasFeature(FeatureEnum::SIDEKICK_SETTINGS)) {\n $sidekickService = app(SidekickService::class);\n\n if (! $sidekickService->isSidekickEnabledForUser($this->getUser())) {\n return false;\n }\n }\n\n // If we don't know the activity type, don't try to log.\n if ($this->playbook_category_id === null) {\n return false;\n }\n\n if ($this->user->crm_required === false) {\n return false;\n }\n\n // Don't prompt for internal meetings.\n if ($this->is_internal) {\n return false;\n }\n\n // If we don't know who we are trying to log to, don't try to log.\n if ($this->prospect === null) {\n return false;\n }\n\n $validStatus = false;\n switch ($this->type) {\n case self::TYPE_SOFTPHONE:\n case self::TYPE_SOFTPHONE_INBOUND:\n $validStatus = true;\n\n break;\n case self::TYPE_CONFERENCE:\n $validStatus = in_array($this->status, [\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n ], true);\n\n break;\n case self::TYPE_SMS_INBOUND:\n case self::TYPE_SMS_OUTBOUND:\n $validStatus = in_array($this->status, [\n self::STATUS_QUEUED,\n self::STATUS_SENT,\n self::STATUS_UNDELIVERED,\n self::STATUS_DELIVERED,\n self::STATUS_RECEIVED,\n ], true);\n\n break;\n }\n\n // Depending on the activity channel, we should not try to log.\n return $validStatus;\n }\n\n public function isScheduled(): bool\n {\n return $this->status === self::STATUS_SCHEDULED;\n }\n\n public function scheduledDuration(): int\n {\n if ($this->scheduled_start_time && $this->scheduled_end_time) {\n return $this->scheduled_end_time->timestamp - $this->scheduled_start_time->timestamp;\n }\n\n return 0;\n }\n\n public function isPending(): bool\n {\n return $this->status === self::STATUS_PENDING;\n }\n\n public function isCompleted(): bool\n {\n return $this->status === self::STATUS_COMPLETED;\n }\n\n public function isRinging(): bool\n {\n return $this->status === self::STATUS_RINGING;\n }\n\n public function isInProgress(): bool\n {\n return $this->status === self::STATUS_IN_PROGRESS;\n }\n\n public function isBusy(): bool\n {\n return $this->status === self::STATUS_BUSY;\n }\n\n public function isNoAnswer(): bool\n {\n return $this->status === self::STATUS_NO_ANSWER;\n }\n\n public function isFailed(): bool\n {\n return $this->status === self::STATUS_FAILED;\n }\n\n public function isCancelled(): bool\n {\n return $this->status === self::STATUS_CANCELLED;\n }\n\n public function hasEnded(int $gracePeriodMinutes = 15): bool\n {\n if ($this->isCompleted()) {\n return true;\n }\n\n if (($this->isFailed() || $this->isCancelled()) && $this->hasScheduledEndTime()) {\n return $this->getScheduledEndTime()->addMinutes($gracePeriodMinutes)->isPast();\n }\n\n return false;\n }\n\n public function hasStarted(): bool\n {\n return $this->hasActualStartTime();\n }\n\n public function isOngoing(): bool\n {\n return $this->hasActualStartTime() && ! $this->hasActualEndTime();\n }\n\n public function isTypeSmsInbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_INBOUND;\n }\n\n public function isTypeSmsOutbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_OUTBOUND;\n }\n\n public function isTypeSoftPhone(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE;\n }\n\n public function isTypeSoftphoneInbound(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE_INBOUND;\n }\n\n public function isTypeConference(): bool\n {\n return $this->getType() === self::TYPE_CONFERENCE;\n }\n\n /**\n * Get a conference elapsed time in seconds.\n *\n * @return int seconds count\n */\n public function secondsTimeElapsed(): int\n {\n if (empty($this->actual_start_time)) {\n return 0;\n }\n\n // Get number of seconds since conference actual start time\n return (int) abs(Carbon::now()->diffInRealSeconds($this->actual_start_time));\n }\n\n /**\n * Get a conference elapsed time formatted as \"1:30:20\" if more than 1 hour or \"30:20\" otherwise.\n */\n public function formattedTimeElapsed(): string\n {\n // Get number of seconds since conference actual start time.\n $elapsedSeconds = $this->secondsTimeElapsed();\n $elapsedTime = Carbon::createFromTimestampUTC($elapsedSeconds);\n\n // Format conference start time.\n return $elapsedTime->format($elapsedSeconds < 3600 ? 'i:s' : 'G:i:s');\n }\n\n public function wasScheduled(): bool\n {\n return $this->calendarEvent !== null || in_array($this->getSource(), [self::SOURCE_OUTLOOK, self::SOURCE_GOOGLE]);\n }\n\n public function isInstant(): bool\n {\n return ! $this->wasScheduled();\n }\n\n /**\n * GETTERS AND SETTERS FOLLOW BELOW\n */\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getFromParticipantId(): ?int\n {\n return $this->getAttribute('from_participant_id');\n }\n\n public function getFromParticipant(): ?Participant\n {\n return $this->getAttribute('from');\n }\n\n public function getToParticipantId(): ?int\n {\n return $this->getAttribute('to_participant_id');\n }\n\n public function getToParticipant(): ?Participant\n {\n return $this->getAttribute('to');\n }\n\n public function hasScheduledStartTime(): bool\n {\n return $this->getAttribute('scheduled_start_time') !== null;\n }\n\n public function getScheduledStartTime(): ?Carbon\n {\n return $this->getAttribute('scheduled_start_time');\n }\n\n public function setScheduledStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_start_time', $dateTime);\n\n return $this;\n }\n\n public function getScheduledEndTime(): ?DateTimeInterface\n {\n return $this->getAttribute('scheduled_end_time');\n }\n\n public function hasScheduledEndTime(): bool\n {\n return $this->getAttribute('scheduled_end_time') !== null;\n }\n\n public function setScheduledEndTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_end_time', $dateTime);\n\n return $this;\n }\n\n public function getActualStartTime(): ?Carbon\n {\n return $this->getAttribute('actual_start_time');\n }\n\n public function hasActualStartTime(): bool\n {\n return $this->getAttribute('actual_start_time') !== null;\n }\n\n public function getActualEndTime(): ?Carbon\n {\n return $this->getAttribute('actual_end_time');\n }\n\n public function hasActualEndTime(): bool\n {\n return $this->getAttribute('actual_end_time') !== null;\n }\n\n public function getType(): ?string\n {\n return $this->getAttribute('type');\n }\n\n public function getStatus(): string\n {\n return $this->getAttribute('status');\n }\n\n public function setStatus(string $status): self\n {\n $this->setAttribute('status', $status);\n\n return $this;\n }\n\n public function setActualStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('actual_start_time', $dateTime);\n\n return $this;\n }\n\n public function setActualEndTime(DateTimeInterface $dateTime, bool $shouldUpdateDuration = true): self\n {\n $this->setAttribute('actual_end_time', $dateTime);\n\n if (! $shouldUpdateDuration) {\n return $this;\n }\n\n return $this->updateDuration();\n }\n\n public function updateDuration(): self\n {\n if (! $this->hasActualStartTime() || ! $this->hasActualEndTime()) {\n return $this;\n }\n\n return $this->setDuration(\n (int) abs($this->getActualStartTime()->diffInRealSeconds($this->getActualEndTime()))\n );\n }\n\n public function setDuration(int $duration): self\n {\n $this->setAttribute('duration', $duration);\n\n return $this;\n }\n\n public function getRecordingState(): string\n {\n return $this->getAttribute('recording_state');\n }\n\n public function isRecordingState(string $recordingState): bool\n {\n return $this->getRecordingState() === $recordingState;\n }\n\n public function setRecordingState(string $recordingState): self\n {\n $this->setAttribute('recording_state', $recordingState);\n\n return $this;\n }\n\n public function hasActivityType(): bool\n {\n return $this->getAttribute('category') !== null;\n }\n\n public function getActivityType(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function setActivityType(int $playbookCategoryId): self\n {\n $this->setAttribute('playbook_category_id', $playbookCategoryId);\n\n return $this;\n }\n\n public function hasStage(): bool\n {\n return $this->getAttribute('stage') !== null;\n }\n\n public function getStage(): ?Stage\n {\n return $this->getAttribute('stage');\n }\n\n public function getStageId(): ?int\n {\n return $this->getAttribute('stage_id');\n }\n\n public function setStageId(?int $stageId): void\n {\n $this->setAttribute('stage_id', $stageId);\n }\n\n public function hasOpportunity(): bool\n {\n return $this->getAttribute('opportunity') !== null;\n }\n\n public function getOpportunity(): ?Opportunity\n {\n return $this->getAttribute('opportunity');\n }\n\n public function getOpportunityId(): ?int\n {\n return $this->getAttribute('opportunity_id');\n }\n\n public function setOpportunityId(?int $opportunityId): void\n {\n $this->setAttribute('opportunity_id', $opportunityId);\n }\n\n public function hasContact(): bool\n {\n return $this->getAttribute('contact') !== null;\n }\n\n public function getContact(): ?Contact\n {\n return $this->getAttribute('contact');\n }\n\n public function getContactId(): ?int\n {\n return $this->getAttribute('contact_id');\n }\n\n public function setContactId(?int $contactId): void\n {\n $this->setAttribute('contact_id', $contactId);\n }\n\n public function hasLead(): bool\n {\n return $this->getAttribute('lead') !== null;\n }\n\n public function getLead(): ?Lead\n {\n return $this->getAttribute('lead');\n }\n\n public function getLeadId(): ?int\n {\n return $this->getAttribute('lead_id');\n }\n\n public function setLeadId(?int $leadId): void\n {\n $this->setAttribute('lead_id', $leadId);\n }\n\n public function hasAccount(): bool\n {\n return $this->getAttribute('account') !== null;\n }\n\n public function getAccount(): ?Account\n {\n return $this->getAttribute('account');\n }\n\n public function getAccountId(): ?int\n {\n return $this->getAttribute('account_id');\n }\n\n public function setAccountId(?int $accountId): void\n {\n $this->setAttribute('account_id', $accountId);\n }\n\n /**\n * This method exists to avoid confusion using ->participants() or ->participants. Use the getter instead.\n *\n * @return Collection<int, Participant>|Participant[]\n */\n public function getParticipants(): Collection\n {\n return $this->participants;\n }\n\n /**\n * @deprecated use ParticipantRepository::findParticipantRoomOwner() instead\n */\n public function findParticipantRoomOwner(): ?Participant\n {\n $roomOwnerId = $this->getUserId();\n\n return $this->getParticipants()\n ->filter(static fn (Participant $participant): bool => $participant->isSameUserId($roomOwnerId))\n ->first();\n }\n\n public function hasCrmProviderId(): bool\n {\n return $this->getAttribute('crm_provider_id') !== null;\n }\n\n public function getCrmProviderId(): ?string\n {\n return $this->getAttribute('crm_provider_id');\n }\n\n public function setCrmProviderId(?string $crmProviderId): void\n {\n $this->setAttribute('crm_provider_id', $crmProviderId);\n }\n\n public function getUserId(): ?int\n {\n return $this->getAttribute('user_id');\n }\n\n public function hasUser(): bool\n {\n return $this->user()->exists();\n }\n\n public function getUser(): User\n {\n return $this->getAttribute('user');\n }\n\n public function getCreatedAt(): Carbon\n {\n return $this->getAttribute('created_at');\n }\n\n public function isInFiniteState(): bool\n {\n return $this->isFiniteState($this->getStatus());\n }\n\n public function isFiniteState(string $status): bool\n {\n $finiteStates = self::FINITE_STATES[$this->getType()] ?? [];\n\n return in_array($status, $finiteStates, true);\n }\n\n public function getParticipant(Authenticatable $user): Participant\n {\n return $this->findParticipant($user);\n }\n\n public function findParticipant(Authenticatable $user): ?Participant\n {\n if ($user instanceof User) {\n /** @var User $user */\n return $this->participants()->where('user_id', '=', $user->getId())->first();\n }\n\n throw new LogicException(sprintf('Unsupported Authenticatable implementation %s', get_class($user)));\n }\n\n public function hasLanguageCode(): bool\n {\n return $this->getAttribute('language') !== null;\n }\n\n public function getLanguageCode(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('language');\n }\n\n public function getLanguageCodeHyphenated(): string\n {\n return str_replace('_', '-', $this->getLanguageCode() ?? '');\n }\n\n public function getLanguageCodeLocale(): string\n {\n [ $language ] = explode('_', $this->getLanguageCode() ?? '');\n\n return $language;\n }\n\n public function setLanguageCode(string $value): self\n {\n return $this->setAttribute('language', $value);\n }\n\n public function hasSource(): bool\n {\n return $this->getAttribute('source') !== null;\n }\n\n public function setSource(?string $source): self\n {\n return $this->setAttribute('source', $source);\n }\n\n public function isSource(string $source): bool\n {\n return $this->getAttribute('source') === $source;\n }\n\n public function getSource(): ?string\n {\n return $this->getAttribute('source');\n }\n\n public function isSourceGong(): bool\n {\n return $this->isSource(self::SOURCE_GONG);\n }\n\n public function getExternalId(): ?string\n {\n return $this->getAttribute('external_id');\n }\n\n public function setExternalId(?string $externalId): self\n {\n return $this->setAttribute('external_id', $externalId);\n }\n\n public function hasExternalId(): bool\n {\n return $this->getAttribute('external_id') !== null;\n }\n\n public function getProvider(): string\n {\n return $this->getAttribute('provider');\n }\n\n public function hasTelephonyProviderId(): bool\n {\n return $this->getAttribute('telephony_provider_id') !== null;\n }\n\n public function getTelephonyProviderId(): ?string\n {\n return $this->getAttribute('telephony_provider_id');\n }\n\n public function setTelephonyProviderId(?string $telephonyProviderId): self\n {\n return $this->setAttribute('telephony_provider_id', $telephonyProviderId);\n }\n\n public function getLocation(): ?string\n {\n return $this->getAttribute('location');\n }\n\n public function setLocation(?string $location): self\n {\n return $this->setAttribute('location', $location);\n }\n\n public function isDeleted(): bool\n {\n return $this->getAttribute('deleted_at') !== null;\n }\n\n /**\n * Check if activity recording is on and activity status is not one of the failed statuses.\n */\n public function canReviewActivity(): bool\n {\n $failedStatuses = self::$enumFailedStatuses;\n\n return (! in_array($this->recording_state, [self::RECORDING_OFF, self::RECORDING_STOPPED], true) &&\n ! in_array($this->status, $failedStatuses, true));\n }\n\n public function hasReasonCodeBotKicked(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_MEETING_BOT_KICKED);\n }\n\n public function hasReasonCodeNotCompliant(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_CONSENT_DENIED);\n }\n\n public function hasTopicTriggers(): bool\n {\n return $this->topicTriggers()->count() !== 0;\n }\n\n public function getTopicTriggers(): Collection\n {\n return $this->topicTriggers;\n }\n\n public function getTopicTriggersSorted(): Collection\n {\n $this->loadMissing([\n 'topicTriggers.participant',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme',\n ]);\n\n return $this->topicTriggers\n ->sortBy([\n 'playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme.sort',\n 'playbackThemeTopicTrigger.playbackThemeTopic.sort',\n 'playbackThemeTopicTrigger.sort',\n ]);\n }\n\n public function hasQuestions(): bool\n {\n return $this->questions()->exists();\n }\n\n public function getQuestions(): Collection\n {\n return $this->questions;\n }\n\n public function hasValue(): bool\n {\n return $this->getAttribute('value') !== null;\n }\n\n public function getValue(): ?float\n {\n return $this->getAttribute('value');\n }\n\n public function setValue(?float $value): void\n {\n $this->setAttribute('value', $value);\n }\n\n public function transitionTo(string $newState, callable $callback, ?int $timeout = null): self\n {\n $newState = $this->getWorkflowStateFor(\n $this->getType(),\n $newState\n );\n\n return $this->traitTransitionTo($newState, $callback, $timeout);\n }\n\n public function getWorkflowState(): string\n {\n return $this->getWorkflowStateFor(\n $this->getType(),\n $this->getStatus()\n );\n }\n\n public function getActivityProviderDisplayName(): string\n {\n return \\Cache::remember('activity_provider_display_name-' . $this->getProvider(), 60 * 60 * 24, function () {\n $activityProviderRegistry = app()->make(ActivityProviderRegistry::class);\n\n try {\n return $activityProviderRegistry->get($this->getProvider())->getDisplayName();\n } catch (Exception $exception) {\n return ucfirst($this->getProvider());\n }\n });\n }\n\n private function getWorkflowStateFor(string $activityChannel, string $activityStatus): string\n {\n return sprintf(\n '%s::%s',\n $activityChannel,\n $activityStatus\n );\n }\n\n public function getWorkflow(): array\n {\n $map = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_SCHEDULED => [\n self::STATUS_PENDING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_PENDING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_RINGING => [\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_IN_PROGRESS,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_RINGING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_NO_ANSWER,\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n ];\n\n return collect($map)\n ->mapWithKeys(function (array $currentStates, string $activityChannel): array {\n return [\n $activityChannel => collect($currentStates)\n ->mapWithKeys(function (array $possibleStates, $currentState) use ($activityChannel): array {\n $transitionName = $this->getWorkflowStateFor($activityChannel, $currentState);\n\n return [\n $transitionName => array_map(function (string $newState) use ($activityChannel) {\n return $this->getWorkflowStateFor($activityChannel, $newState);\n }, $possibleStates),\n ];\n }),\n ];\n })\n ->reduce(static function (array $carry, Collection $item): array {\n return array_merge($carry, $item->all());\n }, []);\n }\n\n public function hasPosterPath(): bool\n {\n return $this->getAttribute('poster_path') !== null;\n }\n\n public function getPosterPath(): ?string\n {\n return $this->getAttribute('poster_path');\n }\n\n /**\n * Take into account all recording settings and determine if we need to record this activity or not.\n */\n public function shouldRecord(): bool\n {\n return $this->determineRecordingReasonCode() === null;\n }\n\n public function determineRecordingReasonCode(): ?int\n {\n // Conference specific decisions.\n if ($this->isTypeConference()) {\n // If they have manually overridden the recording setting to not record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === false) {\n return self::FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE;\n }\n\n // If they have manually overridden the recording setting to record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === true) {\n return null;\n }\n\n // If their team has disabled recording meetings, don't record.\n if ($this->user->team->isConferenceRecordPreferenceDisabled()) {\n return self::FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED;\n }\n\n // If the host has disabled recording meetings, don't record.\n if ($this->user->checkConferenceRecordPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED;\n }\n\n // If it was marked internal...\n if ($this->is_internal) {\n // and their team has disabled recording internal meetings, don't record.\n if (\n $this->user->team->isConferenceRecordPreferenceEnabled()\n && ! $this->user->team->isConferenceRecordInternalPreferenceEnabled()\n ) {\n return self::FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED;\n }\n\n // and the host has disabled recording internal meetings, don't record.\n if ($this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED;\n }\n }\n\n // If it was not scheduled and they disabled internal meetings, we cannot determine if it was internal.\n if ($this->wasScheduled() === false && $this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED;\n }\n }\n\n return null;\n }\n\n public function getRecordingReasonCode(): int\n {\n return $this->getAttribute('recording_reason_code');\n }\n\n public function setRecordingReasonCode(int $recordingReasonCode): self\n {\n $this->setAttribute('recording_reason_code', $recordingReasonCode);\n\n return $this;\n }\n\n // Not used today.\n public function getRecordingReasonString(): ?string\n {\n if ($this->hasRecordingReasonCompliancePrompted()) {\n return Team::COMPLIANCE_MODE_RECORDING_PROMPT;\n }\n\n if ($this->hasRecordingReasonComplianceRestricted()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT;\n }\n\n if ($this->hasRecordingReasonComplianceRestrictedToOneSideRecording()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT_ONE_SIDE;\n }\n\n return null;\n }\n\n public function hasRecordingReasonComplianceRestricted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT);\n }\n\n public function hasRecordingReasonCompliancePrompted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_PROMPT);\n }\n\n public function hasRecordingReasonComplianceRestrictedToOneSideRecording(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE);\n }\n\n public function getAudioTrack(): ?Track\n {\n /** @var Track|null */\n return $this->tracks()\n ->where('type', '=', Track::TYPE_AUDIO)\n ->first();\n }\n\n public function activeParticipants(): HasMany\n {\n return $this->hasMany(Participant::class)->active();\n }\n\n public function getActiveParticipants(): Eloquent\\Collection\n {\n return $this->getAttribute('activeParticipants');\n }\n\n public function crm(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Configuration::class, 'crm_configuration_id');\n }\n\n public function activitySummaryLogs(): HasMany\n {\n return $this->hasMany(ActivitySummaryLog::class);\n }\n\n public function getCrm(): ?Configuration\n {\n return $this->getAttribute('crm');\n }\n\n public function hasCrmConfiguration(): bool\n {\n return $this->getAttribute('crm') !== null;\n }\n\n public function isProcessed(): ?bool\n {\n return $this->getAttribute('is_processed');\n }\n\n public function hasRecordingPrompt(): bool\n {\n return $this->getAttribute('has_recording_prompt') === true;\n }\n\n public function isOnAir(): bool\n {\n return $this->getAttribute('on_air') === self::ON_AIR_READY || $this->getAttribute('on_air') === self::ON_AIR_STREAMING;\n }\n\n public function setOnAir(int $onAir): self\n {\n $this->setAttribute('on_air', $onAir);\n\n return $this;\n }\n\n public function getOnAir(): ?int\n {\n return $this->getAttribute('on_air');\n }\n\n public function setTitleFromCallData(Call $call): void\n {\n $direction = $call->isOutbound() ? 'to' : 'from';\n\n $party = $this->prospect_name\n ?? $call->getContactName()\n ?? $call->getOtherPartyPhoneNumber()\n ;\n\n $this->update(['title' => sprintf('Call %s %s', $direction, $party)]);\n }\n\n /**\n * @param array{}|array{channels:string|null, format:string|null, type:string|null, status:string|null} $audioParams\n */\n public function createAudioTrack(\n string $telephonyProviderId,\n string $recordingUrl,\n array $audioParams = []\n ): Track {\n return $this->tracks()->updateOrCreate([\n 'telephony_provider_id' => $telephonyProviderId,\n ], [\n 'type' => $audioParams['type'] ?? Track::TYPE_AUDIO,\n 'status' => $audioParams['status'] ?? Track::STATUS_PENDING,\n 'format' => $audioParams['format'] ?? Track::FORMAT_WAV,\n 'provider_content_url' => $recordingUrl,\n 'start_time' => $this->actual_start_time,\n 'end_time' => $this->actual_end_time,\n ]);\n }\n\n public function createTrack(string $telephonyProviderId, array $params): Track\n {\n return $this->tracks()->updateOrCreate(\n [\n 'telephony_provider_id' => $telephonyProviderId,\n ],\n $params\n );\n }\n\n public function createOrganiserParticipant(Call $call): Participant\n {\n $user = $this->getUser();\n\n return $this->updateOrCreateParticipant([\n 'is_ghost' => 0,\n 'name' => $user->name,\n 'email' => $user->email,\n 'phone_number' => phone_e164(null, $call->getUserPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'user_id' => $user->id,\n ], false);\n }\n\n public function createProspectParticipant(Call $call): Participant\n {\n // not null 'name' is mandatory here to create a separate participant with 'nameMatching'\n // in case of the same phone_number with the Organiser\n $useNameMatching = $call->getUserPhoneNumber() === $call->getOtherPartyPhoneNumber();\n $defaultName = $useNameMatching ? '' : null;\n\n return $this->updateOrCreateParticipant(data: [\n 'is_ghost' => 0,\n 'name' => $this->prospect->name ?? $defaultName,\n 'email' => $this->prospect->email ?? null,\n 'phone_number' => phone_e164(null, $call->getOtherPartyPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'contact_id' => $this->contact_id ?? null,\n 'lead_id' => $this->lead_id ?? null,\n ], enterRoom: false, nameMatching: $useNameMatching);\n }\n\n public function updateParticipants(Participant $organiserParticipant, Participant $prospectParticipant): void\n {\n $this->update([\n 'from_participant_id' => $this->isTypeSoftPhone() ? $organiserParticipant->id : $prospectParticipant->id,\n 'to_participant_id' => $this->isTypeSoftPhone() ? $prospectParticipant->id : $organiserParticipant->id,\n ]);\n }\n\n public function hasProspect(): bool\n {\n return $this->getProspectAttribute() !== null;\n }\n\n public function isPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n /** Create a new factory instance for the model. */\n protected static function newFactory(): Factory\n {\n return ActivityFactory::new();\n }\n\n public function getUpdatedAt(): Carbon\n {\n return $this->getAttribute('updated_at');\n }\n\n public function getActivitySummaryLogs(): Eloquent\\Collection\n {\n return $this->getAttribute('activitySummaryLogs');\n }\n\n public function hasProspectActivitySummaryLog(): bool\n {\n return $this->getActivitySummaryLogs()->contains(\n 'relation_type',\n ActivitySummaryLog::RELATION_OBJECT_TYPE_PROSPECT\n );\n }\n\n public function getTeam(): Team\n {\n return $this->getUser()->getTeam();\n }\n\n private function getUpdateCrmDataResolver(): UpdateCrmDataResolverInterface\n {\n $factory = app(UpdateCrmDataResolverFactory::class);\n\n return $factory->create($this);\n }\n\n public function getMeetingTrackProviderId(string $type): string\n {\n $label = match ($type) {\n Track::TYPE_VIDEO => 'v',\n Track::TYPE_AUDIO => 'a',\n default => throw new InvalidArgumentJiminnyException('Invalid track type'),\n };\n\n $startTimestamp = $this->getScheduledStartTime()?->getTimestamp();\n $teamId = $this->getTeam()->getId();\n\n return $this->getTelephonyProviderId() . ':' . $label . ':' . $startTimestamp . ':' . $teamId;\n }\n\n /**\n * Get all consent records associated with this activity\n *\n * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasMany\n */\n public function participantConsents(): HasMany\n {\n return $this->hasMany(Participant\\Consent::class);\n }\n\n public function isDiallerCall(): bool\n {\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return false;\n }\n\n if (! in_array($this->getType(), [self::TYPE_SOFTPHONE, self::TYPE_SOFTPHONE_INBOUND])) {\n return false;\n }\n\n return $this->getProvider() !== self::PROVIDER_TWILIO;\n }\n\n public function getActivityDateWithFallback(): Carbon\n {\n if ($this->getActualStartTime() !== null) {\n return $this->getActualStartTime();\n }\n\n if ($this->getScheduledStartTime() !== null) {\n return $this->getScheduledStartTime();\n }\n\n return $this->getCreatedAt();\n }\n\n public function getCrmType(): ?string\n {\n // Treat uploader activities as conferences\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return Activity::TYPE_CONFERENCE;\n }\n\n return $this->getType();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\nnamespace Jiminny\\Models;\n\nuse Carbon\\Carbon;\nuse Database\\Factories\\ActivityFactory;\nuse DateTimeInterface;\nuse Exception;\nuse Illuminate\\Contracts\\Auth\\Authenticatable;\nuse Illuminate\\Database\\Eloquent;\nuse Illuminate\\Database\\Eloquent\\Attributes\\Scope;\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse Illuminate\\Database\\Eloquent\\Factories\\Factory;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasManyThrough;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasOne;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Auth;\nuse InvalidArgumentException;\nuse Jiminny\\Component\\ElasticSearch;\nuse Jiminny\\Component\\MeetingBot;\nuse Jiminny\\Component\\Model\\BitwiseFlagTrait;\nuse Jiminny\\Component\\PlaybackPage\\Comments\\Services\\ActivityCommentService;\nuse Jiminny\\Component\\Sidekick\\SidekickService;\nuse Jiminny\\Component\\Uuid\\UuidAwareInterface;\nuse Jiminny\\Component\\Workflow;\nuse Jiminny\\Contracts;\nuse Jiminny\\Contracts\\Crm\\ProspectInterface;\nuse Jiminny\\DTO\\ImportCall\\Call;\nuse Jiminny\\Events\\Activities\\ActivityTypeUpdated;\nuse Jiminny\\Events\\Activities\\ActivityUpdated;\nuse Jiminny\\Events\\Activities\\ProspectUpdated;\nuse Jiminny\\Events\\Activities\\StageUpdated;\nuse Jiminny\\Events\\Activities\\StatusUpdated;\nuse Jiminny\\Events\\Activities\\TitleUpdated;\nuse Jiminny\\Exceptions\\InvalidArgumentException as InvalidArgumentJiminnyException;\nuse Jiminny\\Exceptions\\LogicException;\nuse Jiminny\\Exceptions\\RuntimeException;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Activity\\ActivitySummaryLog;\nuse Jiminny\\Models\\Activity\\ActivityUploadSetting;\nuse Jiminny\\Models\\Activity\\AvailabilityNotification;\nuse Jiminny\\Models\\Activity\\CoachRequest;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\Activity\\Log;\nuse Jiminny\\Models\\Activity\\Message;\nuse Jiminny\\Models\\Activity\\Moment;\nuse Jiminny\\Models\\Activity\\Note;\nuse Jiminny\\Models\\Activity\\ParticipantSpeech;\nuse Jiminny\\Models\\Activity\\Play;\nuse Jiminny\\Models\\Activity\\Question;\nuse Jiminny\\Models\\Activity\\Share;\nuse Jiminny\\Models\\Activity\\Snapshot;\nuse Jiminny\\Models\\Activity\\Stats;\nuse Jiminny\\Models\\Activity\\SubscriptionSet;\nuse Jiminny\\Models\\Activity\\TopicTrigger;\nuse Jiminny\\Models\\Activity\\Transcription;\nuse Jiminny\\Models\\Calendar\\CalendarEvent;\nuse Jiminny\\Models\\Crm\\Configuration;\nuse Jiminny\\Models\\Crm\\FieldData;\nuse Jiminny\\Models\\ElasticSearch\\ActivityElasticSearchTrait;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Participant\\Connection;\nuse Jiminny\\Models\\Playlist\\Activity as PlaylistActivity;\nuse Jiminny\\Services\\Activity\\ActivityProviderRegistry;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataByStrategy;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverFactory;\nuse Jiminny\\Services\\Activity\\Import\\DataResolvers\\UpdateCrmDataResolverInterface;\nuse Jiminny\\Traits\\Enums;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Jiminny\\Utils\\CurrencyFormatter;\nuse NumberFormatter;\n\nuse function in_array;\n\n/**\n * Jiminny\\Models\\Activity\n *\n * @property null|int $auto_score filled from ES hydrator, not in DB!\n * @property-read Account|null $account\n * @property-read CalendarEvent|null $calendarEvent\n * @property-read Contact|null $contact\n * @property-read Lead|null $lead\n * @property-read Opportunity|null $opportunity\n * @property-read Stage|null $stage\n * @property int $id\n * @property mixed|null $uuid\n * @property string|null $source\n * @property string|null $external_id\n * @property string $provider\n * @property string|null $location\n * @property string|null $telephony_provider_id\n * @property int|null $from_participant_id\n * @property int|null $to_participant_id\n * @property int|null $device_id\n * @property string|null $type\n * @property int|null $playbook_category_id\n * @property int $user_id\n * @property int|null $lead_id\n * @property int|null $account_id\n * @property int|null $contact_id\n * @property int|null $opportunity_id\n * @property int|null $stage_id\n * @property string|null $value\n * @property int|null $crm_configuration_id\n * @property string|null $crm_provider_id\n * @property string|null $language\n * @property int|null $transcription_id\n * @property int $duration\n * @property string $status\n * @property int|null $on_air\n * @property int|null $calendar_event_id\n * @property string $recording_state\n * @property bool|null $recording_preference\n * @property int $recording_reason_code\n * @property int $summary_reminder_sent\n * @property \\Illuminate\\Support\\Carbon|null $log_reminder_sent_at\n * @property \\Illuminate\\Support\\Carbon|null $organizer_notified_at\n * @property bool|null $has_recording_prompt\n * @property bool $is_internal\n * @property int $is_locked\n * @property int $is_recording\n * @property bool|null $is_processed\n * @property bool $is_private\n * @property bool $is_instant_invite\n * @property string|null $poster_path\n * @property string|null $summary\n * @property string|null $title\n * @property string|null $description\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_start_time\n * @property \\Illuminate\\Support\\Carbon|null $scheduled_end_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_start_time\n * @property \\Illuminate\\Support\\Carbon|null $actual_end_time\n * @property int|null $uploaded_by\n * @property \\Illuminate\\Support\\Carbon|null $deleted_at\n * @property \\Illuminate\\Support\\Carbon|null $created_at\n * @property \\Illuminate\\Support\\Carbon|null $updated_at\n * @property string|null $average_score\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $activeParticipants\n * @property-read int|null $active_participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers\n * @property-read int|null $activity_scorecard_rule_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Scorecard\\ActivityScorecardRule> $activityScorecardRules\n * @property-read int|null $activity_scorecard_rules_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, AvailabilityNotification> $availabilityNotifications\n * @property-read int|null $availability_notifications_count\n * @property-read \\Jiminny\\Models\\PlaybookCategory|null $category\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, CoachRequest> $coachRequests\n * @property-read int|null $coach_requests_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $coachingFeedbacks\n * @property-read int|null $coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $coachingMessages\n * @property-read int|null $coaching_messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $comments\n * @property-read int|null $comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Connection> $connections\n * @property-read int|null $connections_count\n * @property-read Configuration|null $crm\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, FieldData> $data\n * @property-read int|null $data_count\n * @property-read \\Jiminny\\Models\\Device|null $device\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $favoritePlaylists\n * @property-read int|null $favorite_playlists_count\n * @property-read \\Jiminny\\Models\\Participant|null $from\n * @property-read string|null $activity_title\n * @property-read mixed $comment_count\n * @property-read mixed $duration_for_humans\n * @property-read string $duration_for_humans_short\n * @property-read int $favorite_count\n * @property-read mixed $favorites_count\n * @property-read mixed $formatted_value\n * @property-read string $id_string\n * @property-read \\Jiminny\\Models\\Participant|null $organizer\n * @property-read mixed $play_count\n * @property-read int|null $plays_count\n * @property-read ?ProspectInterface $prospect\n * @property-read string|null $prospect_name\n * @property-read mixed $prospect_type\n * @property-read mixed $share_count\n * @property-read int|null $shares_count\n * @property-read int|null $tracks_with_telephony_count\n * @property-read int|null $visible_comments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\CoachingFeedback> $latestCoachingFeedbacks\n * @property-read int|null $latest_coaching_feedbacks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Log> $logs\n * @property-read int|null $logs_count\n * @property-read \\Jiminny\\Models\\Track|null $masterTrack\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Message> $messages\n * @property-read int|null $messages_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Moment> $moments\n * @property-read int|null $moments_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Note> $notes\n * @property-read int|null $notes_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\Share> $participantShares\n * @property-read int|null $participant_shares_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, ParticipantSpeech> $participantSpeeches\n * @property-read int|null $participant_speeches_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant\\ParticipantStats> $participantStats\n * @property-read int|null $participant_stats_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Participant> $participants\n * @property-read int|null $participants_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, PlaylistActivity> $playlistActivities\n * @property-read int|null $playlist_activities_count\n * @property-read \\Kalnoy\\Nestedset\\Collection<int, \\Jiminny\\Models\\Playlist> $playlists\n * @property-read int|null $playlists_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Play> $plays\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Question> $questions\n * @property-read int|null $questions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Session> $sessions\n * @property-read int|null $sessions_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Share> $shares\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Snapshot> $snapshots\n * @property-read int|null $snapshots_count\n * @property-read Stats|null $stats\n * @property-read \\Jiminny\\Models\\Participant|null $to\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, TopicTrigger> $topicTriggers\n * @property-read int|null $topic_triggers_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracks\n * @property-read int|null $tracks_count\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, \\Jiminny\\Models\\Track> $tracksWithTelephony\n * @property-read Transcription|null $transcription\n * @property-read \\Jiminny\\Models\\User $user\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection<int, Comment> $visibleComments\n *\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> all($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)\n * @method static \\Database\\Factories\\ActivityFactory factory(...$parameters)\n * @method static \\Illuminate\\Database\\Eloquent\\Collection<int, static> get($columns = ['*'])\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity heldBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity idOrUuId($idOrUuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newModelQuery()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity newQuery()\n * @method static Builder|Activity onlyTrashed()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity query()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity scheduledBetween(\\Carbon\\Carbon $start, \\Carbon\\Carbon $end)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity inOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity notInOpenDeals()\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity forTeam(int $teamId)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity uuid(string $uuid, bool $first = true)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAccountId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereActualStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereAverageScore($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCalendarEventId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereContactId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCreatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmConfigurationId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereCrmProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeletedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDescription($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDeviceId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereDuration($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereFromParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereHasRecordingPrompt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInstantInvite($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsInternal($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsLocked($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsPrivate($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsProcessed($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereIsRecording($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLanguage($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLeadId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLocation($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereLogReminderSentAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOnAir($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOpportunityId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereOrganizerNotifiedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePlaybookCategoryId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity wherePosterPath($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereProvider($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingPreference($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingReasonCode($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereRecordingState($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledEndTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereScheduledStartTime($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSource($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereExternalId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStageId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereStatus($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummary($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereSummaryReminderSent($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTelephonyProviderId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTitle($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereToParticipantId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereTranscriptionId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereType($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUpdatedAt($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUploadedBy($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUserId($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereUuid($value)\n * @method static \\Jiminny\\Component\\Eloquent\\Builder|Activity whereValue($value)\n * @method static Builder|Activity withTrashed()\n * @method static Builder|Activity withoutTrashed()\n *\n * @mixin \\Eloquent\n */\nclass Activity extends Model implements\n ElasticSearch\\Contract\\Searchable,\n Workflow\\Workflow\\WorkflowAwareInterface,\n Models\\Contracts\\ActivityContract,\n Contracts\\Model\\ActivityInterface,\n UuidAwareInterface\n{\n use HasFactory;\n\n use Enums;\n use SoftDeletes;\n use RequiresUUID;\n use BitwiseFlagTrait;\n use ElasticSearch\\Model\\Searchable;\n use ActivityElasticSearchTrait;\n\n use Workflow\\Workflow\\WorkflowAware {\n transitionTo as traitTransitionTo;\n }\n\n public const int FLAG_RECORDING_REASON_DEFAULT = 0;\n\n // Recording Prompted but never started\n public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;\n public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;\n\n // Recording Disabled by Organization\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;\n\n // Recording was restricted to one-side recordings only\n public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;\n\n // Recording was not started because it was internal and team setting disabled that.\n public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;\n\n // Recording was not started because it was internal and user setting disabled that.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;\n\n // Recording was not started because user setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;\n\n // Recording was not started because team setting disabled automatic recording.\n public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;\n\n // Recording was not started because user has overriden default.\n public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;\n\n // Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.\n public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;\n\n // Recording was not started because their team setting does excludes the meeting type.\n public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;\n\n // Recording was not started because the external provider disabled it (or recording is missing etc).\n public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;\n\n // Recording was stopped externally (\"exit-meeting\" Pusher event)\n public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;\n\n // Recording couldn't be started due to Zoom hosting conflict error\n public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;\n\n // meeting.failed event with reason code BOT_DENIED_FROM_LOBBY\n public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;\n\n // meeting.failed event with reason code LOBBY_TIMEOUT\n public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;\n\n // meeting.failed event with reason code BOT_KICKED\n public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;\n\n // meeting.failed event with reason code UNKNOWN\n public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;\n\n public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;\n\n // Invalid meeting (e.g. URL is invalid, or the meeting is not found)\n public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;\n\n // The host stopped the recording.\n public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;\n\n // Recording was not started because an alternative vendor disabled it (or overrode it).\n public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;\n\n // Login required meeting.failed code\n public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;\n\n // Password for meeting was not provided - meeting.failed code\n public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;\n\n // meeting.failed - when the meeting is locked\n public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;\n\n // max recording duration reached\n public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;\n\n // recording size is too small\n public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;\n\n // meeting.failed - when bot is redirected to sign in page multiple times\n public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;\n\n // meeting.failed event with reason code CONNECTION_LOST\n public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;\n\n // recording is corrupted.\n public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;\n\n // meeting ended in lobby\n public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;\n\n // meeting not started\n public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;\n\n // unfinished zoom custom disclaimer\n public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;\n\n // recording download failed - server error\n public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;\n\n // recording download failed - client code 404\n public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;\n\n // recording download failed - client code 401, 403\n public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;\n\n // recording download failed - client code 429\n public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;\n\n // recording download failed - unknown client error\n public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;\n\n // recording download failed - unknown error\n public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;\n\n // It has been setup ahead of time through calendar\n public const string STATUS_SCHEDULED = 'scheduled';\n\n // It is awaiting audio.\n public const string STATUS_PENDING = 'pending';\n\n // Participant(s) dialed in, awaiting organizer.\n public const string STATUS_RINGING = 'ringing';\n\n // Call is in progress.\n public const string STATUS_IN_PROGRESS = 'in-progress';\n\n // It has ended.\n public const string STATUS_COMPLETED = 'completed';\n\n // Cancelled prior to starting.\n public const string STATUS_CANCELLED = 'canceled';\n\n public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference\n\n public const string STATUS_STARTING_SOON = 'starting-soon';\n\n public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';\n\n public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';\n\n public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';\n\n // When bot instance is waiting in lobby\n public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';\n\n public const string STATUS_BUSY = 'busy';\n public const string STATUS_NO_ANSWER = 'no-answer';\n public const string STATUS_FAILED = 'failed'; // Used by SMS too\n\n // SMS related\n public const string STATUS_ACCEPTED = 'accepted';\n public const string STATUS_QUEUED = 'queued';\n public const string STATUS_SENDING = 'sending';\n public const string STATUS_SENT = 'sent';\n public const string STATUS_DELIVERED = 'delivered';\n public const string STATUS_UNDELIVERED = 'undelivered';\n public const string STATUS_RECEIVING = 'receiving';\n public const string STATUS_RECEIVED = 'received';\n public const string STATUS_RESENT = 'resent';\n\n public const array SMS_STATUSES = [\n Activity::STATUS_RECEIVED,\n Activity::STATUS_SENT,\n Activity::STATUS_DELIVERED,\n ];\n\n public const array SOFT_PHONE_CONFERENCE_STATUSES = [\n Activity::STATUS_IN_PROGRESS,\n Activity::STATUS_COMPLETED,\n ];\n\n // @todo refactor prefix from `TYPE_` to `CHANNEL_`\n public const string TYPE_SOFTPHONE = 'softphone';\n public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';\n public const string TYPE_CONFERENCE = 'conference';\n public const string TYPE_SMS_INBOUND = 'sms-inbound';\n public const string TYPE_SMS_OUTBOUND = 'sms-outbound';\n public const string TYPE_EMAIL_INBOUND = 'email-inbound';\n public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';\n\n public const array CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n public const array PLAYABLE_CHANNELS = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n ];\n\n // Recording States\n public const string RECORDING_OFF = 'off'; // Default state\n public const string RECORDING_IN_PROGRESS = 'in-progress';\n public const string RECORDING_PAUSED = 'paused';\n public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.\n public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.\n public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.\n\n // Live Stream States\n public const int ON_AIR_DEFAULT = 0;\n public const int ON_AIR_READY = 1;\n public const int ON_AIR_PREPARING = 2;\n public const int ON_AIR_STREAMING = 3;\n public const int ON_AIR_FINISHED = 4;\n public const int ON_AIR_NOT_STREAMED = 5;\n public const int ON_AIR_ERROR = -1;\n\n public const string SOURCE_GONG = 'gong';\n public const string SOURCE_CHORUS = 'chorus';\n public const string SOURCE_OUTLOOK = 'outlook';\n public const string SOURCE_GOOGLE = 'google';\n\n // Activity Providers\n public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.\n public const string PROVIDER_OUTREACH = 'outreach';\n public const string PROVIDER_ZOOM_BOT = 'zoom-bot';\n public const string PROVIDER_SALESLOFT = 'salesloft';\n public const string PROVIDER_GOOGLE = 'google';\n public const string PROVIDER_AIRCALL = 'aircall';\n public const string PROVIDER_JUSTCALL = 'justcall';\n public const string PROVIDER_GOOGLE_MEET = 'google-meet';\n public const string PROVIDER_GONG = 'gong';\n public const string PROVIDER_HUBSPOT = 'hubspot';\n public const string PROVIDER_CLOSE = 'close';\n public const string PROVIDER_TEAMS = 'ms-teams';\n public const string PROVIDER_SALESFORCE = 'salesforce';\n public const string PROVIDER_GROOVE = 'groove';\n public const string PROVIDER_XANT = 'xant';\n public const string PROVIDER_OFFICE = 'office';\n public const string PROVIDER_NATTERBOX = 'natterbox';\n public const string PROVIDER_RINGCENTRAL = 'ringcentral';\n public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';\n public const string PROVIDER_GOTOMEETING = 'go-to-meeting';\n public const string PROVIDER_DEMODESK = 'demo-desk';\n public const string PROVIDER_DIALPAD = 'dialpad';\n public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';\n public const string PROVIDER_CLOUDCALL = 'cloudcall';\n public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';\n public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // \"8x8\" UK\n public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // \"8x8\" Canada\n public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // \"8x8\" Australia\n public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // \"8x8\" US East\n public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // \"8x8\" US West\n public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';\n public const string PROVIDER_CLOUD_TALK = 'cloud-talk';\n public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';\n public const string PROVIDER_VONAGE = 'vonage';\n public const string PROVIDER_MIGRATOR = 'migrator';\n public const string PROVIDER_UPLOADER = 'uploader';\n public const string PROVIDER_TALKDESK = 'talkdesk';\n public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';\n public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';\n public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';\n public const string PROVIDER_AVAYA = 'avaya';\n public const string PROVIDER_TELUS = 'telus';\n public const string PROVIDER_FIVE_NINE = 'five-nine';\n public const string PROVIDER_APOLLO = 'apollo';\n public const string PROVIDER_ORUM = 'orum';\n public const string PROVIDER_BLOOBIRDS = 'bloobirds';\n\n /**\n * @const API_PROVIDERS\n * A list of integrations that import calls via API instead of webhooks\n */\n public const array API_PROVIDERS = [\n self::PROVIDER_OUTREACH,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n ];\n\n public const array FINITE_STATES = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_NO_ANSWER,\n self::STATUS_BUSY,\n ],\n self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,\n ];\n\n public const array FINITE_STATES_CONFERENCE = [\n self::STATUS_COMPLETED,\n self::STATUS_FAILED,\n self::STATUS_CANCELLED,\n ];\n\n public const array MEETING_BOT_JOIN_ATTEMPTED = [\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_BOT_INSTANCE_STARTED,\n ];\n\n public static array $enumStatuses = [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_ACCEPTED,\n self::STATUS_QUEUED,\n self::STATUS_SENDING,\n self::STATUS_SENT,\n self::STATUS_RESENT,\n self::STATUS_DELIVERED,\n self::STATUS_UNDELIVERED,\n self::STATUS_RECEIVING,\n self::STATUS_RECEIVED,\n self::STATUS_BOT_INSTANCE_WAITING_LOBBY,\n self::STATUS_STARTING_SOON,\n self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,\n self::STATUS_BOT_INSTANCE_STARTED,\n self::STATUS_DUPLICATED,\n ];\n\n public static array $enumProviders = [\n self::PROVIDER_TWILIO,\n self::PROVIDER_OUTREACH,\n self::PROVIDER_ZOOM_BOT,\n self::PROVIDER_SALESLOFT,\n self::PROVIDER_AIRCALL,\n self::PROVIDER_JUSTCALL,\n self::PROVIDER_GOOGLE_MEET,\n self::PROVIDER_GONG,\n self::PROVIDER_HUBSPOT,\n self::PROVIDER_CLOSE,\n self::PROVIDER_TEAMS,\n self::PROVIDER_SALESFORCE,\n self::PROVIDER_GROOVE,\n self::PROVIDER_XANT,\n self::PROVIDER_GOOGLE,\n self::PROVIDER_OFFICE,\n self::PROVIDER_NATTERBOX,\n self::PROVIDER_RINGCENTRAL,\n self::PROVIDER_RINGCENTRAL_VIDEO,\n self::PROVIDER_GOTOMEETING,\n self::PROVIDER_DEMODESK,\n self::PROVIDER_DIALPAD,\n self::PROVIDER_ZOOM_PHONE,\n self::PROVIDER_CLOUDCALL,\n self::PROVIDER_CLOUDCALL_US,\n self::PROVIDER_EIGHT_BY_EIGHT,\n self::PROVIDER_EIGHT_BY_EIGHT_CA,\n self::PROVIDER_EIGHT_BY_EIGHT_AP,\n self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,\n self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,\n self::PROVIDER_CONNECT_AND_SELL,\n self::PROVIDER_CLOUD_TALK,\n self::PROVIDER_AMAZON_CONNECT,\n self::PROVIDER_VONAGE,\n self::PROVIDER_TALKDESK,\n self::PROVIDER_TWILIO_FLEX,\n self::PROVIDER_TWILIO_FLEX_DIRECT,\n self::PROVIDER_TWILIO_VIDEO,\n self::PROVIDER_AVAYA,\n self::PROVIDER_TELUS,\n self::PROVIDER_FIVE_NINE,\n self::PROVIDER_APOLLO,\n self::PROVIDER_ORUM,\n self::PROVIDER_BLOOBIRDS,\n ];\n\n public static $enumRecordingStates = [\n self::RECORDING_OFF, // Default state\n self::RECORDING_IN_PROGRESS,\n self::RECORDING_PAUSED,\n self::RECORDING_STOPPED,\n self::RECORDING_RECORDED,\n self::RECORDING_FAILED,\n ];\n\n // @Important:\n // This collection is not used anywhere, and is fully duplicated by the Channels const.\n // Validate if it is referred somehow via the enum trait, and if not, remove it entirely.\n // An even better strategy will be to move all those constants to a dedicated class\n protected array $enumTypes = [\n self::TYPE_SOFTPHONE,\n self::TYPE_SOFTPHONE_INBOUND,\n self::TYPE_CONFERENCE,\n self::TYPE_SMS_INBOUND,\n self::TYPE_SMS_OUTBOUND,\n self::TYPE_EMAIL_INBOUND,\n self::TYPE_EMAIL_OUTBOUND,\n ];\n\n protected static $enumFailedStatuses = [\n self::STATUS_NO_ANSWER,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n self::STATUS_CANCELLED,\n ];\n\n protected $table = 'activities';\n\n protected $fillable = [\n // Type of activity.\n 'type', // @todo refactor to `channel`\n // The activity type.\n 'playbook_category_id',\n // User who hosts the activity.\n 'user_id',\n // Related Lead record (if applicable)\n 'lead_id',\n // Related Account record (if applicable)\n 'account_id',\n // Related Contact record (if applicable)\n 'contact_id',\n // Related Opportunity record (if applicable)\n 'opportunity_id',\n // Stage of activity.\n 'stage_id',\n // Value of opportunity.\n 'value',\n // If the activity relates to a CRM task.\n 'crm_provider_id',\n // If the activity was created through an external device.\n 'device_id',\n // the activity's language code\n 'language',\n // transcription id\n 'transcription_id',\n // Duration of the call, with microseconds precision.\n 'duration',\n // One of enumStatuses above.\n 'status',\n // Have we reminded them to log the call?\n 'log_reminder_sent_at',\n // If activity is private or inter-org, flagged here.\n 'is_internal',\n // Managers and above can mark a call as private, to exclude it from other team members\n 'is_private',\n 'is_processed',\n // Boolean for this activity being instant invite handled.\n 'is_instant_invite',\n // If activity is in recording state, flagged here.\n 'recording_state',\n // If activity recording is overidden from default.\n 'recording_preference',\n // if recording did (not) happen, why that is\n 'recording_reason_code',\n // Average score, updated during\n 'average_score',\n // Summary that the organizer has taken after the call.\n 'summary',\n // Subject of the activity, usually taken from calendar event.\n 'title',\n // Description of the activity, usually taken from calendar event.\n 'description',\n // Start time, usually taken from calendar event.\n 'scheduled_start_time',\n // End time, usually taken from calendar event.\n 'scheduled_end_time',\n // When the call actually started.\n 'actual_start_time',\n // When the call actually ended.\n 'actual_end_time',\n // SMS: Message reference\n 'telephony_provider_id',\n // SMS: Participant who sent message\n 'from_participant_id',\n // SMS: Participant who should receive the message\n 'to_participant_id',\n // When an external guest joins an organizers meeting room and the organizer is not present,\n // send them an SMS notification that someone has joined.\n 'organizer_notified_at',\n // where was the activity imported from\n 'source',\n // The id in the source system (e.g. the bot id in Recall.ai)\n 'external_id',\n // The provider, by default it is twilio.\n 'provider',\n // Meeting location url\n 'location',\n // The snapshot for displaying a poster image.\n 'poster_path',\n 'crm_configuration_id',\n // If there is an automated message that the conversation is being recorded\n 'has_recording_prompt',\n // If the activity is being live-streamed\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected $appends = [\n 'id_string',\n 'organizer',\n ];\n\n protected $hidden = [\n 'uuid',\n ];\n\n protected $visible = [\n 'id_string',\n 'type',\n 'duration',\n 'average_score',\n 'status',\n 'log_reminder_sent_at',\n 'title',\n 'description',\n 'is_internal',\n 'scheduled_start_time',\n 'scheduled_end_time',\n 'actual_start_time',\n 'actual_end_time',\n 'user',\n 'category',\n 'account',\n 'contact',\n 'opportunity',\n 'lead',\n 'stage',\n 'stats',\n 'participants',\n 'playlists',\n 'tracks',\n 'comments',\n 'plays',\n 'coachingFeedbacks',\n 'shares',\n 'favorites',\n 'language',\n 'transcription',\n 'is_private',\n 'is_instant_invite',\n 'on_air',\n 'calendar_event_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'scheduled_start_time' => 'datetime',\n 'scheduled_end_time' => 'datetime',\n 'actual_start_time' => 'datetime',\n 'actual_end_time' => 'datetime',\n 'organizer_notified_at' => 'datetime',\n 'log_reminder_sent_at' => 'datetime',\n 'is_internal' => 'boolean',\n 'duration' => 'integer',\n 'average_score' => 'decimal:2',\n 'is_private' => 'boolean',\n 'is_processed' => 'boolean',\n 'is_instant_invite' => 'boolean',\n 'value' => 'decimal:2',\n 'recording_preference' => 'boolean',\n 'recording_reason_code' => 'integer',\n 'has_recording_prompt' => 'boolean',\n 'on_air' => 'integer',\n ];\n }\n\n protected static function boot()\n {\n parent::boot();\n\n static::updated(static function (Activity $activity) {\n // If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week\n if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||\n ($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {\n if ($activity->isDirty('status')) {\n event(new StatusUpdated($activity));\n }\n\n if ($activity->isDirty('stage_id')) {\n event(new StageUpdated($activity));\n }\n\n if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {\n event(new ProspectUpdated($activity));\n }\n\n if ($activity->isDirty('opportunity_id')) {\n event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));\n }\n\n if ($activity->isDirty('title')) {\n event(new TitleUpdated($activity));\n }\n }\n\n if ($activity->isDirty('playbook_category_id')) {\n event(new ActivityTypeUpdated($activity));\n }\n });\n\n static::deleted(static function (Activity $activity) {\n // Hard delete associated playlistActivities\n $activity->playlistActivities()->delete();\n });\n }\n\n public function getOrganizerAttribute(): ?Participant\n {\n $participant = $this->participants()->where('user_id', $this->user_id)->first();\n\n if (! $participant instanceof Participant && $participant !== null) {\n throw new RuntimeException(sprintf('$participant must be an instance of \"%s\" or null', Participant::class));\n }\n\n return $participant;\n }\n\n public function getFormattedValueAttribute()\n {\n $currencyCode = 'USD';\n if ($this->opportunity) {\n $currencyCode = $this->opportunity->getCurrencyCode();\n }\n\n $formatter = new CurrencyFormatter();\n $formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);\n $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);\n\n return $formatter->format($this->value, $currencyCode);\n }\n\n public function getProspectNameAttribute(): ?string\n {\n $prospectName = null;\n\n if ($this->lead_id) {\n $prospectName = $this->lead->name;\n } elseif ($this->contact_id) {\n $prospectName = $this->contact->name;\n } elseif ($this->account_id) {\n $prospectName = $this->account->name;\n }\n\n return $prospectName;\n }\n\n public function getProspectName(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('prospect_name');\n }\n\n /**\n * Get activity title depending on prospect or title\n */\n public function getActivityTitleAttribute(): ?string\n {\n $activityTitle = null;\n if ($this->prospect && $this->prospect->getName()) {\n if ($this->account_id) {\n $activityTitle = $this->account->name;\n } elseif ($this->lead_id) {\n $activityTitle = $this->lead->company;\n } elseif ($this->contact_id) {\n $activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;\n }\n } elseif ($this->title) {\n $activityTitle = $this->title;\n }\n\n return $activityTitle;\n }\n\n public function wasRecentlyCreated(): bool\n {\n return $this->wasRecentlyCreated;\n }\n\n public function getProspectTypeAttribute()\n {\n $prospectType = null;\n\n if ($this->lead_id) {\n $prospectType = 'Lead';\n } elseif ($this->contact_id) {\n $prospectType = 'Contact';\n } elseif ($this->account_id) {\n $prospectType = 'Account';\n }\n\n return $prospectType;\n }\n\n /**\n * Return the best match for prospect. Results are in the following order of priority:\n * 1. Lead\n * 2. Contact\n * 3. Account\n * 4. NULL\n */\n public function getProspectAttribute(): ?ProspectInterface\n {\n if ($this->hasLead()) {\n return $this->getLead();\n }\n\n if ($this->hasContact()) {\n return $this->getContact();\n }\n\n if ($this->hasAccount()) {\n return $this->getAccount();\n }\n\n return null;\n }\n\n public function getTitleAttribute($value): ?string\n {\n return \\getActivityTitleAttribute(\n $this->user->name,\n $this->getType(),\n $value,\n $this->prospect->name ?? null,\n $this->from->national_phone_number ?? null\n );\n }\n\n public function getTitle(): ?string\n {\n return $this->getAttribute('title');\n }\n\n public function getSummary(): ?string\n {\n return $this->getAttribute('summary');\n }\n\n public function isInternal(): bool\n {\n return $this->getAttribute('is_internal');\n }\n\n public function getIsPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n public function getDescription(): ?string\n {\n return $this->getAttribute('description');\n }\n\n public function hasTitle(): bool\n {\n return $this->getOriginal('title') !== null;\n }\n\n public function getPlayCountAttribute()\n {\n return $this->getPlaysCountAttribute();\n }\n\n public function getPlaysCountAttribute()\n {\n if (! isset($this->attributes['plays_count'])) {\n $this->loadCount('plays');\n }\n\n return $this->attributes['plays_count'];\n }\n\n public function getCommentCountAttribute()\n {\n return $this->getCommentsCountAttribute();\n }\n\n public function getCommentsCountAttribute()\n {\n if (! isset($this->attributes['comments_count'])) {\n $this->loadCount('comments');\n }\n\n return $this->attributes['comments_count'];\n }\n\n public function getVisibleCommentsCountAttribute()\n {\n if (! isset($this->attributes['visible_comments_count'])) {\n $activityCommentsService = app(ActivityCommentService::class);\n $user = Auth::user() instanceof User ? Auth::user() : null;\n $this->attributes['visible_comments_count'] = $activityCommentsService\n ->getVisibleCommentsCount($this, $user);\n }\n\n return $this->attributes['visible_comments_count'];\n }\n\n public function getShareCountAttribute()\n {\n return $this->getSharesCountAttribute();\n }\n\n public function getSharesCountAttribute()\n {\n if (! isset($this->attributes['shares_count'])) {\n $this->loadCount('shares');\n }\n\n return $this->attributes['shares_count'];\n }\n\n\n /**\n * Get the count of favorites playlists this activity appears in\n */\n public function getFavoriteCountAttribute(): int\n {\n return $this->getFavoritesCountAttribute();\n }\n\n public function getFavoritesCountAttribute()\n {\n if (! isset($this->attributes['favorites_count'])) {\n $this->loadCount('favorites');\n }\n\n return $this->attributes['favorites_count'];\n }\n\n public function getActiveParticipantsCountAttribute()\n {\n if (! isset($this->attributes['active_participants_count'])) {\n $this->loadCount('activeParticipants');\n }\n\n return $this->attributes['active_participants_count'];\n }\n\n public function getTracksWithTelephonyCountAttribute()\n {\n if (! isset($this->attributes['tracks_with_telephony_count'])) {\n $this->loadCount('tracksWithTelephony');\n }\n\n return $this->attributes['tracks_with_telephony_count'];\n }\n\n /**\n * @TEMP\n * $this->loadCount('tracksWithTelephony') throws null pointer exception\n */\n public function countTracksWithTelephony(): int\n {\n return $this->tracks()->whereNotNull('telephony_provider_id')->count();\n }\n\n public function getDuration(): float\n {\n return $this->getAttribute('duration');\n }\n\n public function getDurationForHumansAttribute()\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);\n }\n\n public function getDurationForHumansShortAttribute(): string\n {\n return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);\n }\n\n public function hasRecordingPreference(): bool\n {\n return $this->getAttribute('recording_preference') !== null;\n }\n\n public function getRecordingPreference()\n {\n return $this->getAttribute('recording_preference');\n }\n\n /** @return BelongsTo<User, self> */\n public function user(): BelongsTo\n {\n return $this->belongsTo(User::class)->with('group');\n }\n\n public function device()\n {\n return $this->belongsTo(Device::class);\n }\n\n public function category()\n {\n return $this->belongsTo(PlaybookCategory::class, 'playbook_category_id');\n }\n\n public function getCategory(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function getPlaybookCategoryId(): ?int\n {\n return $this->getAttribute('playbook_category_id');\n }\n\n public function hasStats(): bool\n {\n return $this->getAttribute('stats') !== null;\n }\n\n public function getStats(): ?Stats\n {\n return $this->getAttribute('stats');\n }\n\n public function stats(): HasOne\n {\n return $this->hasOne(Stats::class);\n }\n\n public function participantStats(): Eloquent\\Relations\\HasManyThrough\n {\n return $this->hasManyThrough(\n Models\\Participant\\ParticipantStats::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantStats(): Eloquent\\Collection\n {\n return $this->getAttribute('participantStats');\n }\n\n public function account()\n {\n return $this->belongsTo(Account::class);\n }\n\n public function contact()\n {\n return $this->belongsTo(Contact::class)->with(['account']);\n }\n\n public function lead()\n {\n return $this->belongsTo(Lead::class)->with(['stage', 'recordType']);\n }\n\n /**\n * @return BelongsTo<Opportunity, self>\n */\n public function opportunity(): BelongsTo\n {\n /** @var BelongsTo<Opportunity, self> */\n return $this->belongsTo(Opportunity::class);\n }\n\n public function stage()\n {\n return $this->belongsTo(Stage::class);\n }\n\n /**\n * @return HasMany<Session>\n */\n public function sessions(): HasMany\n {\n return $this->hasMany(Session::class);\n }\n\n /**\n * @return HasMany|ParticipantSpeech[]|Eloquent\\Collection\n */\n public function participantSpeeches()\n {\n return $this->hasMany(ParticipantSpeech::class);\n }\n\n public function getParticipantSpeeches(): Eloquent\\Collection\n {\n return $this->getAttribute('participantSpeeches');\n }\n\n /**\n * @return HasMany|Log[]|Eloquent\\Collection\n */\n public function logs()\n {\n return $this->hasMany(Log::class);\n }\n\n /**\n * @return HasMany|Moment[]|Eloquent\\Collection\n */\n public function moments()\n {\n return $this->hasMany(Moment::class);\n }\n\n /**\n * @return HasMany|Note[]|Eloquent\\Collection\n */\n public function notes()\n {\n return $this->hasMany(Note::class);\n }\n\n /**\n * @return Eloquent\\Collection|Note[]\n */\n public function getNotes(): Eloquent\\Collection\n {\n return $this->getAttribute('notes');\n }\n\n /**\n * @return HasMany|Message[]|Eloquent\\Collection\n */\n public function messages()\n {\n return $this->hasMany(Message::class);\n }\n\n public function coachingMessages(): HasMany\n {\n return $this->hasMany(Message::class)\n ->where('is_private', 1);\n }\n\n public function getCoachingMessages(): Eloquent\\Collection\n {\n return $this->getAttribute('coachingMessages');\n }\n\n public function participants(): HasMany\n {\n return $this->hasMany(Participant::class);\n }\n\n public function getSnapshots(): Eloquent\\Collection\n {\n return $this->getAttribute('snapshots');\n }\n\n /** @return HasMany<Track> */\n public function tracks(): HasMany\n {\n return $this->hasMany(Track::class);\n }\n\n public function tracksWithTelephony(): HasMany\n {\n return $this->hasMany(Track::class)->whereNotNull('telephony_provider_id');\n }\n\n public function getTracksWithTelephony(): Eloquent\\Collection\n {\n return $this->getAttribute('tracksWithTelephony');\n }\n\n /** @return Collection|Track[] */\n public function getTracks(): Eloquent\\Collection\n {\n return $this->getAttribute('tracks');\n }\n\n public function masterTrack(): HasOne\n {\n return $this->hasOne(Track::class)->where('is_master', 1)\n ->whereIn('format', [Track::FORMAT_WAV, Track::FORMAT_M3U8])\n ->latest();\n }\n\n public function getMasterTrack(): ?Track\n {\n /** @var Track|null */\n return $this->getAttribute('masterTrack');\n }\n\n public function transcription(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Transcription::class, 'transcription_id');\n }\n\n public function findTranscriptionPromptSummaries(): Collection\n {\n $transcriptionId = $this->getTranscriptionId();\n if (is_null($transcriptionId)) {\n return new Collection();\n }\n\n return Models\\AiPrompt::query()\n ->where('transcription_id', $transcriptionId)\n ->get();\n }\n\n public function getTranscription(): Transcription\n {\n return $this->getAttribute('transcription');\n }\n\n public function hasTranscription(): bool\n {\n return $this->getAttribute('transcription') !== null;\n }\n\n public function setTranscriptionId(int $transcriptionId): Activity\n {\n $this->setAttribute('transcription_id', $transcriptionId);\n\n return $this;\n }\n\n public function unsetTranscriptionId(): self\n {\n $this->setAttribute('transcription_id', null);\n\n return $this;\n }\n\n public function getTranscriptionId(): ?int\n {\n return $this->getAttribute('transcription_id');\n }\n\n /** @deprecated */\n public function hasTranscriptionId(): bool\n {\n return $this->getAttribute('transcription_id') !== null;\n }\n\n public function coachRequests()\n {\n return $this->hasMany(CoachRequest::class);\n }\n\n public function availabilityNotifications()\n {\n return $this->hasMany(AvailabilityNotification::class);\n }\n\n public function processingStates()\n {\n return $this->hasMany(Models\\Activity\\ActivityProcessingState::class);\n }\n\n public function uploadSettings()\n {\n return $this->hasMany(ActivityUploadSetting::class);\n }\n\n public function comments()\n {\n return $this->hasMany(Comment::class);\n }\n\n public function getComments(): Eloquent\\Collection\n {\n return $this->getAttribute('comments');\n }\n\n public function visibleComments()\n {\n $rel = $this->hasMany(Comment::class);\n // Doesn't have auth()->user() in some tests, breaks the build\n if ($user = auth()->user()) {\n return $rel->visibleThreads($user->id);\n }\n\n return $rel;\n }\n\n public function snapshots(): HasMany\n {\n return $this->hasMany(Snapshot::class);\n }\n\n public function calendarEvent()\n {\n return $this->belongsTo(CalendarEvent::class);\n }\n\n public function getCalendarEvent(): ?CalendarEvent\n {\n return $this->getAttribute('calendarEvent');\n }\n\n public function latestCoachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class)->latest();\n }\n\n public function playlists(): BelongsToMany\n {\n return $this->belongsToMany(Playlist::class, 'playlist_activities')\n ->withPivot('id', 'uuid', 'user_id', 'start_time', 'end_time')\n ->using(PlaylistActivity::class)\n ->withTimestamps();\n }\n\n public function coachingFeedbacks(): HasMany\n {\n return $this->hasMany(CoachingFeedback::class);\n }\n\n /**\n * @return Eloquent\\Collection|CoachingFeedback[]\n */\n public function getCoachingFeedback(?int $visibility = null): Eloquent\\Collection\n {\n $feedbacks = $this->coachingFeedbacks();\n if ($visibility !== null) {\n $feedbacks = $feedbacks->where('visibility', $visibility);\n }\n\n return $feedbacks->get();\n }\n\n /** @return Eloquent\\Collection<int, PlaylistActivity> */\n public function favoritedBy(User $user): Eloquent\\Collection\n {\n return $this->favorites()->where('user_id', $user->getId())->get();\n }\n\n /**\n * Checks whether consumer has added this activity to their favorites playlist\n * In addition a default playlist gets created if not already present\n */\n public function wasFavoritedBy(User $user): bool\n {\n $playlist = $user->favoritePlaylist();\n\n return $playlist\n ->activities()\n ->where('activity_id', '=', $this->getId())\n ->exists();\n }\n\n /**\n * @return HasMany<PlaylistActivity>\n */\n public function playlistActivities(): HasMany\n {\n return $this->hasMany(PlaylistActivity::class);\n }\n\n /**\n * @return HasManyThrough<Playlist>\n */\n public function favoritePlaylists(): HasManyThrough\n {\n return $this->hasManyThrough(\n Playlist::class,\n PlaylistActivity::class,\n 'activity_id',\n 'id',\n 'id',\n 'playlist_id'\n )->where('is_default', 1);\n }\n\n /**\n * @return Eloquent\\Collection<int, Playlist>\n */\n public function getFavoritePlaylists(): Eloquent\\Collection\n {\n return $this->getAttribute('favoritePlaylists');\n }\n\n /**\n * Get activities from the default/favorite playlist\n *\n * @return Eloquent\\Builder|static\n */\n public function favorites()\n {\n return $this->playlistActivities()->whereHas('playlist', function ($query) {\n $query->where('is_default', 1);\n });\n }\n\n /**\n * @return Model|SubscriptionSet|null|object\n */\n public function subscribedBy(User $user)\n {\n if ($this->prospect === null) {\n return null;\n }\n\n return SubscriptionSet::select('activity_subscription_sets.*')\n ->where('user_id', $user->id)\n ->join('activity_subscriptions', function ($join) {\n $join\n ->on('subscription_set_id', '=', 'activity_subscription_sets.id');\n\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $join\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $join\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $join\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $join\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n }\n })\n ->first();\n }\n\n /**\n * @return array|Eloquent\\Builder[]|Eloquent\\Collection|SubscriptionSet[]\n */\n public function subscribers()\n {\n if ($this->prospect === null) {\n return [];\n }\n\n return SubscriptionSet::with(['subscriptions', 'user'])\n ->whereHas('subscriptions', function ($query) {\n if ($this->account_id) {\n if ($this->opportunity_id) {\n $query\n ->where('followable_type', 'opportunity')\n ->where('followable_id', $this->opportunity_id);\n } else {\n $query\n ->where('followable_type', 'account')\n ->where('followable_id', $this->account_id);\n }\n } elseif ($this->contact_id) {\n $query\n ->where('followable_type', 'contact')\n ->where('followable_id', $this->contact_id);\n } elseif ($this->lead_id) {\n $query\n ->where('followable_type', 'lead')\n ->where('followable_id', $this->lead_id);\n } else {\n // Nothing to join on?\n // refactor - use Jiminny specific exception\n throw new InvalidArgumentException('Cannot join on a specific customer filter.');\n }\n })\n ->whereHas('user', function ($query) {\n $query\n ->where('team_id', $this->user->team_id)\n ->where('status', User::STATUS_ACTIVE);\n })\n ->get();\n }\n\n /**\n * @return HasMany|Builder|Eloquent\\Collection|Play[]\n */\n public function plays()\n {\n return $this->hasMany(Play::class);\n }\n\n public function getPlays(): Eloquent\\Collection\n {\n return $this->getAttribute('plays');\n }\n\n public function playsBy(User $user)\n {\n /** @var Builder $builder */\n $builder = $this->plays()->where('user_id', $user->id);\n\n return $builder->get();\n }\n\n /**\n * Check if activity was played by a user\n */\n public function wasPlayedBy(User $user): bool\n {\n return $this->plays()->where('user_id', $user->id)->exists();\n }\n\n public function shares()\n {\n return $this->hasMany(Share::class);\n }\n\n /** @return BelongsTo<Participant, self> */\n public function from(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'from_participant_id');\n }\n\n /** @return BelongsTo<Participant, self> */\n public function to(): BelongsTo\n {\n return $this->belongsTo(Participant::class, 'to_participant_id');\n }\n\n /**\n * Get all of the connections through the participants.\n */\n public function connections()\n {\n return $this->hasManyThrough(\n Connection::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getConnections(): Eloquent\\Collection\n {\n return $this->getAttribute('connections');\n }\n\n /**\n * Get all of the shares through the participants.\n */\n public function participantShares()\n {\n return $this->hasManyThrough(\n Participant\\Share::class,\n Participant::class,\n 'activity_id',\n 'participant_id'\n );\n }\n\n public function getParticipantShares(): Eloquent\\Collection\n {\n return $this->getAttribute('participantShares');\n }\n\n public function topicTriggers(): HasMany\n {\n return $this->hasMany(TopicTrigger::class);\n }\n\n public function activityScorecardRuleTriggers(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRuleTrigger::class);\n }\n\n public function activityScorecardRules(): HasMany\n {\n return $this->hasMany(Models\\Scorecard\\ActivityScorecardRule::class);\n }\n\n public function questions(): HasMany\n {\n return $this->hasMany(Question::class);\n }\n\n /**\n * Get all the custom data attached to it.\n */\n public function data(): HasMany\n {\n return $this->hasMany(FieldData::class);\n }\n\n public function getData(): Eloquent\\Collection\n {\n /** @var Eloquent\\Collection */\n return $this->getAttribute('data');\n }\n\n #[Scope]\n protected function heldBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('actual_start_date', '>=', $from)\n ->where('actual_end_date', '<=', $until);\n }\n\n #[Scope]\n protected function scheduledBetween($query, Carbon $start, Carbon $end)\n {\n // Sanity check.\n $from = min($start, $end);\n $until = max($start, $end);\n\n return $query\n ->where('scheduled_start_date', '>=', $from)\n ->where('scheduled_end_date', '<=', $until);\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function forTeam(Builder $query, int $teamId): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas('user', static function (Builder $query) use ($teamId): void {\n $query->where('team_id', $teamId);\n });\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function inOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->whereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query\n ->where('is_closed', false)\n ->where('deleted_at', '=', null),\n );\n }\n\n /**\n * @param Builder<self> $query\n *\n * @return Builder<self>\n */\n #[Scope]\n protected function notInOpenDeals(Builder $query): Builder\n {\n /** @var Builder<self> */\n return $query->where(\n static fn (Builder $query): Builder => $query->whereNull('opportunity_id')\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->where('is_closed', true),\n )\n ->orWhereHas(\n 'opportunity',\n static fn (Builder $query): Builder => $query->withTrashed()->where('deleted_at', '!=', null),\n ),\n );\n }\n\n /**\n * Finds a participant and updates it with data. If participant doesn't exist creates a new participant from data.\n *\n * @param array $data participant data used to identify the participant and update it\n * @param bool $enterRoom true if participant is entering the room. false if we just want to update some participant data\n * @param Carbon|null $enterTime if $enterNow is true then this is the join time when the actual enter has occurred\n */\n public function updateOrCreateParticipant(\n array $data,\n bool $enterRoom = true,\n ?Carbon $enterTime = null,\n bool $nameMatching = false,\n ): Participant {\n $search = [];\n $participant = null;\n\n if (isset($data['user_id'])) {\n // Check if they already exist based on their ID.\n $search['user_id'] = $data['user_id'];\n } elseif (isset($data['provider_id'])) {\n $search['provider_id'] = $data['provider_id'];\n } elseif ($nameMatching && isset($data['name'])) {\n $search['name'] = $data['name'];\n }\n\n if (! empty($data['email'])) {\n $search['email'] = $data['email'];\n\n // If we have their email, this should be unique enough to lookup (e.g. calendar event based participant).\n unset($search['provider_id']);\n }\n\n // Search by phone number only in case nothing else is available to search by.\n if (array_key_exists('phone_number', $data) && empty($search)) {\n $search['phone_number'] = $data['phone_number'];\n }\n\n if (! empty($search)) {\n // Do a lookup now to see if we have a match on the provided data.\n $lookup = array_map(static function ($key, $value): array {\n return [$key, $value];\n }, array_keys($search), $search);\n\n $participant = $this->participants()->withTrashed()->where($lookup)->first();\n }\n\n // Do a partial match on the name and search in the team members.\n if (! $participant instanceof Participant && $nameMatching && ! empty($data['name'])) {\n $participantMatcher = app(MeetingBot\\Service\\ParticipantMatcher::class);\n\n if (! $participantMatcher instanceof MeetingBot\\Service\\ParticipantMatcher) {\n throw new LogicException('Expecting ParticipantMatcher service instance');\n }\n\n $participant = $participantMatcher->match($this, $data['name']);\n\n // If we've found good participant, avoid data overwrite in `$participant->fill($data)` below.\n if ($participant instanceof Models\\Participant && $participant->hasName()) {\n unset($data['name']); // Thoughts: should we unset also $data['user_id'] and $data['email'] ?\n }\n }\n\n if (! $participant instanceof Participant) {\n // If no match, create a new participant.\n if (empty($search)) {\n $participant = $this->participants()->create();\n } else {\n // If no match, create a new participant but avoid creating duplicates\n $participant = $this->participants()->withTrashed()->firstOrNew($search);\n }\n }\n\n // If we have just recycled a deleted participant\n if ($participant->trashed()) {\n $participant->deleted_at = null;\n }\n\n // Deal with the case when calendar syncs the event while it's in progress.\n // We should prevent change of the participant name, because speeches mapping will fail.\n if ($enterRoom === false\n && $this->isInProgress()\n && $participant->hasName()\n && isset($data['name'])\n && $data['name'] !== $participant->getName()\n ) {\n unset($data['name']);\n }\n\n // Upsert with new data.\n $participant->fill($data);\n\n if ($enterRoom) {\n if ($enterTime === null) {\n $enterTime = now();\n }\n\n // Participant enters room for the first time\n if ($participant->enter_time === null) {\n $participant->enter_time = $enterTime;\n }\n\n // If there is an exit time and it's prior to new enter_time\n if ($participant->exit_time && $participant->exit_time->lt($enterTime)) {\n // Participant has re-joined\n $participant->exit_time = null;\n }\n }\n\n $participant->save();\n\n return $participant;\n }\n\n /**\n * Updates participant CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n * @param Participant $participant participant the CRM data is associated with\n */\n public function updateParticipantCrmData(array $records, Participant $participant): void\n {\n // Extract the records.\n [$lead, , , $contact] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForParticipant($lead, $contact);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n if (! $participant->hasName()) {\n $participant->name = $lead->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $lead->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $lead->phone;\n }\n\n $participant->lead_id = $lead->id;\n $participant->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n if (! $participant->hasName()) {\n $participant->name = $contact->name;\n }\n\n if (! $participant->hasEmailAddress()) {\n $participant->email = $contact->email;\n }\n\n if (! $participant->hasPhoneNumber()) {\n $participant->phone_number = $contact->phone;\n }\n\n $participant->contact_id = $contact->id;\n $participant->save();\n }\n }\n\n /**\n * Updates activity CRM data\n *\n * @param array{\n * Lead|null,\n * Account|null,\n * Opportunity|null,\n * Contact|null,\n * Stage|null,\n * string|null\n *} $records\n */\n public function updateActivityCrmData(array $records): void\n {\n // Extract the records.\n [$lead, $account, $opportunity, $contact, $stage] = $records;\n\n $resolver = $this->getUpdateCrmDataResolver();\n $strategy = $resolver->resolveForActivity($lead, $contact, $account);\n\n if ($strategy == UpdateCrmDataByStrategy::Lead) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n if ($this->account_id === null && $this->contact_id === null && $this->lead_id === null) {\n $this->lead_id = $lead->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n $this->save();\n }\n } elseif ($strategy == UpdateCrmDataByStrategy::Contact) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Don't trust previous matched account_id as it might have been changed in the CRM\n if ($account && $account->id !== $this->account_id) {\n $this->account_id = $account->id;\n }\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($opportunity && $this->opportunity_id !== $opportunity->id) {\n $this->opportunity_id = $opportunity->id;\n }\n\n if ($opportunity && $this->value !== $opportunity->value) {\n $this->value = $opportunity->value;\n }\n\n // Always set contact_id when available, regardless of account_id status\n if ($this->contact_id === null && $contact) {\n $this->contact_id = $contact->id;\n }\n\n $this->save();\n } elseif ($strategy == UpdateCrmDataByStrategy::Account && $this->account_id === null) {\n // Also update the parent activity if required, checking we don't create a mixed lead/account record.\n $this->lead_id = null;\n if ($this->stage && $this->stage->getType() === Stage::TYPE_LEAD) {\n $this->stage_id = null;\n }\n\n // Update the account and opportunity on the activity record if possible.\n $this->account_id = $account->id;\n\n if ($this->stage_id === null && $stage) {\n $this->stage_id = $stage->id;\n }\n\n if ($this->opportunity_id === null && $opportunity) {\n $this->opportunity_id = $opportunity->id;\n $this->value = $opportunity->value;\n }\n\n $this->save();\n }\n }\n\n public function getActivityProspectData(): array\n {\n return [\n 'lead' => $this->lead_id,\n 'contact' => $this->contact_id,\n 'account' => $this->account_id,\n 'opportunity' => $this->opportunity_id,\n 'stage' => $this->stage_id,\n ];\n }\n\n public function isOrganizer(User $user): bool\n {\n return $this->user_id && $this->user_id === $user->id;\n }\n\n public function isJoinable(): bool\n {\n return \\in_array($this->status, [\n self::STATUS_SCHEDULED,\n self::STATUS_PENDING,\n self::STATUS_RINGING,\n self::STATUS_IN_PROGRESS,\n ], true);\n }\n\n public function isAttemptedForBotJoin(): bool\n {\n return in_array($this->getAttribute('status'), self::MEETING_BOT_JOIN_ATTEMPTED, true);\n }\n\n /**\n * Check if the activity can be saved to CRM (manual or autolog)\n */\n public function isLoggable(): bool\n {\n if ($this->getUser()->getTeam()->hasFeature(FeatureEnum::SIDEKICK_SETTINGS)) {\n $sidekickService = app(SidekickService::class);\n\n if (! $sidekickService->isSidekickEnabledForUser($this->getUser())) {\n return false;\n }\n }\n\n // If we don't know the activity type, don't try to log.\n if ($this->playbook_category_id === null) {\n return false;\n }\n\n if ($this->user->crm_required === false) {\n return false;\n }\n\n // Don't prompt for internal meetings.\n if ($this->is_internal) {\n return false;\n }\n\n // If we don't know who we are trying to log to, don't try to log.\n if ($this->prospect === null) {\n return false;\n }\n\n $validStatus = false;\n switch ($this->type) {\n case self::TYPE_SOFTPHONE:\n case self::TYPE_SOFTPHONE_INBOUND:\n $validStatus = true;\n\n break;\n case self::TYPE_CONFERENCE:\n $validStatus = in_array($this->status, [\n self::STATUS_BUSY,\n self::STATUS_NO_ANSWER,\n self::STATUS_COMPLETED,\n self::STATUS_CANCELLED,\n ], true);\n\n break;\n case self::TYPE_SMS_INBOUND:\n case self::TYPE_SMS_OUTBOUND:\n $validStatus = in_array($this->status, [\n self::STATUS_QUEUED,\n self::STATUS_SENT,\n self::STATUS_UNDELIVERED,\n self::STATUS_DELIVERED,\n self::STATUS_RECEIVED,\n ], true);\n\n break;\n }\n\n // Depending on the activity channel, we should not try to log.\n return $validStatus;\n }\n\n public function isScheduled(): bool\n {\n return $this->status === self::STATUS_SCHEDULED;\n }\n\n public function scheduledDuration(): int\n {\n if ($this->scheduled_start_time && $this->scheduled_end_time) {\n return $this->scheduled_end_time->timestamp - $this->scheduled_start_time->timestamp;\n }\n\n return 0;\n }\n\n public function isPending(): bool\n {\n return $this->status === self::STATUS_PENDING;\n }\n\n public function isCompleted(): bool\n {\n return $this->status === self::STATUS_COMPLETED;\n }\n\n public function isRinging(): bool\n {\n return $this->status === self::STATUS_RINGING;\n }\n\n public function isInProgress(): bool\n {\n return $this->status === self::STATUS_IN_PROGRESS;\n }\n\n public function isBusy(): bool\n {\n return $this->status === self::STATUS_BUSY;\n }\n\n public function isNoAnswer(): bool\n {\n return $this->status === self::STATUS_NO_ANSWER;\n }\n\n public function isFailed(): bool\n {\n return $this->status === self::STATUS_FAILED;\n }\n\n public function isCancelled(): bool\n {\n return $this->status === self::STATUS_CANCELLED;\n }\n\n public function hasEnded(int $gracePeriodMinutes = 15): bool\n {\n if ($this->isCompleted()) {\n return true;\n }\n\n if (($this->isFailed() || $this->isCancelled()) && $this->hasScheduledEndTime()) {\n return $this->getScheduledEndTime()->addMinutes($gracePeriodMinutes)->isPast();\n }\n\n return false;\n }\n\n public function hasStarted(): bool\n {\n return $this->hasActualStartTime();\n }\n\n public function isOngoing(): bool\n {\n return $this->hasActualStartTime() && ! $this->hasActualEndTime();\n }\n\n public function isTypeSmsInbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_INBOUND;\n }\n\n public function isTypeSmsOutbound(): bool\n {\n return $this->getType() === self::TYPE_SMS_OUTBOUND;\n }\n\n public function isTypeSoftPhone(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE;\n }\n\n public function isTypeSoftphoneInbound(): bool\n {\n return $this->getType() === self::TYPE_SOFTPHONE_INBOUND;\n }\n\n public function isTypeConference(): bool\n {\n return $this->getType() === self::TYPE_CONFERENCE;\n }\n\n /**\n * Get a conference elapsed time in seconds.\n *\n * @return int seconds count\n */\n public function secondsTimeElapsed(): int\n {\n if (empty($this->actual_start_time)) {\n return 0;\n }\n\n // Get number of seconds since conference actual start time\n return (int) abs(Carbon::now()->diffInRealSeconds($this->actual_start_time));\n }\n\n /**\n * Get a conference elapsed time formatted as \"1:30:20\" if more than 1 hour or \"30:20\" otherwise.\n */\n public function formattedTimeElapsed(): string\n {\n // Get number of seconds since conference actual start time.\n $elapsedSeconds = $this->secondsTimeElapsed();\n $elapsedTime = Carbon::createFromTimestampUTC($elapsedSeconds);\n\n // Format conference start time.\n return $elapsedTime->format($elapsedSeconds < 3600 ? 'i:s' : 'G:i:s');\n }\n\n public function wasScheduled(): bool\n {\n return $this->calendarEvent !== null || in_array($this->getSource(), [self::SOURCE_OUTLOOK, self::SOURCE_GOOGLE]);\n }\n\n public function isInstant(): bool\n {\n return ! $this->wasScheduled();\n }\n\n /**\n * GETTERS AND SETTERS FOLLOW BELOW\n */\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getFromParticipantId(): ?int\n {\n return $this->getAttribute('from_participant_id');\n }\n\n public function getFromParticipant(): ?Participant\n {\n return $this->getAttribute('from');\n }\n\n public function getToParticipantId(): ?int\n {\n return $this->getAttribute('to_participant_id');\n }\n\n public function getToParticipant(): ?Participant\n {\n return $this->getAttribute('to');\n }\n\n public function hasScheduledStartTime(): bool\n {\n return $this->getAttribute('scheduled_start_time') !== null;\n }\n\n public function getScheduledStartTime(): ?Carbon\n {\n return $this->getAttribute('scheduled_start_time');\n }\n\n public function setScheduledStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_start_time', $dateTime);\n\n return $this;\n }\n\n public function getScheduledEndTime(): ?DateTimeInterface\n {\n return $this->getAttribute('scheduled_end_time');\n }\n\n public function hasScheduledEndTime(): bool\n {\n return $this->getAttribute('scheduled_end_time') !== null;\n }\n\n public function setScheduledEndTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('scheduled_end_time', $dateTime);\n\n return $this;\n }\n\n public function getActualStartTime(): ?Carbon\n {\n return $this->getAttribute('actual_start_time');\n }\n\n public function hasActualStartTime(): bool\n {\n return $this->getAttribute('actual_start_time') !== null;\n }\n\n public function getActualEndTime(): ?Carbon\n {\n return $this->getAttribute('actual_end_time');\n }\n\n public function hasActualEndTime(): bool\n {\n return $this->getAttribute('actual_end_time') !== null;\n }\n\n public function getType(): ?string\n {\n return $this->getAttribute('type');\n }\n\n public function getStatus(): string\n {\n return $this->getAttribute('status');\n }\n\n public function setStatus(string $status): self\n {\n $this->setAttribute('status', $status);\n\n return $this;\n }\n\n public function setActualStartTime(DateTimeInterface $dateTime): self\n {\n $this->setAttribute('actual_start_time', $dateTime);\n\n return $this;\n }\n\n public function setActualEndTime(DateTimeInterface $dateTime, bool $shouldUpdateDuration = true): self\n {\n $this->setAttribute('actual_end_time', $dateTime);\n\n if (! $shouldUpdateDuration) {\n return $this;\n }\n\n return $this->updateDuration();\n }\n\n public function updateDuration(): self\n {\n if (! $this->hasActualStartTime() || ! $this->hasActualEndTime()) {\n return $this;\n }\n\n return $this->setDuration(\n (int) abs($this->getActualStartTime()->diffInRealSeconds($this->getActualEndTime()))\n );\n }\n\n public function setDuration(int $duration): self\n {\n $this->setAttribute('duration', $duration);\n\n return $this;\n }\n\n public function getRecordingState(): string\n {\n return $this->getAttribute('recording_state');\n }\n\n public function isRecordingState(string $recordingState): bool\n {\n return $this->getRecordingState() === $recordingState;\n }\n\n public function setRecordingState(string $recordingState): self\n {\n $this->setAttribute('recording_state', $recordingState);\n\n return $this;\n }\n\n public function hasActivityType(): bool\n {\n return $this->getAttribute('category') !== null;\n }\n\n public function getActivityType(): ?PlaybookCategory\n {\n return $this->getAttribute('category');\n }\n\n public function setActivityType(int $playbookCategoryId): self\n {\n $this->setAttribute('playbook_category_id', $playbookCategoryId);\n\n return $this;\n }\n\n public function hasStage(): bool\n {\n return $this->getAttribute('stage') !== null;\n }\n\n public function getStage(): ?Stage\n {\n return $this->getAttribute('stage');\n }\n\n public function getStageId(): ?int\n {\n return $this->getAttribute('stage_id');\n }\n\n public function setStageId(?int $stageId): void\n {\n $this->setAttribute('stage_id', $stageId);\n }\n\n public function hasOpportunity(): bool\n {\n return $this->getAttribute('opportunity') !== null;\n }\n\n public function getOpportunity(): ?Opportunity\n {\n return $this->getAttribute('opportunity');\n }\n\n public function getOpportunityId(): ?int\n {\n return $this->getAttribute('opportunity_id');\n }\n\n public function setOpportunityId(?int $opportunityId): void\n {\n $this->setAttribute('opportunity_id', $opportunityId);\n }\n\n public function hasContact(): bool\n {\n return $this->getAttribute('contact') !== null;\n }\n\n public function getContact(): ?Contact\n {\n return $this->getAttribute('contact');\n }\n\n public function getContactId(): ?int\n {\n return $this->getAttribute('contact_id');\n }\n\n public function setContactId(?int $contactId): void\n {\n $this->setAttribute('contact_id', $contactId);\n }\n\n public function hasLead(): bool\n {\n return $this->getAttribute('lead') !== null;\n }\n\n public function getLead(): ?Lead\n {\n return $this->getAttribute('lead');\n }\n\n public function getLeadId(): ?int\n {\n return $this->getAttribute('lead_id');\n }\n\n public function setLeadId(?int $leadId): void\n {\n $this->setAttribute('lead_id', $leadId);\n }\n\n public function hasAccount(): bool\n {\n return $this->getAttribute('account') !== null;\n }\n\n public function getAccount(): ?Account\n {\n return $this->getAttribute('account');\n }\n\n public function getAccountId(): ?int\n {\n return $this->getAttribute('account_id');\n }\n\n public function setAccountId(?int $accountId): void\n {\n $this->setAttribute('account_id', $accountId);\n }\n\n /**\n * This method exists to avoid confusion using ->participants() or ->participants. Use the getter instead.\n *\n * @return Collection<int, Participant>|Participant[]\n */\n public function getParticipants(): Collection\n {\n return $this->participants;\n }\n\n /**\n * @deprecated use ParticipantRepository::findParticipantRoomOwner() instead\n */\n public function findParticipantRoomOwner(): ?Participant\n {\n $roomOwnerId = $this->getUserId();\n\n return $this->getParticipants()\n ->filter(static fn (Participant $participant): bool => $participant->isSameUserId($roomOwnerId))\n ->first();\n }\n\n public function hasCrmProviderId(): bool\n {\n return $this->getAttribute('crm_provider_id') !== null;\n }\n\n public function getCrmProviderId(): ?string\n {\n return $this->getAttribute('crm_provider_id');\n }\n\n public function setCrmProviderId(?string $crmProviderId): void\n {\n $this->setAttribute('crm_provider_id', $crmProviderId);\n }\n\n public function getUserId(): ?int\n {\n return $this->getAttribute('user_id');\n }\n\n public function hasUser(): bool\n {\n return $this->user()->exists();\n }\n\n public function getUser(): User\n {\n return $this->getAttribute('user');\n }\n\n public function getCreatedAt(): Carbon\n {\n return $this->getAttribute('created_at');\n }\n\n public function isInFiniteState(): bool\n {\n return $this->isFiniteState($this->getStatus());\n }\n\n public function isFiniteState(string $status): bool\n {\n $finiteStates = self::FINITE_STATES[$this->getType()] ?? [];\n\n return in_array($status, $finiteStates, true);\n }\n\n public function getParticipant(Authenticatable $user): Participant\n {\n return $this->findParticipant($user);\n }\n\n public function findParticipant(Authenticatable $user): ?Participant\n {\n if ($user instanceof User) {\n /** @var User $user */\n return $this->participants()->where('user_id', '=', $user->getId())->first();\n }\n\n throw new LogicException(sprintf('Unsupported Authenticatable implementation %s', get_class($user)));\n }\n\n public function hasLanguageCode(): bool\n {\n return $this->getAttribute('language') !== null;\n }\n\n public function getLanguageCode(): ?string\n {\n /** @var string|null */\n return $this->getAttribute('language');\n }\n\n public function getLanguageCodeHyphenated(): string\n {\n return str_replace('_', '-', $this->getLanguageCode() ?? '');\n }\n\n public function getLanguageCodeLocale(): string\n {\n [ $language ] = explode('_', $this->getLanguageCode() ?? '');\n\n return $language;\n }\n\n public function setLanguageCode(string $value): self\n {\n return $this->setAttribute('language', $value);\n }\n\n public function hasSource(): bool\n {\n return $this->getAttribute('source') !== null;\n }\n\n public function setSource(?string $source): self\n {\n return $this->setAttribute('source', $source);\n }\n\n public function isSource(string $source): bool\n {\n return $this->getAttribute('source') === $source;\n }\n\n public function getSource(): ?string\n {\n return $this->getAttribute('source');\n }\n\n public function isSourceGong(): bool\n {\n return $this->isSource(self::SOURCE_GONG);\n }\n\n public function getExternalId(): ?string\n {\n return $this->getAttribute('external_id');\n }\n\n public function setExternalId(?string $externalId): self\n {\n return $this->setAttribute('external_id', $externalId);\n }\n\n public function hasExternalId(): bool\n {\n return $this->getAttribute('external_id') !== null;\n }\n\n public function getProvider(): string\n {\n return $this->getAttribute('provider');\n }\n\n public function hasTelephonyProviderId(): bool\n {\n return $this->getAttribute('telephony_provider_id') !== null;\n }\n\n public function getTelephonyProviderId(): ?string\n {\n return $this->getAttribute('telephony_provider_id');\n }\n\n public function setTelephonyProviderId(?string $telephonyProviderId): self\n {\n return $this->setAttribute('telephony_provider_id', $telephonyProviderId);\n }\n\n public function getLocation(): ?string\n {\n return $this->getAttribute('location');\n }\n\n public function setLocation(?string $location): self\n {\n return $this->setAttribute('location', $location);\n }\n\n public function isDeleted(): bool\n {\n return $this->getAttribute('deleted_at') !== null;\n }\n\n /**\n * Check if activity recording is on and activity status is not one of the failed statuses.\n */\n public function canReviewActivity(): bool\n {\n $failedStatuses = self::$enumFailedStatuses;\n\n return (! in_array($this->recording_state, [self::RECORDING_OFF, self::RECORDING_STOPPED], true) &&\n ! in_array($this->status, $failedStatuses, true));\n }\n\n public function hasReasonCodeBotKicked(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_MEETING_BOT_KICKED);\n }\n\n public function hasReasonCodeNotCompliant(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_CONSENT_DENIED);\n }\n\n public function hasTopicTriggers(): bool\n {\n return $this->topicTriggers()->count() !== 0;\n }\n\n public function getTopicTriggers(): Collection\n {\n return $this->topicTriggers;\n }\n\n public function getTopicTriggersSorted(): Collection\n {\n $this->loadMissing([\n 'topicTriggers.participant',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic',\n 'topicTriggers.playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme',\n ]);\n\n return $this->topicTriggers\n ->sortBy([\n 'playbackThemeTopicTrigger.playbackThemeTopic.playbackTheme.sort',\n 'playbackThemeTopicTrigger.playbackThemeTopic.sort',\n 'playbackThemeTopicTrigger.sort',\n ]);\n }\n\n public function hasQuestions(): bool\n {\n return $this->questions()->exists();\n }\n\n public function getQuestions(): Collection\n {\n return $this->questions;\n }\n\n public function hasValue(): bool\n {\n return $this->getAttribute('value') !== null;\n }\n\n public function getValue(): ?float\n {\n return $this->getAttribute('value');\n }\n\n public function setValue(?float $value): void\n {\n $this->setAttribute('value', $value);\n }\n\n public function transitionTo(string $newState, callable $callback, ?int $timeout = null): self\n {\n $newState = $this->getWorkflowStateFor(\n $this->getType(),\n $newState\n );\n\n return $this->traitTransitionTo($newState, $callback, $timeout);\n }\n\n public function getWorkflowState(): string\n {\n return $this->getWorkflowStateFor(\n $this->getType(),\n $this->getStatus()\n );\n }\n\n public function getActivityProviderDisplayName(): string\n {\n return \\Cache::remember('activity_provider_display_name-' . $this->getProvider(), 60 * 60 * 24, function () {\n $activityProviderRegistry = app()->make(ActivityProviderRegistry::class);\n\n try {\n return $activityProviderRegistry->get($this->getProvider())->getDisplayName();\n } catch (Exception $exception) {\n return ucfirst($this->getProvider());\n }\n });\n }\n\n private function getWorkflowStateFor(string $activityChannel, string $activityStatus): string\n {\n return sprintf(\n '%s::%s',\n $activityChannel,\n $activityStatus\n );\n }\n\n public function getWorkflow(): array\n {\n $map = [\n self::TYPE_SOFTPHONE => [\n self::STATUS_SCHEDULED => [\n self::STATUS_PENDING,\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_PENDING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_RINGING => [\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_IN_PROGRESS,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n self::TYPE_SOFTPHONE_INBOUND => [\n self::STATUS_RINGING => [\n self::STATUS_IN_PROGRESS,\n self::STATUS_NO_ANSWER,\n self::STATUS_CANCELLED,\n self::STATUS_FAILED,\n self::STATUS_BUSY,\n ],\n self::STATUS_IN_PROGRESS => [\n self::STATUS_COMPLETED,\n ],\n ],\n ];\n\n return collect($map)\n ->mapWithKeys(function (array $currentStates, string $activityChannel): array {\n return [\n $activityChannel => collect($currentStates)\n ->mapWithKeys(function (array $possibleStates, $currentState) use ($activityChannel): array {\n $transitionName = $this->getWorkflowStateFor($activityChannel, $currentState);\n\n return [\n $transitionName => array_map(function (string $newState) use ($activityChannel) {\n return $this->getWorkflowStateFor($activityChannel, $newState);\n }, $possibleStates),\n ];\n }),\n ];\n })\n ->reduce(static function (array $carry, Collection $item): array {\n return array_merge($carry, $item->all());\n }, []);\n }\n\n public function hasPosterPath(): bool\n {\n return $this->getAttribute('poster_path') !== null;\n }\n\n public function getPosterPath(): ?string\n {\n return $this->getAttribute('poster_path');\n }\n\n /**\n * Take into account all recording settings and determine if we need to record this activity or not.\n */\n public function shouldRecord(): bool\n {\n return $this->determineRecordingReasonCode() === null;\n }\n\n public function determineRecordingReasonCode(): ?int\n {\n // Conference specific decisions.\n if ($this->isTypeConference()) {\n // If they have manually overridden the recording setting to not record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === false) {\n return self::FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE;\n }\n\n // If they have manually overridden the recording setting to record.\n if ($this->hasRecordingPreference() && $this->getRecordingPreference() === true) {\n return null;\n }\n\n // If their team has disabled recording meetings, don't record.\n if ($this->user->team->isConferenceRecordPreferenceDisabled()) {\n return self::FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED;\n }\n\n // If the host has disabled recording meetings, don't record.\n if ($this->user->checkConferenceRecordPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED;\n }\n\n // If it was marked internal...\n if ($this->is_internal) {\n // and their team has disabled recording internal meetings, don't record.\n if (\n $this->user->team->isConferenceRecordPreferenceEnabled()\n && ! $this->user->team->isConferenceRecordInternalPreferenceEnabled()\n ) {\n return self::FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED;\n }\n\n // and the host has disabled recording internal meetings, don't record.\n if ($this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED;\n }\n }\n\n // If it was not scheduled and they disabled internal meetings, we cannot determine if it was internal.\n if ($this->wasScheduled() === false && $this->user->checkConferenceRecordInternalPreference() === false) {\n return self::FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED;\n }\n }\n\n return null;\n }\n\n public function getRecordingReasonCode(): int\n {\n return $this->getAttribute('recording_reason_code');\n }\n\n public function setRecordingReasonCode(int $recordingReasonCode): self\n {\n $this->setAttribute('recording_reason_code', $recordingReasonCode);\n\n return $this;\n }\n\n // Not used today.\n public function getRecordingReasonString(): ?string\n {\n if ($this->hasRecordingReasonCompliancePrompted()) {\n return Team::COMPLIANCE_MODE_RECORDING_PROMPT;\n }\n\n if ($this->hasRecordingReasonComplianceRestricted()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT;\n }\n\n if ($this->hasRecordingReasonComplianceRestrictedToOneSideRecording()) {\n return Team::COMPLIANCE_MODE_RECORDING_RESTRICT_ONE_SIDE;\n }\n\n return null;\n }\n\n public function hasRecordingReasonComplianceRestricted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT);\n }\n\n public function hasRecordingReasonCompliancePrompted(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_PROMPT);\n }\n\n public function hasRecordingReasonComplianceRestrictedToOneSideRecording(): bool\n {\n return $this->getFlag('recording_reason_code', self::FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE);\n }\n\n public function getAudioTrack(): ?Track\n {\n /** @var Track|null */\n return $this->tracks()\n ->where('type', '=', Track::TYPE_AUDIO)\n ->first();\n }\n\n public function activeParticipants(): HasMany\n {\n return $this->hasMany(Participant::class)->active();\n }\n\n public function getActiveParticipants(): Eloquent\\Collection\n {\n return $this->getAttribute('activeParticipants');\n }\n\n public function crm(): Eloquent\\Relations\\BelongsTo\n {\n return $this->belongsTo(Configuration::class, 'crm_configuration_id');\n }\n\n public function activitySummaryLogs(): HasMany\n {\n return $this->hasMany(ActivitySummaryLog::class);\n }\n\n public function getCrm(): ?Configuration\n {\n return $this->getAttribute('crm');\n }\n\n public function hasCrmConfiguration(): bool\n {\n return $this->getAttribute('crm') !== null;\n }\n\n public function isProcessed(): ?bool\n {\n return $this->getAttribute('is_processed');\n }\n\n public function hasRecordingPrompt(): bool\n {\n return $this->getAttribute('has_recording_prompt') === true;\n }\n\n public function isOnAir(): bool\n {\n return $this->getAttribute('on_air') === self::ON_AIR_READY || $this->getAttribute('on_air') === self::ON_AIR_STREAMING;\n }\n\n public function setOnAir(int $onAir): self\n {\n $this->setAttribute('on_air', $onAir);\n\n return $this;\n }\n\n public function getOnAir(): ?int\n {\n return $this->getAttribute('on_air');\n }\n\n public function setTitleFromCallData(Call $call): void\n {\n $direction = $call->isOutbound() ? 'to' : 'from';\n\n $party = $this->prospect_name\n ?? $call->getContactName()\n ?? $call->getOtherPartyPhoneNumber()\n ;\n\n $this->update(['title' => sprintf('Call %s %s', $direction, $party)]);\n }\n\n /**\n * @param array{}|array{channels:string|null, format:string|null, type:string|null, status:string|null} $audioParams\n */\n public function createAudioTrack(\n string $telephonyProviderId,\n string $recordingUrl,\n array $audioParams = []\n ): Track {\n return $this->tracks()->updateOrCreate([\n 'telephony_provider_id' => $telephonyProviderId,\n ], [\n 'type' => $audioParams['type'] ?? Track::TYPE_AUDIO,\n 'status' => $audioParams['status'] ?? Track::STATUS_PENDING,\n 'format' => $audioParams['format'] ?? Track::FORMAT_WAV,\n 'provider_content_url' => $recordingUrl,\n 'start_time' => $this->actual_start_time,\n 'end_time' => $this->actual_end_time,\n ]);\n }\n\n public function createTrack(string $telephonyProviderId, array $params): Track\n {\n return $this->tracks()->updateOrCreate(\n [\n 'telephony_provider_id' => $telephonyProviderId,\n ],\n $params\n );\n }\n\n public function createOrganiserParticipant(Call $call): Participant\n {\n $user = $this->getUser();\n\n return $this->updateOrCreateParticipant([\n 'is_ghost' => 0,\n 'name' => $user->name,\n 'email' => $user->email,\n 'phone_number' => phone_e164(null, $call->getUserPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'user_id' => $user->id,\n ], false);\n }\n\n public function createProspectParticipant(Call $call): Participant\n {\n // not null 'name' is mandatory here to create a separate participant with 'nameMatching'\n // in case of the same phone_number with the Organiser\n $useNameMatching = $call->getUserPhoneNumber() === $call->getOtherPartyPhoneNumber();\n $defaultName = $useNameMatching ? '' : null;\n\n return $this->updateOrCreateParticipant(data: [\n 'is_ghost' => 0,\n 'name' => $this->prospect->name ?? $defaultName,\n 'email' => $this->prospect->email ?? null,\n 'phone_number' => phone_e164(null, $call->getOtherPartyPhoneNumber()),\n 'enter_time' => $this->actual_start_time,\n 'exit_time' => $this->actual_end_time,\n 'contact_id' => $this->contact_id ?? null,\n 'lead_id' => $this->lead_id ?? null,\n ], enterRoom: false, nameMatching: $useNameMatching);\n }\n\n public function updateParticipants(Participant $organiserParticipant, Participant $prospectParticipant): void\n {\n $this->update([\n 'from_participant_id' => $this->isTypeSoftPhone() ? $organiserParticipant->id : $prospectParticipant->id,\n 'to_participant_id' => $this->isTypeSoftPhone() ? $prospectParticipant->id : $organiserParticipant->id,\n ]);\n }\n\n public function hasProspect(): bool\n {\n return $this->getProspectAttribute() !== null;\n }\n\n public function isPrivate(): bool\n {\n return $this->getAttribute('is_private');\n }\n\n /** Create a new factory instance for the model. */\n protected static function newFactory(): Factory\n {\n return ActivityFactory::new();\n }\n\n public function getUpdatedAt(): Carbon\n {\n return $this->getAttribute('updated_at');\n }\n\n public function getActivitySummaryLogs(): Eloquent\\Collection\n {\n return $this->getAttribute('activitySummaryLogs');\n }\n\n public function hasProspectActivitySummaryLog(): bool\n {\n return $this->getActivitySummaryLogs()->contains(\n 'relation_type',\n ActivitySummaryLog::RELATION_OBJECT_TYPE_PROSPECT\n );\n }\n\n public function getTeam(): Team\n {\n return $this->getUser()->getTeam();\n }\n\n private function getUpdateCrmDataResolver(): UpdateCrmDataResolverInterface\n {\n $factory = app(UpdateCrmDataResolverFactory::class);\n\n return $factory->create($this);\n }\n\n public function getMeetingTrackProviderId(string $type): string\n {\n $label = match ($type) {\n Track::TYPE_VIDEO => 'v',\n Track::TYPE_AUDIO => 'a',\n default => throw new InvalidArgumentJiminnyException('Invalid track type'),\n };\n\n $startTimestamp = $this->getScheduledStartTime()?->getTimestamp();\n $teamId = $this->getTeam()->getId();\n\n return $this->getTelephonyProviderId() . ':' . $label . ':' . $startTimestamp . ':' . $teamId;\n }\n\n /**\n * Get all consent records associated with this activity\n *\n * @return \\Illuminate\\Database\\Eloquent\\Relations\\HasMany\n */\n public function participantConsents(): HasMany\n {\n return $this->hasMany(Participant\\Consent::class);\n }\n\n public function isDiallerCall(): bool\n {\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return false;\n }\n\n if (! in_array($this->getType(), [self::TYPE_SOFTPHONE, self::TYPE_SOFTPHONE_INBOUND])) {\n return false;\n }\n\n return $this->getProvider() !== self::PROVIDER_TWILIO;\n }\n\n public function getActivityDateWithFallback(): Carbon\n {\n if ($this->getActualStartTime() !== null) {\n return $this->getActualStartTime();\n }\n\n if ($this->getScheduledStartTime() !== null) {\n return $this->getScheduledStartTime();\n }\n\n return $this->getCreatedAt();\n }\n\n public function getCrmType(): ?string\n {\n // Treat uploader activities as conferences\n if ($this->getProvider() === Activity::PROVIDER_UPLOADER) {\n return Activity::TYPE_CONFERENCE;\n }\n\n return $this->getType();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.85486114,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.87291664,"top":0.31,"width":0.018055556,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.9138889,"top":0.31,"width":0.059027776,"height":0.026666667},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"8","depth":4,"bounds":{"left":0.8645833,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.8854167,"top":0.34444445,"width":0.015277778,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"3","depth":4,"bounds":{"left":0.9048611,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.92569447,"top":0.34444445,"width":0.016666668,"height":0.02111111},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.9458333,"top":0.3422222,"width":0.015277778,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.9611111,"top":0.3422222,"width":0.014583333,"height":0.025555555},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","depth":4,"on_screen":true,"value":"SELECT\n# DISTINCT\nopp.id as opp_id, opp.uuid, opp.name,\n# COUNT(dr.id) AS deal_risk_count,\n\n# dr.id,\n# cfd.value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\n# LEFT JOIN group_deal_risk_types gdrt ON gdrt.group_id = usr.group_id\n# LEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id AND dr.group_deal_risk_type_id = gdrt.id\n\nLEFT JOIN crm_field_data cfd ON (cfd.object_id = opp.id and cfd.crm_field_id = 66814)\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 1\nAND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\nGROUP BY opp.id, cfd.value\nORDER BY\n# cfd.value\n CAST(cfd.value AS UNSIGNED)\n# owner_name\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1\n# AND gdrt.is_enabled = 1)\nDESC\nLIMIT 25\n# OFFSET 0\n;\n\nselect * from crm_fields where crm_configuration_id = 1 and object_type = 'opportunity';\nselect * from crm_layout_entities where crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4584045;\nSELECT * FROM crm_field_data WHERE object_id = 4584045;\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id = '0061K00000lfb9IQAQ'\n\nSELECT\n opp.id as opportunity_id,\n opp.name,\n COUNT(dr.id) as risk_count\nFROM opportunities opp\nLEFT JOIN deal_risks dr ON dr.opportunity_id = opp.id\nWHERE opp.id IN (\n 6069574,8900938,9507638,9524799,9660490,9662824,9705675,9749758,4158460,4391812,6450439,4448422,5118945,5590675,4584045,7228149,9002408,9165534,9446720,9641778,9665149,9703344,9709280,5747948,4158491,6182565,6263970,5798120,5111315,4536978,6062352,6548383,6072095,6548225,4480986,5011422,6548381,8760540,8917554,9509986,9514392,9569009,9569011,9578490,9713604,5784397,7276612,7288405,8994421,9118219,9608148,9818911,4510535,6479693,5958049,6271674,6550448,4158331,4158483,6126571,6171615,6540943,4897466,5190896,5796182,5932762,8572433,8723698,8892697,9711001,9789264,4549188,6100831,6170064,6260799,6263653,6449936,6530871,6538978,7777651,8059269,8319918,8787049,8901150,9263153,9453207,9514738,9696700,9791062,5752018,6421452,7439134,7878923,9354763,9369285,9514396,9582506,9889949,9890216,4094311,4158495,4158496,6098128,5585661,3872564,6442149,5891604,6164746,6199593,6583474,6519684,9018490,9809006,4496897,5041324,5829430,6198319,6253504,6555763,7242914,7931055,8024125,8797814,8058559,8673347,8892695,8994420,9616219,9714970,9722004,9809439,9818918,6523177,8134147,9002915,9711422,9892713,9901719,9954210,9978435,5800810,6243518,6416114,6222251,6411974,6512456,5791953,6545606,9914780,5805540,6238986,6463838,6547680,9767049,9809437,9810885,9890855,6673493,9902036,4335521,6379871,6503799,6546077,8018765,9907556,9958433,9905855,9916179,9946741,9957877,5563344,6271838,6450815,7641128,7762567,7780592,8684810,8685786,8685787,8685788\n)\nGROUP BY opp.id;\n\nSELECT COUNT(dr.id)\n FROM deal_risks dr\n JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n WHERE dr.opportunity_id = 5563344\n# AND gdrt.group_id = usr.group_id\n\n\n\nEXPLAIN SELECT\n opp.id as opp_id, opp.uuid, opp.name,\n\ncfd.value,\ncfv.sequence,\ncfv.value,\n# MAX(cfd.value) AS max_cfd_value,\nusr.name AS owner_name,\nopp.value, opp.currency_code, opp.close_date, opp.remotely_created_at, opp.is_closed, opp.is_won,\nusr.uuid as owner_uuid,\nusr.photo_path as owner_photo,\nusr.id AS owner_id,\njt.name as owner_job,\nopp.stage_id, opp.stage_updated_at,\nacc.name AS acc_name, opp.stage_updated_at, acc.crm_provider_id AS acc_provider_id, opp.crm_provider_id AS opp_provider_id,\nrt.business_process_id AS pipeline_id\nFROM opportunities opp\n\nLEFT JOIN record_types rt ON opp.record_type_id = rt.id\nLEFT JOIN users usr ON opp.user_id = usr.id\nLEFT JOIN accounts acc ON opp.account_id = acc.id\nLEFT JOIN job_titles jt ON usr.job_title_id = jt.id\n\nLEFT JOIN crm_field_data cfd ON cfd.id = (SELECT sub_cfd.id\n FROM crm_field_data sub_cfd\n WHERE sub_cfd.object_id = opp.id\n AND sub_cfd.crm_field_id = 66810\n ORDER BY sub_cfd.updated_at DESC\n LIMIT 1)\n\nLEFT JOIN crm_field_values cfv ON cfv.crm_field_id = 66810 AND cfv.value = cfd.value\n\nWHERE opp.user_id IS NOT NULL\nAND opp.deleted_at IS NULL\nAND opp.is_closed = 0\n# AND opp.is_closed = 1\n# AND opp.is_won = 0\nAND opp.close_date >= '2024-01-01 00:00:00'\nAND opp.close_date <= '2024-12-31 23:59:59'\nAND usr.team_id = 1\n\n# and opp.id = 4823179\n\n# GROUP BY opp.id\nORDER BY\n cfv.sequence DESC,\n# opp.name\n# owner_name\n cfd.value\n# CAST(cfd.value AS UNSIGNED)\n# CAST(MAX(cfd.value) AS UNSIGNED)\n# (SELECT COUNT(dr.id)\n# FROM deal_risks dr\n# JOIN group_deal_risk_types gdrt ON dr.group_deal_risk_type_id = gdrt.id\n# WHERE dr.opportunity_id = opp.id\n# AND dr.is_active = 1 AND gdrt.is_enabled = 1)\nDESC\n# LIMIT 75, 25\n;\n\n\n\nSELECT * FROM crm_field_values WHERE crm_field_id = 66810;\n\nSELECT f.id, f.crm_provider_id AS field_name, f.label, fd.object_id AS dealId, fd.value, fd.updated_at, fd.id, fd.created_at\nFROM crm_fields f\nINNER JOIN crm_field_data fd ON fd.crm_field_id = f.id\n WHERE (f.crm_configuration_id = 1)\n AND (f.object_type = 'opportunity')\n# AND (fd.object_id IN (4158331,4158483,4158495,4158496,6069574,6263970,6171615,6540943,6545606,5829430,6198319,6263653,6548381,7242914,8797814,7228149,7439134,7878923,8134147,9002915,9118219,9165534,9354763,9369285,9446720))\n AND (fd.object_id IN (4158460))\n AND (f.crm_provider_id IN ('ForecastCategoryName'))\n ORDER BY fd.object_id ASC, fd.updated_at DESC;\n\nselect * from crm_layouts where crm_configuration_id = 1;\nselect cf.* from crm_fields cf\njoin crm_layout_entities cle on cf.id = cle.crm_field_id\nwhere crm_layout_id = 1493;\n\nSELECT * FROM opportunities WHERE id = 4158460;\nSELECT * FROM crm_field_data WHERE object_id = 4158460;\n\nselect * from users where team_id = 1;\nSELECT * FROM users WHERE id = 7160;\nselect * from role_user where user_id = 3248;\n\nselect * from crm_field_values where crm_field_id = 66824;\n\nSELECT * FROM users WHERE id = 23470;\nselect * from crm_configurations;\n\n# ******************************************\nselect * from teams where id = 1038; # 23521, 966\nselect * from users where team_id = 1038;\nselect * from crm_configurations where id = 966;\nSELECT * FROM activities WHERE uuid_to_bin('e8dc7c34-31f6-4430-bd81-2d9d8f00dd07') = uuid; # 54965762\nSELECT * FROM activities WHERE uuid_to_bin('4b5727c0-69d1-428f-b8d9-b649055166e2') = uuid; # 54965764\nSELECT * FROM participants WHERE activity_id = 54965764;\n\nSELECT id, uuid, title, recording_state FROM activities WHERE uuid_to_bin('355f105d-5606-4379-b0c5-d91daf59f4ce') = uuid; # 54964075\nSELECT * FROM participants WHERE activity_id = 54964075;\nselect f.id, slug, title, tf.team_id from team_features tf JOIN features f on tf.feature_id = f.id\n where tf.team_id = 1038;\n\n\n# ****************************************** PD *************************\nselect * from teams where id = 1029;\nSELECT * FROM crm_configurations WHERE id = 957;\nSELECT * FROM activities WHERE uuid_to_bin('581a33cb-4343-44bd-ac0c-4a5cee71c5ec') = uuid; # 54963423\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('8b6bb2f7-e7a7-4aec-8806-fbfea7093ccd') = uuid; # 54963421\n\n# ****************************************** Close *************************\nselect * from teams where id = 1031;\nSELECT * FROM crm_configurations WHERE id = 959;\nSELECT * FROM activities WHERE uuid_to_bin('59c517e0-96c9-4dad-bfeb-b7bef72f8725') = uuid; # 54963517\n\n\nSELECT * FROM activities WHERE uuid_to_bin('07238011-25fa-418e-838b-fb21e82b9ea2') = uuid; # 54963433\n\nSELECT * FROM activities WHERE uuid_to_bin('d68311e3-ac34-49bd-bf04-88323a7e5352') = uuid; # 54966009\n\n# ****************************************** SF *************************\nSELECT * FROM activities WHERE uuid_to_bin('2bd4cfa3-4eb5-4c77-84a7-9ed46a21c988') = uuid;\n\nselect * from roles;\nselect * from permissions;\nselect * from permission_role where permission_id = 136;\n\nselect * from migrations order by id desc;\n\nselect * from teams where id IN (1, 1037);\nselect * from crm_layouts where crm_configuration_id = 1;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 1493;\nSELECT * FROM crm_fields WHERE id IN (1652,1661,66799,66814,66821,66836,66843,66846,66864,84752,182306,323580,380378);\n\nselect * from features;\nselect * from team_features where feature_id = 33;\nselect * from opportunities;\n\nselect * from teams;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1052 and sa.provider = 'hubspot';\n\nSELECT * FROM accounts where id = 11512582;\nselect * from activities where account_id = 11512582;","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.025,"top":0.06666667,"width":0.050694443,"height":0.034444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8376151907542764157
|
8179532969745786684
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
#12066 on JY-20725-handle Project: faVsco.js, menu
#12066 on JY-20725-handle-HS-search-rate-limit, menu
Start Listening for PHP Debug Connections
HandleHubspotRateLimitTest
Run 'HandleHubspotRateLimitTest'
Debug 'HandleHubspotRateLimitTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
169
4
102
4
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Models;
use Carbon\Carbon;
use Database\Factories\ActivityFactory;
use DateTimeInterface;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use InvalidArgumentException;
use Jiminny\Component\ElasticSearch;
use Jiminny\Component\MeetingBot;
use Jiminny\Component\Model\BitwiseFlagTrait;
use Jiminny\Component\PlaybackPage\Comments\Services\ActivityCommentService;
use Jiminny\Component\Sidekick\SidekickService;
use Jiminny\Component\Uuid\UuidAwareInterface;
use Jiminny\Component\Workflow;
use Jiminny\Contracts;
use Jiminny\Contracts\Crm\ProspectInterface;
use Jiminny\DTO\ImportCall\Call;
use Jiminny\Events\Activities\ActivityTypeUpdated;
use Jiminny\Events\Activities\ActivityUpdated;
use Jiminny\Events\Activities\ProspectUpdated;
use Jiminny\Events\Activities\StageUpdated;
use Jiminny\Events\Activities\StatusUpdated;
use Jiminny\Events\Activities\TitleUpdated;
use Jiminny\Exceptions\InvalidArgumentException as InvalidArgumentJiminnyException;
use Jiminny\Exceptions\LogicException;
use Jiminny\Exceptions\RuntimeException;
use Jiminny\Models;
use Jiminny\Models\Activity\ActivitySummaryLog;
use Jiminny\Models\Activity\ActivityUploadSetting;
use Jiminny\Models\Activity\AvailabilityNotification;
use Jiminny\Models\Activity\CoachRequest;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\Activity\Log;
use Jiminny\Models\Activity\Message;
use Jiminny\Models\Activity\Moment;
use Jiminny\Models\Activity\Note;
use Jiminny\Models\Activity\ParticipantSpeech;
use Jiminny\Models\Activity\Play;
use Jiminny\Models\Activity\Question;
use Jiminny\Models\Activity\Share;
use Jiminny\Models\Activity\Snapshot;
use Jiminny\Models\Activity\Stats;
use Jiminny\Models\Activity\SubscriptionSet;
use Jiminny\Models\Activity\TopicTrigger;
use Jiminny\Models\Activity\Transcription;
use Jiminny\Models\Calendar\CalendarEvent;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Crm\FieldData;
use Jiminny\Models\ElasticSearch\ActivityElasticSearchTrait;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Participant\Connection;
use Jiminny\Models\Playlist\Activity as PlaylistActivity;
use Jiminny\Services\Activity\ActivityProviderRegistry;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataByStrategy;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverFactory;
use Jiminny\Services\Activity\Import\DataResolvers\UpdateCrmDataResolverInterface;
use Jiminny\Traits\Enums;
use Jiminny\Traits\RequiresUUID;
use Jiminny\Utils\CurrencyFormatter;
use NumberFormatter;
use function in_array;
/**
* Jiminny\Models\Activity
*
* @property null|int $auto_score filled from ES hydrator, not in DB!
* @property-read Account|null $account
* @property-read CalendarEvent|null $calendarEvent
* @property-read Contact|null $contact
* @property-read Lead|null $lead
* @property-read Opportunity|null $opportunity
* @property-read Stage|null $stage
* @property int $id
* @property mixed|null $uuid
* @property string|null $source
* @property string|null $external_id
* @property string $provider
* @property string|null $location
* @property string|null $telephony_provider_id
* @property int|null $from_participant_id
* @property int|null $to_participant_id
* @property int|null $device_id
* @property string|null $type
* @property int|null $playbook_category_id
* @property int $user_id
* @property int|null $lead_id
* @property int|null $account_id
* @property int|null $contact_id
* @property int|null $opportunity_id
* @property int|null $stage_id
* @property string|null $value
* @property int|null $crm_configuration_id
* @property string|null $crm_provider_id
* @property string|null $language
* @property int|null $transcription_id
* @property int $duration
* @property string $status
* @property int|null $on_air
* @property int|null $calendar_event_id
* @property string $recording_state
* @property bool|null $recording_preference
* @property int $recording_reason_code
* @property int $summary_reminder_sent
* @property \Illuminate\Support\Carbon|null $log_reminder_sent_at
* @property \Illuminate\Support\Carbon|null $organizer_notified_at
* @property bool|null $has_recording_prompt
* @property bool $is_internal
* @property int $is_locked
* @property int $is_recording
* @property bool|null $is_processed
* @property bool $is_private
* @property bool $is_instant_invite
* @property string|null $poster_path
* @property string|null $summary
* @property string|null $title
* @property string|null $description
* @property \Illuminate\Support\Carbon|null $scheduled_start_time
* @property \Illuminate\Support\Carbon|null $scheduled_end_time
* @property \Illuminate\Support\Carbon|null $actual_start_time
* @property \Illuminate\Support\Carbon|null $actual_end_time
* @property int|null $uploaded_by
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $average_score
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $activeParticipants
* @property-read int|null $active_participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRuleTrigger> $activityScorecardRuleTriggers
* @property-read int|null $activity_scorecard_rule_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Scorecard\ActivityScorecardRule> $activityScorecardRules
* @property-read int|null $activity_scorecard_rules_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, AvailabilityNotification> $availabilityNotifications
* @property-read int|null $availability_notifications_count
* @property-read \Jiminny\Models\PlaybookCategory|null $category
* @property-read \Illuminate\Database\Eloquent\Collection<int, CoachRequest> $coachRequests
* @property-read int|null $coach_requests_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $coachingFeedbacks
* @property-read int|null $coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $coachingMessages
* @property-read int|null $coaching_messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $comments
* @property-read int|null $comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Connection> $connections
* @property-read int|null $connections_count
* @property-read Configuration|null $crm
* @property-read \Illuminate\Database\Eloquent\Collection<int, FieldData> $data
* @property-read int|null $data_count
* @property-read \Jiminny\Models\Device|null $device
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $favoritePlaylists
* @property-read int|null $favorite_playlists_count
* @property-read \Jiminny\Models\Participant|null $from
* @property-read string|null $activity_title
* @property-read mixed $comment_count
* @property-read mixed $duration_for_humans
* @property-read string $duration_for_humans_short
* @property-read int $favorite_count
* @property-read mixed $favorites_count
* @property-read mixed $formatted_value
* @property-read string $id_string
* @property-read \Jiminny\Models\Participant|null $organizer
* @property-read mixed $play_count
* @property-read int|null $plays_count
* @property-read ?ProspectInterface $prospect
* @property-read string|null $prospect_name
* @property-read mixed $prospect_type
* @property-read mixed $share_count
* @property-read int|null $shares_count
* @property-read int|null $tracks_with_telephony_count
* @property-read int|null $visible_comments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\CoachingFeedback> $latestCoachingFeedbacks
* @property-read int|null $latest_coaching_feedbacks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Log> $logs
* @property-read int|null $logs_count
* @property-read \Jiminny\Models\Track|null $masterTrack
* @property-read \Illuminate\Database\Eloquent\Collection<int, Message> $messages
* @property-read int|null $messages_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Moment> $moments
* @property-read int|null $moments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Note> $notes
* @property-read int|null $notes_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\Share> $participantShares
* @property-read int|null $participant_shares_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, ParticipantSpeech> $participantSpeeches
* @property-read int|null $participant_speeches_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant\ParticipantStats> $participantStats
* @property-read int|null $participant_stats_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Participant> $participants
* @property-read int|null $participants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, PlaylistActivity> $playlistActivities
* @property-read int|null $playlist_activities_count
* @property-read \Kalnoy\Nestedset\Collection<int, \Jiminny\Models\Playlist> $playlists
* @property-read int|null $playlists_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Play> $plays
* @property-read \Illuminate\Database\Eloquent\Collection<int, Question> $questions
* @property-read int|null $questions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Session> $sessions
* @property-read int|null $sessions_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, Share> $shares
* @property-read \Illuminate\Database\Eloquent\Collection<int, Snapshot> $snapshots
* @property-read int|null $snapshots_count
* @property-read Stats|null $stats
* @property-read \Jiminny\Models\Participant|null $to
* @property-read \Illuminate\Database\Eloquent\Collection<int, TopicTrigger> $topicTriggers
* @property-read int|null $topic_triggers_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracks
* @property-read int|null $tracks_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Jiminny\Models\Track> $tracksWithTelephony
* @property-read Transcription|null $transcription
* @property-read \Jiminny\Models\User $user
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $visibleComments
*
* @method static \Illuminate\Database\Eloquent\Collection<int, static> all($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity chunkByIdDesc($count, callable $callback, $column = null, $alias = null)
* @method static \Database\Factories\ActivityFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Collection<int, static> get($columns = ['*'])
* @method static \Jiminny\Component\Eloquent\Builder|Activity heldBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity idOrUuId($idOrUuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity newModelQuery()
* @method static \Jiminny\Component\Eloquent\Builder|Activity newQuery()
* @method static Builder|Activity onlyTrashed()
* @method static \Jiminny\Component\Eloquent\Builder|Activity query()
* @method static \Jiminny\Component\Eloquent\Builder|Activity scheduledBetween(\Carbon\Carbon $start, \Carbon\Carbon $end)
* @method static \Jiminny\Component\Eloquent\Builder|Activity inOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity notInOpenDeals()
* @method static \Jiminny\Component\Eloquent\Builder|Activity forTeam(int $teamId)
* @method static \Jiminny\Component\Eloquent\Builder|Activity search(callable $searchQuery, $key = null, $sortByResults = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity uuid(string $uuid, bool $first = true)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAccountId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereActualStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereAverageScore($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCalendarEventId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereContactId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCreatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmConfigurationId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereCrmProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeletedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDescription($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDeviceId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereDuration($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereFromParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereHasRecordingPrompt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInstantInvite($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsInternal($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsLocked($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsPrivate($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsProcessed($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereIsRecording($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLanguage($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLeadId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLocation($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereLogReminderSentAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOnAir($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOpportunityId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereOrganizerNotifiedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePlaybookCategoryId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity wherePosterPath($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereProvider($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingPreference($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingReasonCode($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereRecordingState($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledEndTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereScheduledStartTime($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSource($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereExternalId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStageId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereStatus($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummary($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereSummaryReminderSent($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTelephonyProviderId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTitle($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereToParticipantId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereTranscriptionId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereType($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUpdatedAt($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUploadedBy($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUserId($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereUuid($value)
* @method static \Jiminny\Component\Eloquent\Builder|Activity whereValue($value)
* @method static Builder|Activity withTrashed()
* @method static Builder|Activity withoutTrashed()
*
* @mixin \Eloquent
*/
class Activity extends Model implements
ElasticSearch\Contract\Searchable,
Workflow\Workflow\WorkflowAwareInterface,
Models\Contracts\ActivityContract,
Contracts\Model\ActivityInterface,
UuidAwareInterface
{
use HasFactory;
use Enums;
use SoftDeletes;
use RequiresUUID;
use BitwiseFlagTrait;
use ElasticSearch\Model\Searchable;
use ActivityElasticSearchTrait;
use Workflow\Workflow\WorkflowAware {
transitionTo as traitTransitionTo;
}
public const int FLAG_RECORDING_REASON_DEFAULT = 0;
// Recording Prompted but never started
public const int FLAG_RECORDING_REASON_COMPLIANCE_PROMPT = 1;
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESUMED = 2;
public const int FLAG_RECORDING_REASON_NO_AUDIO = 3;
// Recording Disabled by Organization
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT = 4;
// Recording was restricted to one-side recordings only
public const int FLAG_RECORDING_REASON_COMPLIANCE_RESTRICT_ONE_SIDE = 8;
// Recording was not started because it was internal and team setting disabled that.
public const int FLAG_RECORDING_REASON_TEAM_INTERNAL_DISABLED = 16;
// Recording was not started because it was internal and user setting disabled that.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED = 32;
// Recording was not started because user setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_USER_AUTOMATIC_DISABLED = 64;
// Recording was not started because team setting disabled automatic recording.
public const int FLAG_RECORDING_REASON_TEAM_AUTOMATIC_DISABLED = 128;
// Recording was not started because user has overriden default.
public const int FLAG_RECORDING_REASON_PREFERENCE_OVERRIDE = 256;
// Recording was not started because they don't want internal, and this meeting was not scheduled/imported in time.
public const int FLAG_RECORDING_REASON_USER_INTERNAL_DISABLED_UNSCHEDULED = 512;
// Recording was not started because their team setting does excludes the meeting type.
public const int FLAG_RECORDING_REASON_UNSUPPORTED_TYPE = 1024;
// Recording was not started because the external provider disabled it (or recording is missing etc).
public const int FLAG_RECORDING_REASON_EXTERNALLY_DISABLED = 2048;
// Recording was stopped externally ("exit-meeting" Pusher event)
public const int FLAG_RECORDING_REASON_STOPPED_EXTERNALLY = 384;
// Recording couldn't be started due to Zoom hosting conflict error
public const int FLAG_RECORDING_REASON_HOSTING_CONFLICT = 448;
// meeting.failed event with reason code BOT_DENIED_FROM_LOBBY
public const int FLAG_RECORDING_REASON_MEETING_BOT_DENIED_FROM_LOBBY = 4096;
// meeting.failed event with reason code LOBBY_TIMEOUT
public const int FLAG_RECORDING_REASON_MEETING_BOT_LOBBY_TIMEOUT = 8192;
// meeting.failed event with reason code BOT_KICKED
public const int FLAG_RECORDING_REASON_MEETING_BOT_KICKED = 16384;
// meeting.failed event with reason code UNKNOWN
public const int FLAG_RECORDING_REASON_MEETING_BOT_UNKNOWN = 32768;
public const int FLAG_RECORDING_REASON_CONSENT_DENIED = 65536;
// Invalid meeting (e.g. URL is invalid, or the meeting is not found)
public const int FLAG_RECORDING_REASON_MEETING_BOT_INVALID = 131072;
// The host stopped the recording.
public const int FLAG_RECORDING_REASON_USER_STOPPED = 262144;
// Recording was not started because an alternative vendor disabled it (or overrode it).
public const int FLAG_RECORDING_REASON_VENDOR_OVERRIDE = 1048576;
// Login required meeting.failed code
public const int FLAG_RECORDING_REASON_LOGIN_REQUIRED = 524288;
// Password for meeting was not provided - meeting.failed code
public const int FLAG_RECORDING_REASON_MEETING_PASSWORD_NOT_PROVIDED = 2097152;
// meeting.failed - when the meeting is locked
public const int FLAG_RECORDING_REASON_MEETING_IS_LOCKED = 4194304;
// max recording duration reached
public const int FLAG_RECORDING_REASON_MAX_DURATION_REACHED = 8388608;
// recording size is too small
public const int FLAG_RECORDING_REASON_EMPTY_RECORDING = 16777216;
// meeting.failed - when bot is redirected to sign in page multiple times
public const int FLAG_RECORDING_REASON_MAX_RESTART_COUNT_IS_REACHED = 33554432;
// meeting.failed event with reason code CONNECTION_LOST
public const int FLAG_RECORDING_REASON_MEETING_BOT_CONNECTION_LOST = 67108864;
// recording is corrupted.
public const int FLAG_RECORDING_REASON_MEDIA_FILE_UNSUPPORTED_MIME_TYPE = 134217728;
// meeting ended in lobby
public const int FLAG_RECORDING_REASON_MEETING_ENDED_IN_LOBBY = 268435456;
// meeting not started
public const int FLAG_RECORDING_REASON_REASON_MEETING_NOT_STARTED = 536870912;
// unfinished zoom custom disclaimer
public const int FLAG_RECORDING_REASON_FEATURE_RULE_NOT_FOUND_ERROR = 1073741824;
// recording download failed - server error
public const int FLAG_RECORDING_REASON_SERVER_ERROR = 2147483648;
// recording download failed - client code 404
public const int FLAG_RECORDING_REASON_NOT_FOUND = 2147483649;
// recording download failed - client code 401, 403
public const int FLAG_RECORDING_REASON_ACCESS_DENIED = 2147483650;
// recording download failed - client code 429
public const int FLAG_RECORDING_REASON_TOO_MANY_REQUESTS = 2147483651;
// recording download failed - unknown client error
public const int FLAG_RECORDING_REASON_CLIENT_ERROR = 2147483652;
// recording download failed - unknown error
public const int FLAG_RECORDING_REASON_UNKNOWN_ERROR = 2147483653;
// It has been setup ahead of time through calendar
public const string STATUS_SCHEDULED = 'scheduled';
// It is awaiting audio.
public const string STATUS_PENDING = 'pending';
// Participant(s) dialed in, awaiting organizer.
public const string STATUS_RINGING = 'ringing';
// Call is in progress.
public const string STATUS_IN_PROGRESS = 'in-progress';
// It has ended.
public const string STATUS_COMPLETED = 'completed';
// Cancelled prior to starting.
public const string STATUS_CANCELLED = 'canceled';
public const string STATUS_DUPLICATED = 'duplicated'; // duplicated conference
public const string STATUS_STARTING_SOON = 'starting-soon';
public const string STATUS_BOT_CREATE_SENT = 'bot-create-sent';
public const string STATUS_BOT_INSTANCE_WORKER_ASSIGNED = 'worker-assigned';
public const string STATUS_BOT_INSTANCE_STARTED = 'bot-started';
// When bot instance is waiting in lobby
public const string STATUS_BOT_INSTANCE_WAITING_LOBBY = 'bot-waiting';
public const string STATUS_BUSY = 'busy';
public const string STATUS_NO_ANSWER = 'no-answer';
public const string STATUS_FAILED = 'failed'; // Used by SMS too
// SMS related
public const string STATUS_ACCEPTED = 'accepted';
public const string STATUS_QUEUED = 'queued';
public const string STATUS_SENDING = 'sending';
public const string STATUS_SENT = 'sent';
public const string STATUS_DELIVERED = 'delivered';
public const string STATUS_UNDELIVERED = 'undelivered';
public const string STATUS_RECEIVING = 'receiving';
public const string STATUS_RECEIVED = 'received';
public const string STATUS_RESENT = 'resent';
public const array SMS_STATUSES = [
Activity::STATUS_RECEIVED,
Activity::STATUS_SENT,
Activity::STATUS_DELIVERED,
];
public const array SOFT_PHONE_CONFERENCE_STATUSES = [
Activity::STATUS_IN_PROGRESS,
Activity::STATUS_COMPLETED,
];
// @todo refactor prefix from `TYPE_` to `CHANNEL_`
public const string TYPE_SOFTPHONE = 'softphone';
public const string TYPE_SOFTPHONE_INBOUND = 'softphone-inbound';
public const string TYPE_CONFERENCE = 'conference';
public const string TYPE_SMS_INBOUND = 'sms-inbound';
public const string TYPE_SMS_OUTBOUND = 'sms-outbound';
public const string TYPE_EMAIL_INBOUND = 'email-inbound';
public const string TYPE_EMAIL_OUTBOUND = 'email-outbound';
public const array CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
public const array PLAYABLE_CHANNELS = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
];
// Recording States
public const string RECORDING_OFF = 'off'; // Default state
public const string RECORDING_IN_PROGRESS = 'in-progress';
public const string RECORDING_PAUSED = 'paused';
public const string RECORDING_STOPPED = 'stopped'; // To never be resumed.
public const string RECORDING_RECORDED = 'recorded'; // At least some portion of it was recorded.
public const string RECORDING_FAILED = 'failed'; // Recording was attempted but failed for some reason.
// Live Stream States
public const int ON_AIR_DEFAULT = 0;
public const int ON_AIR_READY = 1;
public const int ON_AIR_PREPARING = 2;
public const int ON_AIR_STREAMING = 3;
public const int ON_AIR_FINISHED = 4;
public const int ON_AIR_NOT_STREAMED = 5;
public const int ON_AIR_ERROR = -1;
public const string SOURCE_GONG = 'gong';
public const string SOURCE_CHORUS = 'chorus';
public const string SOURCE_OUTLOOK = 'outlook';
public const string SOURCE_GOOGLE = 'google';
// Activity Providers
public const string PROVIDER_TWILIO = 'twilio'; // XXX: This is run via the Jiminny Provider.
public const string PROVIDER_OUTREACH = 'outreach';
public const string PROVIDER_ZOOM_BOT = 'zoom-bot';
public const string PROVIDER_SALESLOFT = 'salesloft';
public const string PROVIDER_GOOGLE = 'google';
public const string PROVIDER_AIRCALL = 'aircall';
public const string PROVIDER_JUSTCALL = 'justcall';
public const string PROVIDER_GOOGLE_MEET = 'google-meet';
public const string PROVIDER_GONG = 'gong';
public const string PROVIDER_HUBSPOT = 'hubspot';
public const string PROVIDER_CLOSE = 'close';
public const string PROVIDER_TEAMS = 'ms-teams';
public const string PROVIDER_SALESFORCE = 'salesforce';
public const string PROVIDER_GROOVE = 'groove';
public const string PROVIDER_XANT = 'xant';
public const string PROVIDER_OFFICE = 'office';
public const string PROVIDER_NATTERBOX = 'natterbox';
public const string PROVIDER_RINGCENTRAL = 'ringcentral';
public const string PROVIDER_RINGCENTRAL_VIDEO = 'ringcentral-video';
public const string PROVIDER_GOTOMEETING = 'go-to-meeting';
public const string PROVIDER_DEMODESK = 'demo-desk';
public const string PROVIDER_DIALPAD = 'dialpad';
public const string PROVIDER_ZOOM_PHONE = 'zoom-phone';
public const string PROVIDER_CLOUDCALL = 'cloudcall';
public const string PROVIDER_CLOUDCALL_US = 'cloudcall-us';
public const string PROVIDER_EIGHT_BY_EIGHT = 'eight-by-eight'; // "8x8" UK
public const string PROVIDER_EIGHT_BY_EIGHT_CA = 'eight-by-eight-ca'; // "8x8" Canada
public const string PROVIDER_EIGHT_BY_EIGHT_AP = 'eight-by-eight-ap'; // "8x8" Australia
public const string PROVIDER_EIGHT_BY_EIGHT_US_EAST = 'eight-by-eight-use'; // "8x8" US East
public const string PROVIDER_EIGHT_BY_EIGHT_US_WEST = 'eight-by-eight-usw'; // "8x8" US West
public const string PROVIDER_CONNECT_AND_SELL = 'connect-and-sell';
public const string PROVIDER_CLOUD_TALK = 'cloud-talk';
public const string PROVIDER_AMAZON_CONNECT = 'amazon-connect';
public const string PROVIDER_VONAGE = 'vonage';
public const string PROVIDER_MIGRATOR = 'migrator';
public const string PROVIDER_UPLOADER = 'uploader';
public const string PROVIDER_TALKDESK = 'talkdesk';
public const string PROVIDER_TWILIO_FLEX = 'twilio-flex';
public const string PROVIDER_TWILIO_FLEX_DIRECT = 'twilio-flex-direct';
public const string PROVIDER_TWILIO_VIDEO = 'twilio-video';
public const string PROVIDER_AVAYA = 'avaya';
public const string PROVIDER_TELUS = 'telus';
public const string PROVIDER_FIVE_NINE = 'five-nine';
public const string PROVIDER_APOLLO = 'apollo';
public const string PROVIDER_ORUM = 'orum';
public const string PROVIDER_BLOOBIRDS = 'bloobirds';
/**
* @const API_PROVIDERS
* A list of integrations that import calls via API instead of webhooks
*/
public const array API_PROVIDERS = [
self::PROVIDER_OUTREACH,
self::PROVIDER_SALESLOFT,
self::PROVIDER_HUBSPOT,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_NATTERBOX,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
];
public const array FINITE_STATES = [
self::TYPE_SOFTPHONE => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_SOFTPHONE_INBOUND => [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_NO_ANSWER,
self::STATUS_BUSY,
],
self::TYPE_CONFERENCE => self::FINITE_STATES_CONFERENCE,
];
public const array FINITE_STATES_CONFERENCE = [
self::STATUS_COMPLETED,
self::STATUS_FAILED,
self::STATUS_CANCELLED,
];
public const array MEETING_BOT_JOIN_ATTEMPTED = [
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_BOT_INSTANCE_STARTED,
];
public static array $enumStatuses = [
self::STATUS_SCHEDULED,
self::STATUS_PENDING,
self::STATUS_RINGING,
self::STATUS_IN_PROGRESS,
self::STATUS_COMPLETED,
self::STATUS_CANCELLED,
self::STATUS_BUSY,
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_ACCEPTED,
self::STATUS_QUEUED,
self::STATUS_SENDING,
self::STATUS_SENT,
self::STATUS_RESENT,
self::STATUS_DELIVERED,
self::STATUS_UNDELIVERED,
self::STATUS_RECEIVING,
self::STATUS_RECEIVED,
self::STATUS_BOT_INSTANCE_WAITING_LOBBY,
self::STATUS_STARTING_SOON,
self::STATUS_BOT_INSTANCE_WORKER_ASSIGNED,
self::STATUS_BOT_INSTANCE_STARTED,
self::STATUS_DUPLICATED,
];
public static array $enumProviders = [
self::PROVIDER_TWILIO,
self::PROVIDER_OUTREACH,
self::PROVIDER_ZOOM_BOT,
self::PROVIDER_SALESLOFT,
self::PROVIDER_AIRCALL,
self::PROVIDER_JUSTCALL,
self::PROVIDER_GOOGLE_MEET,
self::PROVIDER_GONG,
self::PROVIDER_HUBSPOT,
self::PROVIDER_CLOSE,
self::PROVIDER_TEAMS,
self::PROVIDER_SALESFORCE,
self::PROVIDER_GROOVE,
self::PROVIDER_XANT,
self::PROVIDER_GOOGLE,
self::PROVIDER_OFFICE,
self::PROVIDER_NATTERBOX,
self::PROVIDER_RINGCENTRAL,
self::PROVIDER_RINGCENTRAL_VIDEO,
self::PROVIDER_GOTOMEETING,
self::PROVIDER_DEMODESK,
self::PROVIDER_DIALPAD,
self::PROVIDER_ZOOM_PHONE,
self::PROVIDER_CLOUDCALL,
self::PROVIDER_CLOUDCALL_US,
self::PROVIDER_EIGHT_BY_EIGHT,
self::PROVIDER_EIGHT_BY_EIGHT_CA,
self::PROVIDER_EIGHT_BY_EIGHT_AP,
self::PROVIDER_EIGHT_BY_EIGHT_US_EAST,
self::PROVIDER_EIGHT_BY_EIGHT_US_WEST,
self::PROVIDER_CONNECT_AND_SELL,
self::PROVIDER_CLOUD_TALK,
self::PROVIDER_AMAZON_CONNECT,
self::PROVIDER_VONAGE,
self::PROVIDER_TALKDESK,
self::PROVIDER_TWILIO_FLEX,
self::PROVIDER_TWILIO_FLEX_DIRECT,
self::PROVIDER_TWILIO_VIDEO,
self::PROVIDER_AVAYA,
self::PROVIDER_TELUS,
self::PROVIDER_FIVE_NINE,
self::PROVIDER_APOLLO,
self::PROVIDER_ORUM,
self::PROVIDER_BLOOBIRDS,
];
public static $enumRecordingStates = [
self::RECORDING_OFF, // Default state
self::RECORDING_IN_PROGRESS,
self::RECORDING_PAUSED,
self::RECORDING_STOPPED,
self::RECORDING_RECORDED,
self::RECORDING_FAILED,
];
// @Important:
// This collection is not used anywhere, and is fully duplicated by the Channels const.
// Validate if it is referred somehow via the enum trait, and if not, remove it entirely.
// An even better strategy will be to move all those constants to a dedicated class
protected array $enumTypes = [
self::TYPE_SOFTPHONE,
self::TYPE_SOFTPHONE_INBOUND,
self::TYPE_CONFERENCE,
self::TYPE_SMS_INBOUND,
self::TYPE_SMS_OUTBOUND,
self::TYPE_EMAIL_INBOUND,
self::TYPE_EMAIL_OUTBOUND,
];
protected static $enumFailedStatuses = [
self::STATUS_NO_ANSWER,
self::STATUS_FAILED,
self::STATUS_BUSY,
self::STATUS_CANCELLED,
];
protected $table = 'activities';
protected $fillable = [
// Type of activity.
'type', // @todo refactor to `channel`
// The activity type.
'playbook_category_id',
// User who hosts the activity.
'user_id',
// Related Lead record (if applicable)
'lead_id',
// Related Account record (if applicable)
'account_id',
// Related Contact record (if applicable)
'contact_id',
// Related Opportunity record (if applicable)
'opportunity_id',
// Stage of activity.
'stage_id',
// Value of opportunity.
'value',
// If the activity relates to a CRM task.
'crm_provider_id',
// If the activity was created through an external device.
'device_id',
// the activity's language code
'language',
// transcription id
'transcription_id',
// Duration of the call, with microseconds precision.
'duration',
// One of enumStatuses above.
'status',
// Have we reminded them to log the call?
'log_reminder_sent_at',
// If activity is private or inter-org, flagged here.
'is_internal',
// Managers and above can mark a call as private, to exclude it from other team members
'is_private',
'is_processed',
// Boolean for this activity being instant invite handled.
'is_instant_invite',
// If activity is in recording state, flagged here.
'recording_state',
// If activity recording is overidden from default.
'recording_preference',
// if recording did (not) happen, why that is
'recording_reason_code',
// Average score, updated during
'average_score',
// Summary that the organizer has taken after the call.
'summary',
// Subject of the activity, usually taken from calendar event.
'title',
// Description of the activity, usually taken from calendar event.
'description',
// Start time, usually taken from calendar event.
'scheduled_start_time',
// End time, usually taken from calendar event.
'scheduled_end_time',
// When the call actually started.
'actual_start_time',
// When the call actually ended.
'actual_end_time',
// SMS: Message reference
'telephony_provider_id',
// SMS: Participant who sent message
'from_participant_id',
// SMS: Participant who should receive the message
'to_participant_id',
// When an external guest joins an organizers meeting room and the organizer is not present,
// send them an SMS notification that someone has joined.
'organizer_notified_at',
// where was the activity imported from
'source',
// The id in the source system (e.g. the bot id in Recall.ai)
'external_id',
// The provider, by default it is twilio.
'provider',
// Meeting location url
'location',
// The snapshot for displaying a poster image.
'poster_path',
'crm_configuration_id',
// If there is an automated message that the conversation is being recorded
'has_recording_prompt',
// If the activity is being live-streamed
'on_air',
'calendar_event_id',
];
protected $appends = [
'id_string',
'organizer',
];
protected $hidden = [
'uuid',
];
protected $visible = [
'id_string',
'type',
'duration',
'average_score',
'status',
'log_reminder_sent_at',
'title',
'description',
'is_internal',
'scheduled_start_time',
'scheduled_end_time',
'actual_start_time',
'actual_end_time',
'user',
'category',
'account',
'contact',
'opportunity',
'lead',
'stage',
'stats',
'participants',
'playlists',
'tracks',
'comments',
'plays',
'coachingFeedbacks',
'shares',
'favorites',
'language',
'transcription',
'is_private',
'is_instant_invite',
'on_air',
'calendar_event_id',
];
protected function casts(): array
{
return [
'scheduled_start_time' => 'datetime',
'scheduled_end_time' => 'datetime',
'actual_start_time' => 'datetime',
'actual_end_time' => 'datetime',
'organizer_notified_at' => 'datetime',
'log_reminder_sent_at' => 'datetime',
'is_internal' => 'boolean',
'duration' => 'integer',
'average_score' => 'decimal:2',
'is_private' => 'boolean',
'is_processed' => 'boolean',
'is_instant_invite' => 'boolean',
'value' => 'decimal:2',
'recording_preference' => 'boolean',
'recording_reason_code' => 'integer',
'has_recording_prompt' => 'boolean',
'on_air' => 'integer',
];
}
protected static function boot()
{
parent::boot();
static::updated(static function (Activity $activity) {
// If activity is about to start (pending, ringing, in-progress) or event is scheduled in less than 1 week
if (in_array($activity->status, [Activity::STATUS_PENDING, Activity::STATUS_RINGING, Activity::STATUS_IN_PROGRESS], true) ||
($activity->scheduled_start_time && (int) $activity->scheduled_start_time->diffInWeeks(new Carbon(), true) < 1)) {
if ($activity->isDirty('status')) {
event(new StatusUpdated($activity));
}
if ($activity->isDirty('stage_id')) {
event(new StageUpdated($activity));
}
if ($activity->isDirty(['lead_id', 'account_id', 'contact_id'])) {
event(new ProspectUpdated($activity));
}
if ($activity->isDirty('opportunity_id')) {
event(new ActivityUpdated($activity, 'activity.opportunity-updated', Auth::user()));
}
if ($activity->isDirty('title')) {
event(new TitleUpdated($activity));
}
}
if ($activity->isDirty('playbook_category_id')) {
event(new ActivityTypeUpdated($activity));
}
});
static::deleted(static function (Activity $activity) {
// Hard delete associated playlistActivities
$activity->playlistActivities()->delete();
});
}
public function getOrganizerAttribute(): ?Participant
{
$participant = $this->participants()->where('user_id', $this->user_id)->first();
if (! $participant instanceof Participant && $participant !== null) {
throw new RuntimeException(sprintf('$participant must be an instance of "%s" or null', Participant::class));
}
return $participant;
}
public function getFormattedValueAttribute()
{
$currencyCode = 'USD';
if ($this->opportunity) {
$currencyCode = $this->opportunity->getCurrencyCode();
}
$formatter = new CurrencyFormatter();
$formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currencyCode);
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
return $formatter->format($this->value, $currencyCode);
}
public function getProspectNameAttribute(): ?string
{
$prospectName = null;
if ($this->lead_id) {
$prospectName = $this->lead->name;
} elseif ($this->contact_id) {
$prospectName = $this->contact->name;
} elseif ($this->account_id) {
$prospectName = $this->account->name;
}
return $prospectName;
}
public function getProspectName(): ?string
{
/** @var string|null */
return $this->getAttribute('prospect_name');
}
/**
* Get activity title depending on prospect or title
*/
public function getActivityTitleAttribute(): ?string
{
$activityTitle = null;
if ($this->prospect && $this->prospect->getName()) {
if ($this->account_id) {
$activityTitle = $this->account->name;
} elseif ($this->lead_id) {
$activityTitle = $this->lead->company;
} elseif ($this->contact_id) {
$activityTitle = $this->contact->account ? $this->contact->account->name : $this->contact->name;
}
} elseif ($this->title) {
$activityTitle = $this->title;
}
return $activityTitle;
}
public function wasRecentlyCreated(): bool
{
return $this->wasRecentlyCreated;
}
public function getProspectTypeAttribute()
{
$prospectType = null;
if ($this->lead_id) {
$prospectType = 'Lead';
} elseif ($this->contact_id) {
$prospectType = 'Contact';
} elseif ($this->account_id) {
$prospectType = 'Account';
}
return $prospectType;
}
/**
* Return the best match for prospect. Results are in the following order of priority:
* 1. Lead
* 2. Contact
* 3. Account
* 4. NULL
*/
public function getProspectAttribute(): ?ProspectInterface
{
if ($this->hasLead()) {
return $this->getLead();
}
if ($this->hasContact()) {
return $this->getContact();
}
if ($this->hasAccount()) {
return $this->getAccount();
}
return null;
}
public function getTitleAttribute($value): ?string
{
return \getActivityTitleAttribute(
$this->user->name,
$this->getType(),
$value,
$this->prospect->name ?? null,
$this->from->national_phone_number ?? null
);
}
public function getTitle(): ?string
{
return $this->getAttribute('title');
}
public function getSummary(): ?string
{
return $this->getAttribute('summary');
}
public function isInternal(): bool
{
return $this->getAttribute('is_internal');
}
public function getIsPrivate(): bool
{
return $this->getAttribute('is_private');
}
public function getDescription(): ?string
{
return $this->getAttribute('description');
}
public function hasTitle(): bool
{
return $this->getOriginal('title') !== null;
}
public function getPlayCountAttribute()
{
return $this->getPlaysCountAttribute();
}
public function getPlaysCountAttribute()
{
if (! isset($this->attributes['plays_count'])) {
$this->loadCount('plays');
}
return $this->attributes['plays_count'];
}
public function getCommentCountAttribute()
{
return $this->getCommentsCountAttribute();
}
public function getCommentsCountAttribute()
{
if (! isset($this->attributes['comments_count'])) {
$this->loadCount('comments');
}
return $this->attributes['comments_count'];
}
public function getVisibleCommentsCountAttribute()
{
if (! isset($this->attributes['visible_comments_count'])) {
$activityCommentsService = app(ActivityCommentService::class);
$user = Auth::user() instanceof User ? Auth::user() : null;
$this->attributes['visible_comments_count'] = $activityCommentsService
->getVisibleCommentsCount($this, $user);
}
return $this->attributes['visible_comments_count'];
}
public function getShareCountAttribute()
{
return $this->getSharesCountAttribute();
}
public function getSharesCountAttribute()
{
if (! isset($this->attributes['shares_count'])) {
$this->loadCount('shares');
}
return $this->attributes['shares_count'];
}
/**
* Get the count of favorites playlists this activity appears in
*/
public function getFavoriteCountAttribute(): int
{
return $this->getFavoritesCountAttribute();
}
public function getFavoritesCountAttribute()
{
if (! isset($this->attributes['favorites_count'])) {
$this->loadCount('favorites');
}
return $this->attributes['favorites_count'];
}
public function getActiveParticipantsCountAttribute()
{
if (! isset($this->attributes['active_participants_count'])) {
$this->loadCount('activeParticipants');
}
return $this->attributes['active_participants_count'];
}
public function getTracksWithTelephonyCountAttribute()
{
if (! isset($this->attributes['tracks_with_telephony_count'])) {
$this->loadCount('tracksWithTelephony');
}
return $this->attributes['tracks_with_telephony_count'];
}
/**
* @TEMP
* $this->loadCount('tracksWithTelephony') throws null pointer exception
*/
public function countTracksWithTelephony(): int
{
return $this->tracks()->whereNotNull('telephony_provider_id')->count();
}
public function getDuration(): float
{
return $this->getAttribute('duration');
}
public function getDurationForHumansAttribute()
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true);
}
public function getDurationForHumansShortAttribute(): string
{
return Carbon::now()->subSeconds($this->duration)->diffForHumans(now(), true, true);
}
public function has...
|
45486
|
NULL
|
NULL
|
NULL
|
|
45489
|
1628
|
20
|
2026-05-14T14:39:45.550211+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769585550_m2.jpg...
|
PhpStorm
|
faVsco.js – Activity.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIAl Notes: OffLeavev Q SearchDate ModifiedYesterdav at 13.36Yesterday at 13:36Yesterday at 13.30Yesterdav at 13:34Yesterday at 13:34resterday at 15.3sYesterdav at 13:3kYesterday at 13:32Yesterday at 13.31Yesterdav at 13:31Yesterday at 13:30resterday at 15.30Yesterdav at 13:29Yesterday at 13:29Yesterday at 13:28Yesterday at 13:28Yesterdav at 13:27resterday at 13-40Yesterdav at 13:26Yesterday at 13:25Yesterday at 13:25Yesterday at 13:24Voctorday at 12:01Yesterday at 13.22Yesterdav at 13:21Yesterday at 13:20Yesterday at 13:19Yesterday at 13.18Yecterdav at 12:19Yesterday at 13-1/Yesterdav at 13:16Yesterday at 13:16Yesterday at 13:15Yecterdav at 12:1/Yesterdav at 13:14Yesterday at 13.13Yecterdav at 13:10Yesterday at 13:12Yesterday at 13:11Yoctorday at 12:11Yesterdav at 13:10Yesterday at 13.10Yecterdav at 12:091Yesterdav at 13:09Yesterdav at 13:0823K:MPEG-4 movie9 KB13 KB16 Kb17 KE29 KB6 KB12 K:MDEG-A movieMPEG-4 movieMPEG-4 movieMPE0"4 movie9 KBMDSG-A movie7 KEMP2G-4 movie37 KB10 KBI KD8 KEMPEG-4 movieMPEG"4 movie9 KBMoEeh movio8 KB72 KBMPEG-4 movie14 KBI13 KB9 KBMPEG-1 movieMPEG-4 movie18 KEMPEG-4 movie12 KB10 KBMPEG-4 movie16 K:MPEG-4 movieAkpMDEG.A movic12 KBMPEG-4 movie23 KB8 KBMPEG-4 movieMPEG-4 movie6 KBMPEG-4 movie16 K:11 KPMDECA movid20 KBMPEG-4 movie21 KPMDEG-A movie10 KB MPEG-4 movie7 KBMPEG-4 movie5 KB111 KB26 KB111 KBMPEG-4 movieMDEC.A movialMPEG-4 movie102 KR88 KB59 KBMDEG-A movieMPEG-4 movie08 KBIMPEG-A movie97 KB MPEG-4 movie66 KB44 KB02 KpMPEG-4 movieMDEG.A movio78 KB50 KBMPEG-4 movie58 KГMPEG-A movid27 KBMPEG-4 movie7 KB12K8MPEG-4 movieFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc tolde0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zipreport(2).xmlAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence hettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentPDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archive5KRMarkdo…..umentWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 Mау 1/.39.44Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
-7500240828889432556
|
NULL
|
click
|
ocr
|
NULL
|
Jiminny... ~ActivityFilesLater@ jiminny-x-integrat Jiminny... ~ActivityFilesLater@ jiminny-x-integrati• plattorm-inner-teamE Channels# ai-chapter# alertsi backend# bugscontusion-cllnia# curiosity lab# engineering# general#jiminny-bgac nlattorm-nckets# product launches# random# releases# sofia-officed sunport# thank-yous# the people of iimi... Direct messages• 8la 62% Galya Dimitrovavasil VasilevM Stefka StovanovaSg: Todor StamatovMario GeorgievNiudlay lanay. James Graham "* Stoyan Tanevo Stelivan Georgiev( Petko Kashinski*. Lukas Kovali...::: AnnsToastS lira Gloud6d Huddle with Aneliva Angelova* Aneliya Angelova &• Messagest Add canvasur FilesAneliya Angelova 2:30 PMЛукаш, само при Сейлсфорс и Хубспот се синкваха активити типовете, когато се направи плейбук,нали?пои останалите скМі тоябва оъчно ла се въвелат.Lukas Kovalik 2:47 PMтряова да се за всички, някъде не се ли попьлвапри зохо май беше hardcoded но май и там си връщаха две категорииAneliya Angelova 4:00 PMЛукаш имаш ли време да се чуем за тестването на https://jiminny.atlassian.net/browse/JY-20725X Preuiew in sact[HubSpotl Optimise CRM rematct(7 OpenRosdy for OA- MediumAA Aneliya AngelovaAs of today at 4:00 PM RetreshOpen in Jira* SummariseLukas Kovalik 4:02 PMzean-iurwiniareelYou joined the huddle (LIVE 4:06 PMAneliva Angelova is here toolAneliva Angelova 4:44 PN11512582Lukas Kovalik M 5.16 PNcurl --location "httns:ani.hubani.com/crm/v3/obiects/contacts/search--header 'Content-vne' annlication/ison'--header "Authorization: BearerC|Kvma?iMx7OINOM8kOFwrAowAcAkUAhIR24?A05D?xiVrIYMILuP6SA01Kwcmhr=n.v2 hytorDniMvDalYck-CMalovolNOM9kOFwrAUAcrkcaws-ThwRARIRAOF-ATFSAOFRAO-ROIEBAQUBEggBAQEBAYICFIr7Au8O2Nwal9YW2CbCCxYvwngmSgNldTFSAFoAYABoAHAAeAA'\--data "{ "limit", 13'Message Aneliva Angelova+ AaIAl Notes: OffLeavev Q SearchDate ModifiedYesterdav at 13.36Yesterday at 13:36Yesterday at 13.30Yesterdav at 13:34Yesterday at 13:34resterday at 15.3sYesterdav at 13:3kYesterday at 13:32Yesterday at 13.31Yesterdav at 13:31Yesterday at 13:30resterday at 15.30Yesterdav at 13:29Yesterday at 13:29Yesterday at 13:28Yesterday at 13:28Yesterdav at 13:27resterday at 13-40Yesterdav at 13:26Yesterday at 13:25Yesterday at 13:25Yesterday at 13:24Voctorday at 12:01Yesterday at 13.22Yesterdav at 13:21Yesterday at 13:20Yesterday at 13:19Yesterday at 13.18Yecterdav at 12:19Yesterday at 13-1/Yesterdav at 13:16Yesterday at 13:16Yesterday at 13:15Yecterdav at 12:1/Yesterdav at 13:14Yesterday at 13.13Yecterdav at 13:10Yesterday at 13:12Yesterday at 13:11Yoctorday at 12:11Yesterdav at 13:10Yesterday at 13.10Yecterdav at 12:091Yesterdav at 13:09Yesterdav at 13:0823K:MPEG-4 movie9 KB13 KB16 Kb17 KE29 KB6 KB12 K:MDEG-A movieMPEG-4 movieMPEG-4 movieMPE0"4 movie9 KBMDSG-A movie7 KEMP2G-4 movie37 KB10 KBI KD8 KEMPEG-4 movieMPEG"4 movie9 KBMoEeh movio8 KB72 KBMPEG-4 movie14 KBI13 KB9 KBMPEG-1 movieMPEG-4 movie18 KEMPEG-4 movie12 KB10 KBMPEG-4 movie16 K:MPEG-4 movieAkpMDEG.A movic12 KBMPEG-4 movie23 KB8 KBMPEG-4 movieMPEG-4 movie6 KBMPEG-4 movie16 K:11 KPMDECA movid20 KBMPEG-4 movie21 KPMDEG-A movie10 KB MPEG-4 movie7 KBMPEG-4 movie5 KB111 KB26 KB111 KBMPEG-4 movieMDEC.A movialMPEG-4 movie102 KR88 KB59 KBMDEG-A movieMPEG-4 movie08 KBIMPEG-A movie97 KB MPEG-4 movie66 KB44 KB02 KpMPEG-4 movieMDEG.A movio78 KB50 KBMPEG-4 movie58 KГMPEG-A movid27 KBMPEG-4 movie7 KB12K8MPEG-4 movieFavourites• jiminny• Recents* ApplicationsiCloud• iCloud Drive992 Svnc tolde0 DXP4800PLUS-B5F49 Networl• CRMI• Orange• Red|• Yellow• Green• Purple•) All lags..IhlDownloadsNameLoom.pkgAlfred copv.alfredoreterences=KeychronAssist-1.0.2 (1).dmeKeychronAssist-1.0.2.dmgmazanoke-images-yWJo.zioPhotos-3-001.zip→mage U.loge1 Orioninstaller.dma_image.jpg- image (2).1pc• ПO-22221726037035-004-001_ORGES.pdf%D0%9F%D0%9E-22221726037035-004-001 archive.zipПO-22221726037035-004-001_archive (1).zipreport(2).xmlAltred copy2.altredoreterencesСE 060209С О000000026571172 CWICT 0Р70501260015900 ndt= 27022026_0000000026574472_ SWIFT_ [IBAN].pdf= 03042026 [CREDIT_CARD] SWIFT [CREDIT_CARD].001reportxmmi=pdt.odiB pdf-1.pdfD pdf-2.pdf-pdf-5.pd1= ndf-1 ndipdf-3.pdfKoválik Family Tree.gedbitwarden export 20251031122528.isonlKoválik Family Tree.zip*macOS Storage_Cleanup.mdal favicon icofirst aid_notes_complete.docxrenortl2).esv1 config.vmlIteration run Search HS.postman_collection.jsonm licence hettertouchtoalMariusHosting Config.isonnokc.901a6502.6667.A62h-062 ccu•AlfredwPmazanoko.imnaoc.YWIfана Ковалик.jpg•искане даниел Ковалик..pg• Фактура Март Даниел Ковалик.jрс• Фактура Април Даниел Ковалик iро• Dhotac 2.001Q SearchKind00,4 MD55.9 MBinstdlle..dckageAlfred...ferences10,1 MB10,1 MBIL MBDisk ImageDisk ImageLiP archive6.6 MBZIp archive2,5 MB PDF Document2,5 MBJreo lmage2.2 MBDisk Image2,2 MB PDF Document2 MBJPEG image1,9 MBJPEG imaqe192 KBPDE Document140 KbZIP archive148 KВ148 KB122 KBZIP archivelZIP archiveXML document111 KBAlfred...ferences94 KBDDE Documont92 KBPDr DocumentPDF Document91 KB91 KBXML document30 KBn0kpDDE Nocumont28 KBPDF Document28 KRPDE Document28 KB27 KBDocument14 KB11 KB6 KB6KBJSONINCV NacumontZIP archive5KRMarkdo…..umentWindo...n image4 KB3 KBword ..cumentCSV Document2 KBVAMI dosumon1 KB029 buteccSV Documenthttlicence183 bytesZero butesJSONAlfrod foronso!Zero bytesFolde1.9 MB1,8 MB17 MB1,7 MBColdorJPEG imageJPEG ImageIPEG imadeJPEG imageColdo1 of 58 selected, 8.44 GB availabld• Inu 14 Mау 1/.39.44Date AddedIs Mdl ZUzo dl 19:4530 Jan 2026 at 12:3617 Mar 2026 at 20:2717 Mar 2026 at 20:26Z3 Aor 2020 al 13:0229 ,Jan 2026 at 15:2019 Dec 2025 at 10:1619 Dec 2025 at 12:238 Aor 2026 at 20:3519 Dec 2025 at 10:2919 Dec 2025 at 12:1819 Dec 2025 at 12:4026 Mar 2026 at 11:2410 May 2026 at 13:5326 Mar 2026 at 11:2426 Mar 2026 at 11:2426 Mar 2026 at 11:2310 May 2026 at 14:3730 Jan 2026 at 12:3712 Goh 2006 9t 11:5 A1Z3 Apr 2026 at 13.0823 Aor 2026 at 13:0810 May 2026 at 13:5410 May 2026 at 14:3710 May 2026 at 13:4910 May 2026 at 13:5010 May 2026 at 13:5110 Mav 2026 at 12:51110 May 2026 at 13:5019 Dec 2025 at 11:3431 Oct 2025 at 12:2525 Nau 2025 4+ 17:506 Mar 2026 at 11.2224 Anr 2026 at 16:5220 Oct 2025 at 11:0218 Mar 2026 at 15:29• Mav 2026 at 11:09129 Oct 2025 at 19:329 May 2026 at 10:0419 Mar 2026 at 11:55|10 May 2026 at 13:5712 Jun 2025 at 19:0430 Jan 2026 at 12:362616 Oct 2025 aт 16:0122 Aar 2026 at 12:0223 Apr 2026 at 13:0223 Apr 2026 at 13:0222 Anr 2026 at 12:0223 Apr 2026 at 13:0229 Jan 2026 at 15:20...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
45490
|
1627
|
25
|
2026-05-14T14:39:48.039636+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-14/1778 /Users/lukas/.screenpipe/data/data/2026-05-14/1778769588039_m1.jpg...
|
iTerm2
|
NULL
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpabl100% С•FV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest8• Thu 14 May 17:39:47* :QProject vTrackAutomatedReportGeneratedEvent.phpAutomatedReportResult.phpSendReportJob.php> C WebhookDeleteAccountJob.phpImportActivitylypes.php0 WriteCrmTrait.phpDecorateActivity.php© Account.php© IntegrationApp/Service.phpActivity.php XSalesforce/Service.phpT LogActivityTrait.php© Activity.php© Address.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.php© AiPrompt.php© ActivityPlaybookTrait.phpCrmHelperRepository.php© AccountController.php=.env.staging18© AutomatedReport.php© AutomatedReportResult.php•DetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.php© Calendar.php© HubspotPaginationService.php© CallImport.php© CoachingFeedback.php© HandleHubspotRateLimit.phpModel implementscLass Acet uty exnsen receras ussueausea wat cns uctavaty© CoachingFeedbackVisibility.php© CoachingSection.php© CoachingSectionCriterion.php3033350335733583359* @return lIlluminate DatabaselEloquent Relations HasMany© CoachingSectionCriterionFeedback.*/8 usages© CoachingSectionFeedback.php© CommentAbstract.php33663364public function participantConsents(): HasMany{..© Commentinterface.php1 usage© Contact.php© Device.php3365 @ >3377public function isDiallerCall(): bool{..© EmailMessage.php3 usages© GenericAiPrompt.php© Group.php© Inbox.php© InboxEmail.php© InboxEmailBatch.php© Invitation.php© JobLog.php© JobTitle.php© Language.php© LanguageDialect.php© Lead.php© MobileSetting.php© Model.php337833903391 € public function getActivityDateWithFallback(): Carbon{...}public function getCrmType(): ?string// Treat uploader activities as conferencesif (Sthis->getProviderO=== Activity::PROVIDER_UPLOADER) {return Activity: :TYPE_CONFERENCE;return $this->getType();}© Moment.php© Nudge.phpA MudnaDun nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DeleteCrmEntityTrait.php:=custom.logIntegrationAppServiceTrait.php= laravel.log© Playbook.phpSF [jiminny@localhost]© PlainTextDecorateActivity.phpA HS_local [jiminny@localho:=.env4 console [QAI PROD] XClient.php4 console [PROD]A console (EU]A4 A169 X4 X 102 2,4 ^DGo jiminny084143 ×4 л215•m_layout_id =2162,1661, 66799,66217- 218-219id = 33;220=221222223224id THEN •(own225226227228229230hubspot':-231232233 V= 11512582;234W Windsurf Teams3395:26UTF-8Ca 4 spaces...
|
NULL
|
-5584264757848738278
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormFileEditViewNavigateCodeLaravelRefactorRun PhpStormFileEditViewNavigateCodeLaravelRefactorRunToolsGitWindowHelpabl100% С•FV faVsco.jsv* #12066 on JY-20725-handle-HS-search-rate-limit k vHandleHubspotRateLimitTest8• Thu 14 May 17:39:47* :QProject vTrackAutomatedReportGeneratedEvent.phpAutomatedReportResult.phpSendReportJob.php> C WebhookDeleteAccountJob.phpImportActivitylypes.php0 WriteCrmTrait.phpDecorateActivity.php© Account.php© IntegrationApp/Service.phpActivity.php XSalesforce/Service.phpT LogActivityTrait.php© Activity.php© Address.php© Pipedrive/Service.phpClose/Service.phpCopper/Service.php© BullhornService.php© AiPrompt.php© ActivityPlaybookTrait.phpCrmHelperRepository.php© AccountController.php=.env.staging18© AutomatedReport.php© AutomatedReportResult.php•DetachActivityObject.phpRematchActivityOnCrmObjectDetach.phpMatchActivityCrmData.php© Calendar.php© HubspotPaginationService.php© CallImport.php© CoachingFeedback.php© HandleHubspotRateLimit.phpModel implementscLass Acet uty exnsen receras ussueausea wat cns uctavaty© CoachingFeedbackVisibility.php© CoachingSection.php© CoachingSectionCriterion.php3033350335733583359* @return lIlluminate DatabaselEloquent Relations HasMany© CoachingSectionCriterionFeedback.*/8 usages© CoachingSectionFeedback.php© CommentAbstract.php33663364public function participantConsents(): HasMany{..© Commentinterface.php1 usage© Contact.php© Device.php3365 @ >3377public function isDiallerCall(): bool{..© EmailMessage.php3 usages© GenericAiPrompt.php© Group.php© Inbox.php© InboxEmail.php© InboxEmailBatch.php© Invitation.php© JobLog.php© JobTitle.php© Language.php© LanguageDialect.php© Lead.php© MobileSetting.php© Model.php337833903391 € public function getActivityDateWithFallback(): Carbon{...}public function getCrmType(): ?string// Treat uploader activities as conferencesif (Sthis->getProviderO=== Activity::PROVIDER_UPLOADER) {return Activity: :TYPE_CONFERENCE;return $this->getType();}© Moment.php© Nudge.phpA MudnaDun nhnWorkspace associated with branch 'JY-20725-handle-HS-search-rate-limit' has been restored // Rollback // Configure... (today 16:17)DeleteCrmEntityTrait.php:=custom.logIntegrationAppServiceTrait.php= laravel.log© Playbook.phpSF [jiminny@localhost]© PlainTextDecorateActivity.phpA HS_local [jiminny@localho:=.env4 console [QAI PROD] XClient.php4 console [PROD]A console (EU]A4 A169 X4 X 102 2,4 ^DGo jiminny084143 ×4 л215•m_layout_id =2162,1661, 66799,66217- 218-219id = 33;220=221222223224id THEN •(own225226227228229230hubspot':-231232233 V= 11512582;234W Windsurf Teams3395:26UTF-8Ca 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|