From d397642329dca174c5a551944161fd7e92aed3c0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 26 Oct 2026 16:39:31 +0100 Subject: [PATCH 1/2] fix(debugging): Redact chat-relay comments in debug log Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Joas Schilling --- lib/Signaling/BackendNotifier.php | 5 ++ tests/php/Signaling/BackendNotifierTest.php | 77 +++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 tests/php/Signaling/BackendNotifierTest.php diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index 0883bd54f22..0373f745406 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -532,6 +532,11 @@ public function sendRoomMessage(Room $room, array $message): void { ], ]); $duration = microtime(true) - $start; + + // Don't log chat messages to not leak the content + if (isset($message['chat']['comment'])) { + $message['chat']['comment'] = '[redacted #' . ($message['chat']['comment']['id'] ?? 'null') . ']'; + } $this->logger->debug('Send room message: {token} {message} ({duration})', [ 'token' => $room->getToken(), 'message' => $message, diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php new file mode 100644 index 00000000000..1eaf0a061ef --- /dev/null +++ b/tests/php/Signaling/BackendNotifierTest.php @@ -0,0 +1,77 @@ +logger = $this->createMock(LoggerInterface::class); + $this->backendNotifier = new BackendNotifier( + $this->createMock(Config::class), + $this->createMock(IAppConfig::class), + $this->logger, + $this->createMock(IClientService::class), + $this->createMock(ISecureRandom::class), + $this->createMock(Manager::class), + $this->createMock(ParticipantService::class), + $this->createMock(IURLGenerator::class), + $this->createMock(RoomPropertiesHelper::class), + ); + } + + public static function dataSendRoomMessageLog(): array { + return [ + 'chat message' => [ + ['type' => 'chat', 'chat' => ['refresh' => true, 'comment' => ['id' => 42, 'actorDisplayName' => 'Alice', 'message' => 'Secret', 'parent' => ['message' => 'Secret parent']]]], + ['type' => 'chat', 'chat' => ['refresh' => true, 'comment' => '[redacted #42]']], + ], + 'chat refresh' => [ + ['type' => 'chat', 'chat' => ['refresh' => true]], + ['type' => 'chat', 'chat' => ['refresh' => true]], + ], + 'recording' => [ + ['type' => 'recording', 'recording' => ['status' => 1]], + ['type' => 'recording', 'recording' => ['status' => 1]], + ], + ]; + } + + #[DataProvider('dataSendRoomMessageLog')] + public function testSendRoomMessageLog(array $message, array $expected): void { + $room = $this->createMock(Room::class); + $room->method('getToken')->willReturn('token'); + + $this->logger->expects($this->once()) + ->method('debug') + ->with('Send room message: {token} {message} ({duration})', $this->callback(function (array $context) use ($expected): bool { + $this->assertSame($expected, $context['message']); + return true; + })); + + $this->backendNotifier->sendRoomMessage($room, $message); + } +} From 1dc68683f7ae71c0bf3591256777f755d6004de4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 27 Oct 2026 12:17:24 +0100 Subject: [PATCH 2/2] test: Fix unit tests Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Joas Schilling --- tests/php/Signaling/BackendNotifierTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php index 1eaf0a061ef..6ecff07fbdd 100644 --- a/tests/php/Signaling/BackendNotifierTest.php +++ b/tests/php/Signaling/BackendNotifierTest.php @@ -13,7 +13,6 @@ use OCA\Talk\Service\ParticipantService; use OCA\Talk\Signaling\BackendNotifier; use OCA\Talk\Signaling\Manager; -use OCA\Talk\Signaling\RoomPropertiesHelper; use OCP\AppFramework\Services\IAppConfig; use OCP\Http\Client\IClientService; use OCP\IURLGenerator; @@ -30,8 +29,10 @@ class BackendNotifierTest extends TestCase { public function setUp(): void { parent::setUp(); $this->logger = $this->createMock(LoggerInterface::class); + $config = $this->createMock(Config::class); + $config->method('getSignalingMode')->willReturn(Config::SIGNALING_INTERNAL); $this->backendNotifier = new BackendNotifier( - $this->createMock(Config::class), + $config, $this->createMock(IAppConfig::class), $this->logger, $this->createMock(IClientService::class), @@ -39,7 +40,6 @@ public function setUp(): void { $this->createMock(Manager::class), $this->createMock(ParticipantService::class), $this->createMock(IURLGenerator::class), - $this->createMock(RoomPropertiesHelper::class), ); }