diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php
index 9fb6fddbdbe99..db2b757143871 100644
--- a/apps/files/lib/AppInfo/Application.php
+++ b/apps/files/lib/AppInfo/Application.php
@@ -45,6 +45,7 @@
use OCA\Files\Sharing\Permission\NodeUpdateSharePermissionType;
use OCA\Files\Sharing\Property\NodeGridViewSharePropertyType;
use OCA\Files\Sharing\Source\NodeShareSourceType;
+use OCA\Files_Trashbin\Events\MoveToTrashEvent;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -56,6 +57,7 @@
use OCP\Files\Events\Node\BeforeNodeDeletedEvent;
use OCP\Files\Events\Node\BeforeNodeRenamedEvent;
use OCP\Files\Events\Node\NodeCopiedEvent;
+use OCP\Files\Events\Node\NodeDeletedEvent;
use OCP\Files\Events\NodeAddedToFavorite;
use OCP\Files\Events\NodeRemovedFromFavorite;
use OCP\Interaction\RestrictInteractionEvent;
@@ -136,6 +138,9 @@ public function register(IRegistrationContext $context): void {
$registry->registerPermissionType(NodeShareSourceType::class, Server::get(NodeDownloadSharePermissionType::class));
$registry->markPermissionTypeCompatibleWithPermissionPreset(NodeDownloadSharePermissionType::class, ViewSharePermissionPreset::class);
$registry->markPermissionTypeCompatibleWithPermissionPreset(NodeDownloadSharePermissionType::class, EditSharePermissionPreset::class);
+
+ $context->registerEventListener(NodeDeletedEvent::class, NodeShareSourceType::class);
+ $context->registerEventListener(MoveToTrashEvent::class, NodeShareSourceType::class);
}
#[\Override]
diff --git a/apps/files/lib/Sharing/Source/NodeShareSourceType.php b/apps/files/lib/Sharing/Source/NodeShareSourceType.php
index e2b10ca37a3aa..eda0bc37e0f9c 100644
--- a/apps/files/lib/Sharing/Source/NodeShareSourceType.php
+++ b/apps/files/lib/Sharing/Source/NodeShareSourceType.php
@@ -46,8 +46,6 @@ public function __construct(
private ISharingManager $manager,
private IFileAccess $fileAccess,
) {
- $eventDispatcher->addServiceListener(NodeDeletedEvent::class, self::class);
- $eventDispatcher->addServiceListener(MoveToTrashEvent::class, self::class);
}
#[\Override]
diff --git a/apps/sharing/lib/AppInfo/Application.php b/apps/sharing/lib/AppInfo/Application.php
index 680e125b05bcc..f7061efe270e9 100644
--- a/apps/sharing/lib/AppInfo/Application.php
+++ b/apps/sharing/lib/AppInfo/Application.php
@@ -9,12 +9,14 @@
namespace OCA\Sharing\AppInfo;
+use OC\Sharing\SharingManager;
use OCA\Sharing\Capabilities;
use OCA\Sharing\Middleware\ShareApiEnabledMiddleware;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
+use OCP\User\Events\BeforeUserDeletedEvent;
final class Application extends App implements IBootstrap {
public const string APP_ID = 'sharing';
@@ -27,6 +29,8 @@ public function __construct(array $urlParams = []) {
public function register(IRegistrationContext $context): void {
$context->registerCapability(Capabilities::class);
$context->registerMiddleware(ShareApiEnabledMiddleware::class);
+
+ $context->registerEventListener(BeforeUserDeletedEvent::class, SharingManager::class);
}
#[\Override]
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 6dbdb8a6c0e9b..2592c94081e2b 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -2711,6 +2711,14 @@
+
+
+
+
+
+
+
+
@@ -3055,15 +3063,9 @@
-
-
-
-
-
-
diff --git a/core/AppInfo/Application.php b/core/AppInfo/Application.php
index 42a3a09f2625a..8881732029fff 100644
--- a/core/AppInfo/Application.php
+++ b/core/AppInfo/Application.php
@@ -42,6 +42,7 @@
use OC\DirectEditing\Listeners\UserDisabledTokenCleanupListener as UserDisabledDirectEditingTokenCleanupListener;
use OC\OCM\OCMDiscoveryHandler;
use OC\TagManager;
+use OCA\Circles\Events\DestroyingCircleEvent;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -50,6 +51,7 @@
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\DB\Events\AddMissingPrimaryKeyEvent;
+use OCP\Group\Events\BeforeGroupDeletedEvent;
use OCP\IAppConfig;
use OCP\Interaction\RestrictInteractionEvent;
use OCP\Navigation\Events\LoadAdditionalEntriesEvent;
@@ -157,6 +159,10 @@ public function register(IRegistrationContext $context): void {
if (!Server::get(IAppConfig::class)->getValueBool('files_sharing', 'shareapi_exclude_reshare_from_edit')) {
$registry->markPermissionTypeCompatibleWithPermissionPreset(ReshareSharePermissionType::class, EditSharePermissionPreset::class);
}
+
+ $context->registerEventListener(BeforeGroupDeletedEvent::class, GroupShareRecipientType::class);
+ $context->registerEventListener(DestroyingCircleEvent::class, TeamShareRecipientType::class);
+ $context->registerEventListener(BeforeUserDeletedEvent::class, UserShareRecipientType::class);
}
#[\Override]
diff --git a/core/Sharing/Recipient/GroupShareRecipientType.php b/core/Sharing/Recipient/GroupShareRecipientType.php
index 53c1de0629961..2519947c46193 100644
--- a/core/Sharing/Recipient/GroupShareRecipientType.php
+++ b/core/Sharing/Recipient/GroupShareRecipientType.php
@@ -42,7 +42,6 @@ public function __construct(
private readonly IGroupManager $groupManager,
private readonly ISharingManager $manager,
) {
- $eventDispatcher->addServiceListener(BeforeGroupDeletedEvent::class, self::class);
}
#[\Override]
diff --git a/core/Sharing/Recipient/TeamShareRecipientType.php b/core/Sharing/Recipient/TeamShareRecipientType.php
index 61a02fded937b..36a6537781558 100644
--- a/core/Sharing/Recipient/TeamShareRecipientType.php
+++ b/core/Sharing/Recipient/TeamShareRecipientType.php
@@ -42,7 +42,6 @@ public function __construct(
private readonly IDBConnection $dbConnection,
private readonly ISharingManager $manager,
) {
- $eventDispatcher->addServiceListener(DestroyingCircleEvent::class, self::class);
}
// CirclesManager class is not registered yet when the class is instantiated.
diff --git a/core/Sharing/Recipient/UserShareRecipientType.php b/core/Sharing/Recipient/UserShareRecipientType.php
index 0b4010136a4fb..113fb16a8ca8c 100644
--- a/core/Sharing/Recipient/UserShareRecipientType.php
+++ b/core/Sharing/Recipient/UserShareRecipientType.php
@@ -41,7 +41,6 @@ public function __construct(
private readonly IUserManager $userManager,
private readonly ISharingManager $manager,
) {
- $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, self::class);
}
#[\Override]
diff --git a/lib/private/Sharing/SharingManager.php b/lib/private/Sharing/SharingManager.php
index 0190d1408864a..1dd136ac6cead 100644
--- a/lib/private/Sharing/SharingManager.php
+++ b/lib/private/Sharing/SharingManager.php
@@ -77,8 +77,6 @@ public function __construct(
) {
$this->randomizer = new Randomizer();
$this->l10n = $l10nFactory->get('sharing');
-
- $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, self::class);
}
#[\Override]