feat: listen to user life cycle events

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-08-09 22:41:17 -04:00
parent e48c6c9bb6
commit d45d54951e
5 changed files with 117 additions and 0 deletions
+28
View File
@@ -268,6 +268,34 @@ class BlobStore {
return $blobDeleted && $metaDeleted;
}
/**
* Permanently remove the configured user storage root.
*/
public function rootDestroy(): void {
if ($this->rootPath === null || !is_dir($this->rootPath)) {
return;
}
$root = realpath($this->rootPath);
if ($root === false || $root === DIRECTORY_SEPARATOR) {
throw new RuntimeException('Refusing to destroy an invalid blob root');
}
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($root, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::CHILD_FIRST,
);
foreach ($iterator as $entry) {
if ($entry->isDir() && !$entry->isLink()) {
rmdir($entry->getPathname());
} else {
unlink($entry->getPathname());
}
}
rmdir($root);
$this->rootPath = null;
}
// ========== Blob Existence Check ==========
/**
+10
View File
@@ -796,4 +796,14 @@ class MetaStore {
}
}
/**
* Delete every chronicle entry owned by a user.
*/
public function chronicleExpungeByUser(string $tenantId, string $userId): void {
$this->_store->selectCollection($this->_ChronicleTable)->deleteMany([
'tid' => $tenantId,
'uid' => $userId,
]);
}
}