diff --git a/lib/Controller/BotController.php b/lib/Controller/BotController.php index bf6ce318f3..dfd3a2a689 100644 --- a/lib/Controller/BotController.php +++ b/lib/Controller/BotController.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) { } diff --git a/lib/Service/BotService.php b/lib/Service/BotService.php index e371c6ac02..3071c96fd3 100644 --- a/lib/Service/BotService.php +++ b/lib/Service/BotService.php @@ -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, );