diff --git a/appinfo/info.xml b/appinfo/info.xml index 7daa6c6eb73..d4aafa346cf 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -79,6 +79,7 @@ OCA\Talk\Migration\ClearResourceAccessCache OCA\Talk\Migration\CacheUserDisplayNames + OCA\Talk\Migration\FixLastReadMessageZero diff --git a/lib/Migration/FixLastReadMessageZero.php b/lib/Migration/FixLastReadMessageZero.php new file mode 100644 index 00000000000..23023f63ed1 --- /dev/null +++ b/lib/Migration/FixLastReadMessageZero.php @@ -0,0 +1,51 @@ +connection->getQueryBuilder(); + $update->update('talk_attendees') + /** + * -2 is {@see ChatManager::UNREAD_FIRST_MESSAGE}, but we can't use + * it in update code, because ChatManager is already loaded with the + * previous implementation. + */ + ->set('last_read_message', $update->createNamedParameter(-2, IQueryBuilder::PARAM_INT)) + ->where($update->expr()->eq('last_read_message', $update->createNamedParameter(0, IQueryBuilder::PARAM_INT))); + $updatedEntries = $update->executeStatement(); + if ($updatedEntries) { + $output->info($updatedEntries . ' attendees have been updated.'); + } + } +}