Merge pull request #11630 from nextcloud/bot-install-event-features

feat(BotInstallEvent): Add "features" field
This commit is contained in:
Joas Schilling 2024-02-25 10:02:53 +01:00 committed by GitHub
commit 89e20d99c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 0 deletions

View file

@ -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

View file

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
use OCA\Talk\Model\Bot;
use OCP\EventDispatcher\Event;
class BotInstallEvent extends Event {
@ -33,6 +34,7 @@ class BotInstallEvent extends Event {
protected string $secret,
protected string $url,
protected string $description = '',
protected int $features = Bot::FEATURE_WEBHOOK | Bot::FEATURE_RESPONSE,
) {
parent::__construct();
}
@ -52,4 +54,8 @@ class BotInstallEvent extends Event {
public function getDescription(): string {
return $this->description;
}
public function getFeatures(): int {
return $this->features;
}
}

View file

@ -108,6 +108,7 @@ class BotListener implements IEventListener {
$bot->setUrl($event->getUrl());
$bot->setUrlHash(sha1($event->getUrl()));
$bot->setState(Bot::STATE_ENABLED);
$bot->setFeatures($event->getFeatures());
$this->botServerMapper->insert($bot);
}
}