feat(subscribe): --prune flag removes all stale webhooks first
All checks were successful
Deploy Max Bot Test / deploy (push) Successful in 12s
All checks were successful
Deploy Max Bot Test / deploy (push) Successful in 12s
Pipeline uses --prune so old tuna/test subscriptions don't linger after deploy. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -65,7 +65,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
ssh -i ~/.ssh/id_rsa -p ${{ vars.SERVER_PORT }} ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "
|
ssh -i ~/.ssh/id_rsa -p ${{ vars.SERVER_PORT }} ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "
|
||||||
cd /home/pkirillw/dockered-services/max-bot-test && \
|
cd /home/pkirillw/dockered-services/max-bot-test && \
|
||||||
docker compose exec -T app bin/console webhook:subscribe"
|
docker compose exec -T app bin/console webhook:subscribe --prune"
|
||||||
|
|
||||||
- name: Health check
|
- name: Health check
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ final class SubscribeWebhookCommand extends AbstractCommand
|
|||||||
$this->addOption('url', 'u', InputOption::VALUE_OPTIONAL, 'Override WEBHOOK_URL from env');
|
$this->addOption('url', 'u', InputOption::VALUE_OPTIONAL, 'Override WEBHOOK_URL from env');
|
||||||
$this->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Override MAX_BOT_API_SECRET from env');
|
$this->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Override MAX_BOT_API_SECRET from env');
|
||||||
$this->addOption('types', 't', InputOption::VALUE_OPTIONAL, 'Comma-separated update types (default: empty = all)');
|
$this->addOption('types', 't', InputOption::VALUE_OPTIONAL, 'Comma-separated update types (default: empty = all)');
|
||||||
|
$this->addOption('prune', null, InputOption::VALUE_NONE, 'Unsubscribe every other webhook before subscribing');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doExecute(SymfonyStyle $io, InputInterface $input, OutputInterface $output): int
|
protected function doExecute(SymfonyStyle $io, InputInterface $input, OutputInterface $output): int
|
||||||
@@ -39,6 +40,16 @@ final class SubscribeWebhookCommand extends AbstractCommand
|
|||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($input->getOption('prune')) {
|
||||||
|
$existing = $this->api->subscriptions->getSubscriptions();
|
||||||
|
foreach ($existing->subscriptions as $s) {
|
||||||
|
if ($s->url !== $url) {
|
||||||
|
$io->text("Pruning stale webhook: $s->url");
|
||||||
|
$this->api->subscriptions->unsubscribe($s->url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$io->text("Subscribing $url with " . ($types === [] ? 'all update types' : 'types: ' . implode(',', $types)));
|
$io->text("Subscribing $url with " . ($types === [] ? 'all update types' : 'types: ' . implode(',', $types)));
|
||||||
$result = $this->api->subscriptions->subscribe($url, $types, $secret);
|
$result = $this->api->subscriptions->subscribe($url, $types, $secret);
|
||||||
if (!$result->success) {
|
if (!$result->success) {
|
||||||
|
|||||||
Reference in New Issue
Block a user