Address Greptile feedback for queue publishers

This commit is contained in:
Chirag Aggarwal
2026-05-08 14:41:58 +05:30
parent 34075322d7
commit 18ec96f124
2 changed files with 11 additions and 7 deletions
@@ -95,12 +95,13 @@ class Create extends Action
->inject('timelimit')
->inject('usage')
->inject('plan')
->inject('platform')
->inject('proofForPassword')
->inject('proofForToken')
->callback($this->action(...));
}
public function action(string $teamId, string $email, string $userId, string $phone, array $roles, string $url, string $name, Response $response, Document $project, User $user, Database $dbForProject, Authorization $authorization, Locale $locale, MailPublisher $publisherForMails, MessagingPublisher $publisherForMessaging, Event $queueForEvents, callable $timelimit, Context $usage, array $plan, Password $proofForPassword, Token $proofForToken)
public function action(string $teamId, string $email, string $userId, string $phone, array $roles, string $url, string $name, Response $response, Document $project, User $user, Database $dbForProject, Authorization $authorization, Locale $locale, MailPublisher $publisherForMails, MessagingPublisher $publisherForMessaging, Event $queueForEvents, callable $timelimit, Context $usage, array $plan, array $platform, Password $proofForPassword, Token $proofForToken)
{
$isAppUser = $user->isApp($authorization->getRoles());
$isPrivilegedUser = $user->isPrivileged($authorization->getRoles());
@@ -417,6 +418,7 @@ class Create extends Action
preview: $preview,
smtp: $smtpConfig,
variables: $emailVariables,
platform: $platform,
));
} elseif (! empty($phone)) {
if (empty(System::getEnv('_APP_SMS_PROVIDER'))) {
@@ -14,6 +14,8 @@ class ScheduleMessages extends ScheduleBase
public const UPDATE_TIMER = 3; // seconds
public const ENQUEUE_TIMER = 4; // seconds
private ?MessagingPublisher $publisherForMessaging = null;
public static function getName(): string
{
return 'schedule-messages';
@@ -31,6 +33,11 @@ class ScheduleMessages extends ScheduleBase
protected function enqueueResources(Database $dbForPlatform, callable $getProjectDB): void
{
$publisherForMessaging = $this->publisherForMessaging ??= new MessagingPublisher(
$this->publisherMessaging,
new Queue(System::getEnv('_APP_MESSAGING_QUEUE_NAME', Event::MESSAGING_QUEUE_NAME))
);
foreach ($this->schedules as $schedule) {
if (!$schedule['active']) {
continue;
@@ -43,14 +50,9 @@ class ScheduleMessages extends ScheduleBase
continue;
}
\go(function () use ($schedule, $scheduledAt, $dbForPlatform) {
\go(function () use ($schedule, $scheduledAt, $dbForPlatform, $publisherForMessaging) {
$this->updateProjectAccess($schedule['project'], $dbForPlatform);
$publisherForMessaging = new MessagingPublisher(
$this->publisherMessaging,
new Queue(System::getEnv('_APP_MESSAGING_QUEUE_NAME', Event::MESSAGING_QUEUE_NAME))
);
$publisherForMessaging->enqueue(new MessagingMessage(
type: MESSAGE_SEND_TYPE_EXTERNAL,
project: $schedule['project'],