Browse Source

Merge pull request #10362 from nextcloud/bugfix/10354/duplicate-changelog-update

fix(changelog): Prevent duplicated changelog message by parallel requ…
pull/10372/head
Joas Schilling 2 years ago
committed by GitHub
parent
commit
602091220e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      lib/Chat/Changelog/Manager.php

10
lib/Chat/Changelog/Manager.php

@ -29,6 +29,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\PreConditionNotMetException;
class Manager {
@ -56,14 +57,19 @@ class Manager {
$logs = $this->getChangelogs();
$hasReceivedLog = $this->getChangelogForUser($userId);
try {
$this->config->setUserValue($userId, 'spreed', 'changelog', (string) count($logs), (string) $hasReceivedLog);
} catch (PreConditionNotMetException $e) {
// Parallel request won the race
return;
}
foreach ($logs as $key => $changelog) {
if ($key < $hasReceivedLog || $changelog === '') {
continue;
}
$this->chatManager->addChangelogMessage($room, $changelog);
}
$this->config->setUserValue($userId, 'spreed', 'changelog', (string) count($this->getChangelogs()));
}
public function getChangelogs(): array {

Loading…
Cancel
Save