From caf3aa08d2b4709bd4b268e55982cdd2f74e49d8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 7 May 2024 14:56:23 +0200 Subject: [PATCH] fix(dashboard): Fix dashboard when the last message of a chat expired Signed-off-by: Joas Schilling --- lib/Dashboard/TalkWidget.php | 4 +-- .../features/integration/dashboard.feature | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/Dashboard/TalkWidget.php b/lib/Dashboard/TalkWidget.php index d7c9bdb136f..0ce135da886 100644 --- a/lib/Dashboard/TalkWidget.php +++ b/lib/Dashboard/TalkWidget.php @@ -237,10 +237,10 @@ protected function prepareRoom(Room $room, string $userId): WidgetItem { ); $message = $this->messageParser->createMessageFromProxyCache($room, $participant, $cachedMessage, $this->l10n); $subtitle = $this->getSubtitleFromMessage($message); - } catch (DoesNotExistException $e) { + } catch (DoesNotExistException) { // Fallback to empty subtitle } - } elseif ($room->getLastMessageId() && !$room->isFederatedConversation()) { + } elseif ($room->getLastMessageId() && $room->getLastMessage() && !$room->isFederatedConversation()) { $message = $this->messageParser->createMessage($room, $participant, $room->getLastMessage(), $this->l10n); $this->messageParser->parseMessage($message); $subtitle = $this->getSubtitleFromMessage($message); diff --git a/tests/integration/features/integration/dashboard.feature b/tests/integration/features/integration/dashboard.feature index 018427dda0c..da51558ae14 100644 --- a/tests/integration/features/integration/dashboard.feature +++ b/tests/integration/features/integration/dashboard.feature @@ -43,12 +43,30 @@ Feature: integration/dashboard And user "participant2" starts breakout rooms in room "breakout room parent" with 200 (v1) And user "participant2" broadcasts message "@participant1 hello" to room "breakout room parent" with 201 (v1) Then user "participant1" sees the following entries for dashboard widgets "spreed" (v1) - | title | subtitle | link | iconUrl | sinceId | overlayIconUrl | - | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | - | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | - | participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | title | subtitle | link | iconUrl | sinceId | overlayIconUrl | + | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | Then user "participant1" sees the following entries for dashboard widgets "spreed" (v2) - | title | subtitle | link | iconUrl | sinceId | overlayIconUrl | - | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | - | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | - | participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | title | subtitle | link | iconUrl | sinceId | overlayIconUrl | + | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + And user "participant2" set the message expiration to 3 of room "one-to-one room" with 200 (v4) + And user "participant2" sends message "Message 3" to room "one-to-one room" with 201 + And user "participant2" set the message expiration to 3 of room "group room" with 200 (v4) + And user "participant2" sends message "Message 2" to room "group room" with 201 + And user "participant2" set the message expiration to 3 of room "call room" with 200 (v4) + And user "participant2" sends message "Message 3" to room "call room" with 201 + And wait for 3 seconds + And force run "OCA\Talk\BackgroundJob\ExpireChatMessages" background jobs + Then user "participant1" sees the following entries for dashboard widgets "spreed" (v1) + | title | subtitle | link | iconUrl | sinceId | overlayIconUrl | + | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | participant2-displayname | | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + Then user "participant1" sees the following entries for dashboard widgets "spreed" (v2) + | title | subtitle | link | iconUrl | sinceId | overlayIconUrl | + | call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | | + | participant2-displayname | | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |