From 9e1525872691a4e45dc2b7d7a959ab015eddd12c Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Wed, 21 Feb 2024 20:57:25 +0300 Subject: [PATCH] feat(BotInstallEvent): Added "features" field Signed-off-by: Alexander Piskun --- docs/events.md | 1 + lib/Events/BotInstallEvent.php | 6 ++++++ lib/Listener/BotListener.php | 1 + 3 files changed, 8 insertions(+) diff --git a/docs/events.md b/docs/events.md index 32cb0bad774..ad21c67ff42 100644 --- a/docs/events.md +++ b/docs/events.md @@ -193,6 +193,7 @@ Dispatch this event in your app to install a bot on this server * Event: `OCA\Talk\Events\BotInstallEvent` * Since: 17.0.0 +* Since: 19.0.0 - Features flag was added ### Bot uninstall diff --git a/lib/Events/BotInstallEvent.php b/lib/Events/BotInstallEvent.php index fa05c44194b..4ceb347bea3 100644 --- a/lib/Events/BotInstallEvent.php +++ b/lib/Events/BotInstallEvent.php @@ -25,6 +25,7 @@ namespace OCA\Talk\Events; +use OCA\Talk\Model\Bot; use OCP\EventDispatcher\Event; class BotInstallEvent extends Event { @@ -33,6 +34,7 @@ public function __construct( protected string $secret, protected string $url, protected string $description = '', + protected int $features = Bot::FEATURE_WEBHOOK | Bot::FEATURE_RESPONSE, ) { parent::__construct(); } @@ -52,4 +54,8 @@ public function getUrl(): string { public function getDescription(): string { return $this->description; } + + public function getFeatures(): int { + return $this->features; + } } diff --git a/lib/Listener/BotListener.php b/lib/Listener/BotListener.php index fe38b109f95..38ca7ba7baf 100644 --- a/lib/Listener/BotListener.php +++ b/lib/Listener/BotListener.php @@ -108,6 +108,7 @@ protected function handleBotInstallEvent(BotInstallEvent $event): void { $bot->setUrl($event->getUrl()); $bot->setUrlHash(sha1($event->getUrl())); $bot->setState(Bot::STATE_ENABLED); + $bot->setFeatures($event->getFeatures()); $this->botServerMapper->insert($bot); } }