summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-03-07 15:51:28 +0100
committerJoas Schilling <coding@schilljs.com>2024-03-07 15:51:28 +0100
commit3f686ac136343153b50d74a0c02d0615cf8200d6 (patch)
tree98ab2be9f14f679017fb474d11a08fefa755ecb7 /lib
parent9c1cb0a3a5cbfeb0c4d53b8c3127bcf6f481f379 (diff)
fix(federation): Do not allow bots in proxy conversations
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Command/Bot/Setup.php7
-rw-r--r--lib/Controller/BotController.php6
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Command/Bot/Setup.php b/lib/Command/Bot/Setup.php
index 40641a1e7..028303658 100644
--- a/lib/Command/Bot/Setup.php
+++ b/lib/Command/Bot/Setup.php
@@ -79,7 +79,12 @@ class Setup extends Base {
$returnCode = 0;
foreach ($tokens as $token) {
try {
- $this->roomManager->getRoomByToken($token);
+ $room = $this->roomManager->getRoomByToken($token);
+
+ if ($room->getRemoteServer() !== '') {
+ $output->writeln('<error>Federated conversations can not have bots: ' . $token . '</error>');
+ $returnCode = 2;
+ }
} catch (RoomNotFoundException) {
$output->writeln('<error>Conversation could not be found by token: ' . $token . '</error>');
$returnCode = 2;
diff --git a/lib/Controller/BotController.php b/lib/Controller/BotController.php
index b71342518..a12bf0c14 100644
--- a/lib/Controller/BotController.php
+++ b/lib/Controller/BotController.php
@@ -353,6 +353,12 @@ class BotController extends AEnvironmentAwareController {
#[NoAdminRequired]
#[RequireLoggedInModeratorParticipant]
public function enableBot(int $botId): DataResponse {
+ if ($this->room->getRemoteServer() !== '') {
+ return new DataResponse([
+ 'error' => 'room',
+ ], Http::STATUS_BAD_REQUEST);
+ }
+
try {
$bot = $this->botServerMapper->findById($botId);
} catch (DoesNotExistException) {