Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(BotInstallEvent): Add "features" field #11630

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading