Skip to content

Commit

Permalink
feat: add participant by meeting link
Browse files Browse the repository at this point in the history
  • Loading branch information
FredPeal committed Dec 23, 2024
1 parent e71edf3 commit 96e8f50
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function up(): void
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
// $table->dropColumn('meeting_link');
$table->dropColumn('meeting_link');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

namespace Kanvas\Connectors\Ghost\Jobs;

use Kanvas\Event\Events\Models\Event;
use Kanvas\Event\Participants\Actions\SyncPeopleWithParticipantAction;
use Kanvas\Guild\Customers\Actions\CreatePeopleAction;
use Kanvas\Guild\Customers\DataTransferObject\People;
use Kanvas\Guild\Customers\Enums\ContactTypeEnum;
use Kanvas\Guild\Customers\Repositories\PeoplesRepository;
use Kanvas\Workflow\Jobs\ProcessWebhookJob;

class CreateParticipantFromMeetingJob extends ProcessWebhookJob
{
public function execute(): array
{
$payload = $this->webhookRequest->payload['payload'];
$zoomId = $payload['object']['id'];
$event = Event::whereLike('meeting_link', "%https://us04web.zoom.us/j/{$zoomId}%")
->first();

if (! $event) {
return [
'message' => 'No data found',
'payload' => $this->webhookRequest->payload,
];
}

$people = PeoplesRepository::getByEmail($payload['object']['participant']['email'], $this->webhookRequest->company);
if (! $people) {
$peopleDto = People::from([
'app' => $this->webhookRequest->app,
'company' => $this->webhookRequest->company,
'user' => $this->webhookRequest->user,
'firstname' => $payload['object']['participant']['user_name'],
'contacts' => [
[
'value' => $payload['object']['participant']['email'],
'contacts_types_id' => ContactTypeEnum::EMAIL->value,
'weight' => 0,
],
],
]);
$action = new CreatePeopleAction($peopleDto);
$people = $action->execute();
}
$sync = new SyncPeopleWithParticipantAction($people, $this->webhookRequest->user);
$participant = $sync->execute();
$eventVersion = $event->eventVersions()->first();
$eventVersion->addParticipant($participant);

return [
'message' => 'Participant created',
'people' => $people->toArray(),
'participant' => $participant->toArray(),
];
}
}

0 comments on commit 96e8f50

Please sign in to comment.