From bd25be94c9f2523fe6270d998565130e9a7369e8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 19 Oct 2024 23:04:16 +0200 Subject: [PATCH 1/2] fix(activity): Fix parameter type of call activity Signed-off-by: Joas Schilling --- lib/Activity/Provider/Base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Activity/Provider/Base.php b/lib/Activity/Provider/Base.php index 0c29017fd9f..d402941075d 100644 --- a/lib/Activity/Provider/Base.php +++ b/lib/Activity/Provider/Base.php @@ -99,7 +99,7 @@ protected function getRoom(Room $room, string $userId): array { return [ 'type' => 'call', - 'id' => $room->getId(), + 'id' => (string)$room->getId(), 'name' => $room->getDisplayName($userId), 'link' => $this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]), 'call-type' => $stringType, From 374f955fb0c090d0820e06700ca92776a2babf03 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 19 Oct 2024 23:12:00 +0200 Subject: [PATCH 2/2] fix(activity): Also fix former conversations Signed-off-by: Joas Schilling --- lib/Activity/Provider/Base.php | 7 +++---- lib/Activity/Provider/Invitation.php | 4 ++-- tests/php/Activity/Provider/InvitationTest.php | 10 ++++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Activity/Provider/Base.php b/lib/Activity/Provider/Base.php index d402941075d..e8ae4807820 100644 --- a/lib/Activity/Provider/Base.php +++ b/lib/Activity/Provider/Base.php @@ -107,12 +107,11 @@ protected function getRoom(Room $room, string $userId): array { ]; } - protected function getFormerRoom(IL10N $l, int $roomId): array { + protected function getFormerRoom(IL10N $l): array { return [ - 'type' => 'call', - 'id' => $roomId, + 'type' => 'highlight', + 'id' => 'deleted', 'name' => $l->t('a conversation'), - 'call-type' => Room::TYPE_UNKNOWN, ]; } diff --git a/lib/Activity/Provider/Invitation.php b/lib/Activity/Provider/Invitation.php index 9a22e38d66f..fb9f24f9cf2 100644 --- a/lib/Activity/Provider/Invitation.php +++ b/lib/Activity/Provider/Invitation.php @@ -28,11 +28,11 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): $l = $this->languageFactory->get('spreed', $language); $parameters = $event->getSubjectParameters(); - $roomParameter = $this->getFormerRoom($l, (int)$parameters['room']); try { $room = $this->manager->getRoomById((int)$parameters['room']); $roomParameter = $this->getRoom($room, $event->getAffectedUser()); - } catch (RoomNotFoundException $e) { + } catch (RoomNotFoundException) { + $roomParameter = $this->getFormerRoom($l); } $this->setSubjects($event, $l->t('{actor} invited you to {call}'), [ diff --git a/tests/php/Activity/Provider/InvitationTest.php b/tests/php/Activity/Provider/InvitationTest.php index 558b3ff6e89..bedff43fa5d 100644 --- a/tests/php/Activity/Provider/InvitationTest.php +++ b/tests/php/Activity/Provider/InvitationTest.php @@ -178,6 +178,8 @@ public function testParse(string $lang, bool $roomExists, array $params, array $ ->method('getRoom') ->with($room, 'user') ->willReturn(['call-data']); + $provider->expects($this->never()) + ->method('getFormerRoom'); } else { $this->manager->expects($this->once()) ->method('getRoomById') @@ -186,6 +188,10 @@ public function testParse(string $lang, bool $roomExists, array $params, array $ $provider->expects($this->never()) ->method('getRoom'); + $provider->expects($this->once()) + ->method('getFormerRoom') + ->with($l) + ->willReturn(['call-unknown']); } $this->l10nFactory->expects($this->once()) @@ -204,10 +210,6 @@ public function testParse(string $lang, bool $roomExists, array $params, array $ ->method('getUser') ->with($params['user']) ->willReturn(['actor-data']); - $provider->expects($this->once()) - ->method('getFormerRoom') - ->with($l, $params['room']) - ->willReturn(['call-unknown']); $provider->parse($lang, $event); }