Skip to content

Commit

Permalink
fix(activity): Also fix former conversations
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Nov 7, 2024
1 parent 7809663 commit 837d452
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 3 additions & 4 deletions lib/Activity/Provider/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Activity/Provider/Invitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}'), [
Expand Down
10 changes: 6 additions & 4 deletions tests/php/Activity/Provider/InvitationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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())
Expand All @@ -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);
}
Expand Down

0 comments on commit 837d452

Please sign in to comment.