Browse Source
feat(bots): Respect the feature flags
Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/10289/head
Joas Schilling
2 years ago
No known key found for this signature in database
GPG Key ID: 74434EFE0D2E2205
2 changed files with
13 additions and
1 deletions
-
lib/Controller/BotController.php
-
lib/Service/BotService.php
|
|
|
@ -100,6 +100,12 @@ class BotController extends AEnvironmentAwareController { |
|
|
|
$botAttempt->getBotServer()->getSecret(), |
|
|
|
$message |
|
|
|
); |
|
|
|
|
|
|
|
if (!($botAttempt->getBotServer()->getFeatures() & Bot::FEATURE_RESPONSE)) { |
|
|
|
$this->logger->debug('Not accepting response from bot ID ' . $botAttempt->getBotServer()->getId() . ' because the feature is disabled for it'); |
|
|
|
throw new \InvalidArgumentException('Feature not enabled for bot', Http::STATUS_BAD_REQUEST); |
|
|
|
} |
|
|
|
|
|
|
|
return $botAttempt; |
|
|
|
} catch (UnauthorizedException) { |
|
|
|
} |
|
|
|
|
|
|
|
@ -269,9 +269,15 @@ class BotService { |
|
|
|
$this->logger->warning('Can not find bot by ID ' . $botConversation->getBotId() . ' for token ' . $botConversation->getToken()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
$botServer = $serversMap[$botConversation->getBotId()]; |
|
|
|
|
|
|
|
if (!($botServer->getFeatures() & Bot::FEATURE_WEBHOOK)) { |
|
|
|
$this->logger->debug('Not sending webhook to bot ID ' . $botConversation->getBotId() . ' because the feature is disabled for it'); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
$bot = new Bot( |
|
|
|
$serversMap[$botConversation->getBotId()], |
|
|
|
$botServer, |
|
|
|
$botConversation, |
|
|
|
); |
|
|
|
|
|
|
|
|