diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php index 516c071c35342..5b6e8221fa6a2 100644 --- a/apps/files/lib/AppInfo/Application.php +++ b/apps/files/lib/AppInfo/Application.php @@ -46,6 +46,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; @@ -58,6 +59,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; @@ -139,6 +141,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 d1410703a1eaa..003b70c962d87 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -2635,6 +2635,14 @@ + + + + + + + + @@ -2968,15 +2976,9 @@ - - - - - - diff --git a/core/AppInfo/Application.php b/core/AppInfo/Application.php index 9c439c677112e..32ee1041c24bb 100644 --- a/core/AppInfo/Application.php +++ b/core/AppInfo/Application.php @@ -44,6 +44,7 @@ use OC\DirectEditing\Listeners\UserDisabledTokenCleanupListener as UserDisabledDirectEditingTokenCleanupListener; use OC\OCM\OCMDiscoveryHandler; use OC\TagManager; +use OCA\Circles\Events\DestroyingCircleEvent; use OCP\Accounts\UserUpdatedEvent; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; @@ -55,6 +56,7 @@ use OCP\Config\BeforeAppConfigSetEvent; 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; @@ -166,6 +168,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 a6d36ca28e782..e9bba995337b7 100644 --- a/lib/private/Sharing/SharingManager.php +++ b/lib/private/Sharing/SharingManager.php @@ -78,8 +78,6 @@ public function __construct( ) { $this->randomizer = new Randomizer(); $this->l10n = $l10nFactory->get('sharing'); - - $this->eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, self::class); } #[\Override]