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..5badfd921c8 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; @@ -129,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)'), ]; } }