From d06d4d61c7e4c03c05e4bae9e5edf1760cdc7a24 Mon Sep 17 00:00:00 2001 From: Philip Stadermann Date: Mon, 6 Oct 2025 08:35:52 +0200 Subject: [PATCH 01/10] Upgrade to Nextcloud 32 --- appinfo/info.xml | 2 +- lib/AppInfo/Application.php | 8 ++------ lib/Service/FileService.php | 18 ++++++++++++------ lib/Service/VerdictService.php | 2 +- ...emTagObjectMapperWithoutActivityFactory.php | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index c76d3d1a..ad31416d 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -55,7 +55,7 @@ Please make sure the "Authentication Method" "Resource Owner Password Flow" is s pgsql mysql sqlite - + OCA\GDataVaas\BackgroundJobs\ScanJob diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index e1fedb45..cffd2710 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -16,7 +16,6 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; -use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\IDBConnection; use OCP\SystemTag\ISystemTagManager; @@ -37,11 +36,8 @@ public function __construct() { parent::__construct(self::APP_ID); $container = $this->getContainer(); - $eventDispatcher = $container->get(IEventDispatcher::class); - assert($eventDispatcher instanceof IEventDispatcher); - $eventDispatcher->addListener(LoadAdditionalScriptsEvent::class, function () { - Util::addScript(self::APP_ID, 'gdatavaas-files-action'); - }); + // Add the script directly for Nextcloud 32 compatibility + Util::addScript(self::APP_ID, 'gdatavaas-files-action'); } /** diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index a9217621..ad8d1f74 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -6,8 +6,7 @@ namespace OCA\GDataVaas\Service; -use OC; -use OC\User\NoUserException; +use OCP\User\NoUserException; use OCA\Files_Trashbin\Trash\ITrashManager; use OCA\GDataVaas\AppInfo\Application; use OCP\App\IAppManager; @@ -30,6 +29,7 @@ class FileService { private IAppConfig $appConfig; private LoggerInterface $logger; private IAppManager $appManager; + private ?ITrashManager $trashManager; public function __construct( LoggerInterface $logger, @@ -37,12 +37,14 @@ public function __construct( IRootFolder $rootFolder, IAppConfig $appConfig, IAppManager $appManager, + ?ITrashManager $trashManager = null, ) { $this->userMountCache = $userMountCache; $this->rootFolder = $rootFolder; $this->appConfig = $appConfig; $this->logger = $logger; $this->appManager = $appManager; + $this->trashManager = $trashManager; } /** @@ -138,10 +140,14 @@ public function deleteFile(int $fileId): void { $file = $this->getNodeFromFileId($fileId); $file->unlock(ILockingProvider::LOCK_SHARED); if ($this->appManager->isEnabledForUser('files_trashbin')) { - $trashManager = OC::$server->get(ITrashManager::class); - $trashManager->pauseTrash(); - $file->delete(); - $trashManager->resumeTrash(); + if ($this->trashManager !== null) { + $this->trashManager->pauseTrash(); + $file->delete(); + $this->trashManager->resumeTrash(); + } else { + // Fallback: if no trash manager is available, just delete the file + $file->delete(); + } } else { $file->delete(); } diff --git a/lib/Service/VerdictService.php b/lib/Service/VerdictService.php index b7c6638b..3671123a 100644 --- a/lib/Service/VerdictService.php +++ b/lib/Service/VerdictService.php @@ -7,7 +7,7 @@ namespace OCA\GDataVaas\Service; use Exception; -use OC\User\NoUserException; +use OCP\User\NoUserException; use OCA\GDataVaas\AppInfo\Application; use OCP\Files\EntityTooLargeException; use OCP\Files\NotFoundException; diff --git a/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php b/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php index 2d5c5e22..3a8f36dc 100644 --- a/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php +++ b/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php @@ -6,7 +6,7 @@ namespace OCA\GDataVaas\SystemTag; -use OC\SystemTag\SystemTagObjectMapper; +use OCP\SystemTag\SystemTagObjectMapper; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\IDBConnection; From 1e010598428c8977964eb73552ce2a020372972e Mon Sep 17 00:00:00 2001 From: Verdict-as-a-Service Team Date: Mon, 6 Oct 2025 14:51:03 +0200 Subject: [PATCH 02/10] replace OC_Template with ITemplateManager --- lib/EventListener/FileEventsListener.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/EventListener/FileEventsListener.php b/lib/EventListener/FileEventsListener.php index d454c5c7..e1901606 100644 --- a/lib/EventListener/FileEventsListener.php +++ b/lib/EventListener/FileEventsListener.php @@ -7,7 +7,7 @@ namespace OCA\GDataVaas\EventListener; use Exception; -use OC_Template; +use OCP\Template\ITemplateManager; use OCA\GDataVaas\AppInfo\Application; use OCA\GDataVaas\Exceptions\VirusFoundException; use OCA\GDataVaas\Service\FileService; @@ -42,6 +42,7 @@ public function __construct( private readonly TagService $tagService, private readonly IAppConfig $appConfig, private readonly MailService $mailService, + private readonly ITemplateManager $templateManager ) { } @@ -125,7 +126,7 @@ public function generateBody(Exception $ex): string { $debug = $this->config->getSystemValueBool('debug'); - $content = new OC_Template('gdatavaas', $templateName, $renderAs); + $content = $this->templateManager->getTemplate('gdatavaas', $templateName, $renderAs); $content->assign('title', 'Error'); $content->assign('message', $ex->getMessage()); $content->assign('remoteAddr', $this->request->getRemoteAddress()); From 07c8cbda563601925bff21c0772cd348e17b84cd Mon Sep 17 00:00:00 2001 From: Philip Stadermann Date: Mon, 6 Oct 2025 14:56:08 +0200 Subject: [PATCH 03/10] Revert "Upgrade to Nextcloud 32" This reverts commit d06d4d61c7e4c03c05e4bae9e5edf1760cdc7a24. --- lib/AppInfo/Application.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index cffd2710..e1fedb45 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -16,6 +16,7 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\IDBConnection; use OCP\SystemTag\ISystemTagManager; @@ -36,8 +37,11 @@ public function __construct() { parent::__construct(self::APP_ID); $container = $this->getContainer(); - // Add the script directly for Nextcloud 32 compatibility - Util::addScript(self::APP_ID, 'gdatavaas-files-action'); + $eventDispatcher = $container->get(IEventDispatcher::class); + assert($eventDispatcher instanceof IEventDispatcher); + $eventDispatcher->addListener(LoadAdditionalScriptsEvent::class, function () { + Util::addScript(self::APP_ID, 'gdatavaas-files-action'); + }); } /** From f8a3ae66793be2f890a2c93c1045dbba7ea5f350 Mon Sep 17 00:00:00 2001 From: Philip Stadermann Date: Mon, 6 Oct 2025 14:56:27 +0200 Subject: [PATCH 04/10] Revert "Upgrade to Nextcloud 32" This reverts commit d06d4d61c7e4c03c05e4bae9e5edf1760cdc7a24. --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index ad31416d..c76d3d1a 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -55,7 +55,7 @@ Please make sure the "Authentication Method" "Resource Owner Password Flow" is s pgsql mysql sqlite - + OCA\GDataVaas\BackgroundJobs\ScanJob From c4e99e28a8b9d225bb06448467753091974e6ee6 Mon Sep 17 00:00:00 2001 From: Philip Stadermann Date: Mon, 6 Oct 2025 15:04:30 +0200 Subject: [PATCH 05/10] Revert "Upgrade to Nextcloud 32" This reverts commit d06d4d61c7e4c03c05e4bae9e5edf1760cdc7a24. --- lib/Service/FileService.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index ad8d1f74..a9217621 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -6,7 +6,8 @@ namespace OCA\GDataVaas\Service; -use OCP\User\NoUserException; +use OC; +use OC\User\NoUserException; use OCA\Files_Trashbin\Trash\ITrashManager; use OCA\GDataVaas\AppInfo\Application; use OCP\App\IAppManager; @@ -29,7 +30,6 @@ class FileService { private IAppConfig $appConfig; private LoggerInterface $logger; private IAppManager $appManager; - private ?ITrashManager $trashManager; public function __construct( LoggerInterface $logger, @@ -37,14 +37,12 @@ public function __construct( IRootFolder $rootFolder, IAppConfig $appConfig, IAppManager $appManager, - ?ITrashManager $trashManager = null, ) { $this->userMountCache = $userMountCache; $this->rootFolder = $rootFolder; $this->appConfig = $appConfig; $this->logger = $logger; $this->appManager = $appManager; - $this->trashManager = $trashManager; } /** @@ -140,14 +138,10 @@ public function deleteFile(int $fileId): void { $file = $this->getNodeFromFileId($fileId); $file->unlock(ILockingProvider::LOCK_SHARED); if ($this->appManager->isEnabledForUser('files_trashbin')) { - if ($this->trashManager !== null) { - $this->trashManager->pauseTrash(); - $file->delete(); - $this->trashManager->resumeTrash(); - } else { - // Fallback: if no trash manager is available, just delete the file - $file->delete(); - } + $trashManager = OC::$server->get(ITrashManager::class); + $trashManager->pauseTrash(); + $file->delete(); + $trashManager->resumeTrash(); } else { $file->delete(); } From ae9f9a3f61e91fac49261b32060ed42388a920d5 Mon Sep 17 00:00:00 2001 From: Philip Stadermann Date: Mon, 6 Oct 2025 15:04:50 +0200 Subject: [PATCH 06/10] Revert "Upgrade to Nextcloud 32" This reverts commit d06d4d61c7e4c03c05e4bae9e5edf1760cdc7a24. --- lib/Service/VerdictService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/VerdictService.php b/lib/Service/VerdictService.php index 3671123a..b7c6638b 100644 --- a/lib/Service/VerdictService.php +++ b/lib/Service/VerdictService.php @@ -7,7 +7,7 @@ namespace OCA\GDataVaas\Service; use Exception; -use OCP\User\NoUserException; +use OC\User\NoUserException; use OCA\GDataVaas\AppInfo\Application; use OCP\Files\EntityTooLargeException; use OCP\Files\NotFoundException; From 3993e3c489687570753b633d0c3f53d1eada666e Mon Sep 17 00:00:00 2001 From: Philip Stadermann Date: Mon, 6 Oct 2025 15:06:05 +0200 Subject: [PATCH 07/10] Revert "Upgrade to Nextcloud 32" This reverts commit d06d4d61c7e4c03c05e4bae9e5edf1760cdc7a24. --- lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php b/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php index 3a8f36dc..2d5c5e22 100644 --- a/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php +++ b/lib/SystemTag/SystemTagObjectMapperWithoutActivityFactory.php @@ -6,7 +6,7 @@ namespace OCA\GDataVaas\SystemTag; -use OCP\SystemTag\SystemTagObjectMapper; +use OC\SystemTag\SystemTagObjectMapper; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\IDBConnection; From 4aac669cf4030e6905fe588e37598ba36deee2f5 Mon Sep 17 00:00:00 2001 From: PT-ATA No One Date: Mon, 6 Oct 2025 13:53:28 +0000 Subject: [PATCH 08/10] Upgrade to Nextcloud v32.0.0 --- Makefile | 2 +- appinfo/info.xml | 2 +- composer.json | 4 ++-- docker-compose.yaml | 2 +- scripts/get-nc-server.sh | 2 +- scripts/run-app.sh | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 156d598c..3bc0fcee 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,7 @@ local: build docker compose kill || true docker stop nextcloud-container || true docker container rm nextcloud-container || true - docker run --rm -d -p 8080:80 --name nextcloud-container -e SERVER_BRANCH="v31.0.8" -v .:/var/www/html/apps-extra/gdatavaas ghcr.io/juliusknorr/nextcloud-dev-php84:latest + docker run --rm -d -p 8080:80 --name nextcloud-container -e SERVER_BRANCH="v32.0.0" -v .:/var/www/html/apps-extra/gdatavaas ghcr.io/juliusknorr/nextcloud-dev-php84:latest composer install # Builds the app for production and prepares it for the appstore under ./build/artifacts diff --git a/appinfo/info.xml b/appinfo/info.xml index c76d3d1a..362d6388 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -55,7 +55,7 @@ Please make sure the "Authentication Method" "Resource Owner Password Flow" is s pgsql mysql sqlite - + OCA\GDataVaas\BackgroundJobs\ScanJob diff --git a/composer.json b/composer.json index 1f99715d..56f2e8ca 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "coduo/php-humanizer": "5.0.0" }, "require-dev": { - "nextcloud/ocp": "v31.0.8", + "nextcloud/ocp": "v32.0.0", "psalm/phar": "6.8.2", "nextcloud/coding-standard": "v1.4.0", "colinodell/psr-testlogger": "1.3.0", @@ -45,4 +45,4 @@ "php": "8.1" } } -} +} \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 7a5cf344..8cf5dd78 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,7 +4,7 @@ services: nextcloud-container: - image: nextcloud:31.0.8 + image: nextcloud:32.0.0 ports: - "8080:80" container_name: nextcloud-container diff --git a/scripts/get-nc-server.sh b/scripts/get-nc-server.sh index b2d1c092..b0be2688 100755 --- a/scripts/get-nc-server.sh +++ b/scripts/get-nc-server.sh @@ -5,7 +5,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later rm -rf nextcloud-server/ -export NEXTCLOUD_VERSION=${1:-31.0.8} +export NEXTCLOUD_VERSION=${1:-32.0.0} git clone --depth 1 --recurse-submodules --single-branch --branch v"$NEXTCLOUD_VERSION" https://github.com/nextcloud/server.git ./nextcloud-server cd nextcloud-server || exit 1 git submodule update --init diff --git a/scripts/run-app.sh b/scripts/run-app.sh index 94ef9044..2a0c0b31 100755 --- a/scripts/run-app.sh +++ b/scripts/run-app.sh @@ -6,7 +6,7 @@ set -e -export NEXTCLOUD_VERSION=${1:-31.0.8} +export NEXTCLOUD_VERSION=${1:-32.0.0} export IS_CI=${2:-0} if [ "$IS_CI" -eq 0 ]; then From 6d16635051f89d3a032ced06ea8f1c3151ed74ed Mon Sep 17 00:00:00 2001 From: PT-ATA No One Date: Tue, 7 Oct 2025 08:18:48 +0000 Subject: [PATCH 09/10] Fix upload message --- lib/EventListener/FileEventsListener.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/EventListener/FileEventsListener.php b/lib/EventListener/FileEventsListener.php index e1901606..1e29b5a1 100644 --- a/lib/EventListener/FileEventsListener.php +++ b/lib/EventListener/FileEventsListener.php @@ -15,6 +15,7 @@ use OCA\GDataVaas\Service\TagService; use OCA\GDataVaas\Service\VerdictService; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\AppFramework\Http\TemplateResponse; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\Files\Events\Node\NodeWrittenEvent; @@ -43,8 +44,7 @@ public function __construct( private readonly IAppConfig $appConfig, private readonly MailService $mailService, private readonly ITemplateManager $templateManager - ) { - } + ) {} public static function register(IRegistrationContext $context): void { $context->registerEventListener(NodeWrittenEvent::class, self::class); @@ -116,11 +116,11 @@ private function sendErrorResponse(Exception $ex): void { public function generateBody(Exception $ex): string { if ($this->acceptHtml()) { - $renderAs = 'guest'; + $renderAs = TemplateResponse::RENDER_AS_GUEST; $templateName = 'exception'; } else { $templateName = 'xml_exception'; - $renderAs = null; + $renderAs = TemplateResponse::RENDER_AS_BLANK; $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); } From f84606271d7a4741a40cf8ab8efc61f0c7ce3817 Mon Sep 17 00:00:00 2001 From: PT-ATA No One Date: Tue, 7 Oct 2025 08:30:09 +0000 Subject: [PATCH 10/10] Fix linter errors --- lib/EventListener/FileEventsListener.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/EventListener/FileEventsListener.php b/lib/EventListener/FileEventsListener.php index 1e29b5a1..76b11adf 100644 --- a/lib/EventListener/FileEventsListener.php +++ b/lib/EventListener/FileEventsListener.php @@ -7,7 +7,6 @@ namespace OCA\GDataVaas\EventListener; use Exception; -use OCP\Template\ITemplateManager; use OCA\GDataVaas\AppInfo\Application; use OCA\GDataVaas\Exceptions\VirusFoundException; use OCA\GDataVaas\Service\FileService; @@ -28,6 +27,7 @@ use OCP\IRequest; use OCP\IUserSession; use OCP\Lock\LockedException; +use OCP\Template\ITemplateManager; use Psr\Log\LoggerInterface; use Sabre\DAV\Server; @@ -43,8 +43,9 @@ public function __construct( private readonly TagService $tagService, private readonly IAppConfig $appConfig, private readonly MailService $mailService, - private readonly ITemplateManager $templateManager - ) {} + private readonly ITemplateManager $templateManager, + ) { + } public static function register(IRegistrationContext $context): void { $context->registerEventListener(NodeWrittenEvent::class, self::class);