Skip to content

Commit b42ebea

Browse files
committed
refactor: Add new modern events for system tag lifecycle
The old one was deprecated in 22.0.0 but didn't had a replacement. Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent 351d3c6 commit b42ebea

21 files changed

Lines changed: 425 additions & 355 deletions

File tree

apps/admin_audit/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
'OCA\\AdminAudit\\Actions\\Action' => $baseDir . '/../lib/Actions/Action.php',
1111
'OCA\\AdminAudit\\Actions\\Files' => $baseDir . '/../lib/Actions/Files.php',
1212
'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir . '/../lib/Actions/Sharing.php',
13-
'OCA\\AdminAudit\\Actions\\TagManagement' => $baseDir . '/../lib/Actions/TagManagement.php',
1413
'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir . '/../lib/Actions/Trashbin.php',
1514
'OCA\\AdminAudit\\Actions\\Versions' => $baseDir . '/../lib/Actions/Versions.php',
1615
'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
@@ -26,5 +25,6 @@
2625
'OCA\\AdminAudit\\Listener\\GroupManagementEventListener' => $baseDir . '/../lib/Listener/GroupManagementEventListener.php',
2726
'OCA\\AdminAudit\\Listener\\SecurityEventListener' => $baseDir . '/../lib/Listener/SecurityEventListener.php',
2827
'OCA\\AdminAudit\\Listener\\SharingEventListener' => $baseDir . '/../lib/Listener/SharingEventListener.php',
28+
'OCA\\AdminAudit\\Listener\\TagEventListener' => $baseDir . '/../lib/Listener/TagEventListener.php',
2929
'OCA\\AdminAudit\\Listener\\UserManagementEventListener' => $baseDir . '/../lib/Listener/UserManagementEventListener.php',
3030
);

apps/admin_audit/composer/composer/autoload_static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class ComposerStaticInitAdminAudit
2525
'OCA\\AdminAudit\\Actions\\Action' => __DIR__ . '/..' . '/../lib/Actions/Action.php',
2626
'OCA\\AdminAudit\\Actions\\Files' => __DIR__ . '/..' . '/../lib/Actions/Files.php',
2727
'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__ . '/..' . '/../lib/Actions/Sharing.php',
28-
'OCA\\AdminAudit\\Actions\\TagManagement' => __DIR__ . '/..' . '/../lib/Actions/TagManagement.php',
2928
'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__ . '/..' . '/../lib/Actions/Trashbin.php',
3029
'OCA\\AdminAudit\\Actions\\Versions' => __DIR__ . '/..' . '/../lib/Actions/Versions.php',
3130
'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
@@ -41,6 +40,7 @@ class ComposerStaticInitAdminAudit
4140
'OCA\\AdminAudit\\Listener\\GroupManagementEventListener' => __DIR__ . '/..' . '/../lib/Listener/GroupManagementEventListener.php',
4241
'OCA\\AdminAudit\\Listener\\SecurityEventListener' => __DIR__ . '/..' . '/../lib/Listener/SecurityEventListener.php',
4342
'OCA\\AdminAudit\\Listener\\SharingEventListener' => __DIR__ . '/..' . '/../lib/Listener/SharingEventListener.php',
43+
'OCA\\AdminAudit\\Listener\\TagEventListener' => __DIR__ . '/..' . '/../lib/Listener/TagEventListener.php',
4444
'OCA\\AdminAudit\\Listener\\UserManagementEventListener' => __DIR__ . '/..' . '/../lib/Listener/UserManagementEventListener.php',
4545
);
4646

apps/admin_audit/lib/Actions/TagManagement.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

apps/admin_audit/lib/AppInfo/Application.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use OCA\AdminAudit\Actions\Console;
1414
use OCA\AdminAudit\Actions\Files;
1515
use OCA\AdminAudit\Actions\Sharing;
16-
use OCA\AdminAudit\Actions\TagManagement;
1716
use OCA\AdminAudit\Actions\Trashbin;
1817
use OCA\AdminAudit\Actions\Versions;
1918
use OCA\AdminAudit\AuditLogger;
@@ -27,6 +26,7 @@
2726
use OCA\AdminAudit\Listener\GroupManagementEventListener;
2827
use OCA\AdminAudit\Listener\SecurityEventListener;
2928
use OCA\AdminAudit\Listener\SharingEventListener;
29+
use OCA\AdminAudit\Listener\TagEventListener;
3030
use OCA\AdminAudit\Listener\UserManagementEventListener;
3131
use OCA\Files_Versions\Events\VersionRestoredEvent;
3232
use OCP\App\Events\AppDisableEvent;
@@ -58,7 +58,7 @@
5858
use OCP\Share;
5959
use OCP\Share\Events\ShareCreatedEvent;
6060
use OCP\Share\Events\ShareDeletedEvent;
61-
use OCP\SystemTag\ManagerEvent;
61+
use OCP\SystemTag\Events\TagCreatedEvent;
6262
use OCP\User\Events\BeforeUserLoggedInEvent;
6363
use OCP\User\Events\BeforeUserLoggedOutEvent;
6464
use OCP\User\Events\PasswordUpdatedEvent;
@@ -127,6 +127,9 @@ public function register(IRegistrationContext $context): void {
127127
// Cache events
128128
$context->registerEventListener(CacheEntryInsertedEvent::class, CacheEventListener::class);
129129
$context->registerEventListener(CacheEntryRemovedEvent::class, CacheEventListener::class);
130+
131+
// System tag event
132+
$context->registerEventListener(TagCreatedEvent::class, TagEventListener::class);
130133
}
131134

