Skip to content

Commit

Permalink
Merge pull request #11630 from nextcloud/bot-install-event-features
Browse files Browse the repository at this point in the history
feat(BotInstallEvent): Add "features" field
  • Loading branch information
nickvergessen authored Feb 25, 2024
2 parents 7b34e38 + 9e15258 commit 89e20d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions lib/Events/BotInstallEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace OCA\Talk\Events;

use OCA\Talk\Model\Bot;
use OCP\EventDispatcher\Event;

class BotInstallEvent extends Event {
Expand All @@ -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();
}
Expand All @@ -52,4 +54,8 @@ public function getUrl(): string {
public function getDescription(): string {
return $this->description;
}

public function getFeatures(): int {
return $this->features;
}
}
1 change: 1 addition & 0 deletions lib/Listener/BotListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 89e20d9

Please sign in to comment.