From e48f514498fb5a3fdb4ede40df2e791978b69c3b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 13 Sep 2024 08:58:00 +0200 Subject: [PATCH 1/2] fix(changelog): Don't count the user changelog twice Signed-off-by: Joas Schilling --- lib/Chat/Changelog/Listener.php | 4 ---- lib/Chat/Changelog/Manager.php | 17 +++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/Chat/Changelog/Listener.php b/lib/Chat/Changelog/Listener.php index 4a40457af32..3956bf1ba86 100644 --- a/lib/Chat/Changelog/Listener.php +++ b/lib/Chat/Changelog/Listener.php @@ -32,10 +32,6 @@ public function handle(Event $event): void { return; } - if (!$this->manager->userHasNewChangelog($event->getUserId())) { - return; - } - $this->manager->updateChangelog($event->getUserId()); } } diff --git a/lib/Chat/Changelog/Manager.php b/lib/Chat/Changelog/Manager.php index 6c3c2a9657c..d6996c7fdee 100644 --- a/lib/Chat/Changelog/Manager.php +++ b/lib/Chat/Changelog/Manager.php @@ -32,23 +32,24 @@ public function getChangelogForUser(string $userId): int { return (int)$this->config->getUserValue($userId, 'spreed', 'changelog', '0'); } - public function userHasNewChangelog(string $userId): bool { - return $this->getChangelogForUser($userId) < count($this->getChangelogs()); - } - public function updateChangelog(string $userId): void { - $room = $this->roomManager->getChangelogRoom($userId); - $logs = $this->getChangelogs(); $hasReceivedLog = $this->getChangelogForUser($userId); + $shouldHaveReceived = count($logs); + + if ($hasReceivedLog === $shouldHaveReceived) { + return; + } try { - $this->config->setUserValue($userId, 'spreed', 'changelog', (string)count($logs), (string)$hasReceivedLog); - } catch (PreConditionNotMetException $e) { + $this->config->setUserValue($userId, 'spreed', 'changelog', (string)$shouldHaveReceived, (string)$hasReceivedLog); + } catch (PreConditionNotMetException) { // Parallel request won the race return; } + $room = $this->roomManager->getChangelogRoom($userId); + foreach ($logs as $key => $changelog) { if ($key < $hasReceivedLog || $changelog === '') { continue; From 5d4159dd641a714dd29b3494bb9798c5489ade3f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 13 Sep 2024 08:59:26 +0200 Subject: [PATCH 2/2] fix(changelog): Remove "Preview" prefix from changelog messages Signed-off-by: Joas Schilling --- lib/Chat/Changelog/Manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Chat/Changelog/Manager.php b/lib/Chat/Changelog/Manager.php index d6996c7fdee..5badfd921c8 100644 --- a/lib/Chat/Changelog/Manager.php +++ b/lib/Chat/Changelog/Manager.php @@ -130,11 +130,11 @@ public function getChangelogs(): array { $this->l->t('## New in Talk %s', ['19']) . "\n" . $this->l->t('- Messages can now be edited by logged-in authors and moderators for 6 hours') . "\n" . $this->l->t('- Unsent message drafts are now saved in your browser') . "\n" - . $this->l->t('- *Preview:* Text chatting can now be done in a federated way with other Talk servers'), + . $this->l->t('- Text chatting can now be done in a federated way with other Talk servers'), $this->l->t('## New in Talk %s', ['20']) . "\n" . $this->l->t('- Moderators can now ban accounts and guests to prevent them from rejoining a conversation') . "\n" . $this->l->t('- Upcoming calls from linked calendar events and out-of-office replacements are now shown in conversations') . "\n" - . $this->l->t('- *Preview:* Calls can now be done in a federated way with other Talk servers (requires the High-performance backend)'), + . $this->l->t('- Calls can now be done in a federated way with other Talk servers (requires the High-performance backend)'), ]; } }