132135
#[\Override]
@@ -151,7 +154,6 @@ private function registerLegacyHooks(IAuditLogger $logger, ContainerInterface $s
151154
$this->fileHooks($logger, $eventDispatcher);
152155
$this->trashbinHooks($logger);
153156
$this->versionsHooks($logger);
154-
$this->tagHooks($logger, $eventDispatcher);
155157
}
156158

157159
private function sharingLegacyHooks(IAuditLogger $logger): void {
@@ -163,14 +165,6 @@ private function sharingLegacyHooks(IAuditLogger $logger): void {
163165
Util::connectHook(Share::class, 'share_link_access', $shareActions, 'shareAccessed');
164166
}
165167

166-
private function tagHooks(IAuditLogger $logger,
167-
IEventDispatcher $eventDispatcher): void {
168-
$eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, function (ManagerEvent $event) use ($logger): void {
169-
$tagActions = new TagManagement($logger);
170-
$tagActions->createTag($event->getTag());
171-
});
172-
}
173-
174168
private function fileHooks(IAuditLogger $logger, IEventDispatcher $eventDispatcher): void {
175169
$fileActions = new Files($logger);
176170

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH
7+
* SPDX-FileContributor: Carl Schwan
8+
* SPDX-License-Identifier: AGPL-3.0-or-later
9+
*/
10+
11+
namespace OCA\AdminAudit\Listener;
12+
13+
use OCA\AdminAudit\Actions\Action;
14+
use OCP\EventDispatcher\Event;
15+
use OCP\EventDispatcher\IEventListener;
16+
use OCP\SystemTag\Events\TagCreatedEvent;
17+
use Override;
18+
19+
/**
20+
* @template-implements IEventListener<TagCreatedEvent>
21+
*/
22+
class TagEventListener extends Action implements IEventListener {
23+
#[Override]
24+
public function handle(Event $event): void {
25+
if (!$event instanceof TagCreatedEvent) {
26+
return;
27+
}
28+
29+
$tag = $event->getTag();
30+
31+
$this->log('System tag "%s" (%s, %s) created',
32+
[
33+
'name' => $tag->getName(),
34+
'visibility' => $tag->isUserVisible() ? 'visible' : 'invisible',
35+
'assignable' => $tag->isUserAssignable() ? 'user assignable' : 'system only',
36+
],
37+
['name', 'visibility', 'assignable']
38+
);
39+
}
40+
}

apps/systemtags/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
return array(
99
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
10-
'OCA\\SystemTags\\Activity\\Listener' => $baseDir . '/../lib/Activity/Listener.php',
1110
'OCA\\SystemTags\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php',
1211
'OCA\\SystemTags\\Activity\\Setting' => $baseDir . '/../lib/Activity/Setting.php',
12+
'OCA\\SystemTags\\Activity\\TagListener' => $baseDir . '/../lib/Activity/TagListener.php',
1313
'OCA\\SystemTags\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
1414
'OCA\\SystemTags\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
1515
'OCA\\SystemTags\\Command\\Files\\Add' => $baseDir . '/../lib/Command/Files/Add.php',

apps/systemtags/composer/composer/autoload_static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class ComposerStaticInitSystemTags
2222

2323
public static $classMap = array (
2424
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
25-
'OCA\\SystemTags\\Activity\\Listener' => __DIR__ . '/..' . '/../lib/Activity/Listener.php',
2625
'OCA\\SystemTags\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
2726
'OCA\\SystemTags\\Activity\\Setting' => __DIR__ . '/..' . '/../lib/Activity/Setting.php',
27+
'OCA\\SystemTags\\Activity\\TagListener' => __DIR__ . '/..' . '/../lib/Activity/TagListener.php',
2828
'OCA\\SystemTags\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
2929
'OCA\\SystemTags\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
3030
'OCA\\SystemTags\\Command\\Files\\Add' => __DIR__ . '/..' . '/../lib/Command/Files/Add.php',

0 commit comments

Comments
 (0)