Skip to content

Commit 0fda289

Browse files
leftybournesbackportbot[bot]
authored andcommitted
fix(trashbin): properly show deleted by for federated shares
Signed-off-by: Kent Delante <kent@delante.me> Assisted-by: ClaudeCode:claude-sonnet-5 When a remote user deletes a file in a federated share, the deleted by column in trashbin shows "Unknown" instead of the remote user. This fixes it so that it properly shows the remote user under the deleted by column.
1 parent e3ed4e3 commit 0fda289

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

apps/files_trashbin/lib/Trash/LegacyTrashBackend.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OCA\Files_Trashbin\Helper;
1212
use OCA\Files_Trashbin\Storage;
1313
use OCA\Files_Trashbin\Trashbin;
14+
use OCP\Federation\ICloudIdManager;
1415
use OCP\Files\FileInfo;
1516
use OCP\Files\Folder;
1617
use OCP\Files\IRootFolder;
@@ -38,7 +39,7 @@ private function mapTrashItem(FileInfo $file, IUser $user, ?ITrashItem $parent =
3839
$originalLocation = $file->getName();
3940
}
4041
/** @psalm-suppress UndefinedInterfaceMethod */
41-
$deletedBy = $this->userManager->get($file['deletedBy']) ?? $parent?->getDeletedBy();
42+
$deletedBy = $this->resolveDeletedBy($file['deletedBy']) ?? $parent?->getDeletedBy();
4243
$trashFilename = Trashbin::getTrashFilename($file->getName(), $file->getMtime());
4344
return new TrashItem(
4445
$this,
@@ -119,4 +120,29 @@ public function getTrashNodeById(IUser $user, int $fileId) {
119120
return null;
120121
}
121122
}
123+
124+
/**
125+
* Resolve the user that deleted a trash item. Files deleted by a federated share
126+
* recipient only carry the recipient's remote cloud ID, which no local IUserManager
127+
* backend can resolve, so fall back to a display-only user for the cloud ID in that
128+
* case instead of leaving the item without an "Unknown" deleted by user.
129+
*/
130+
private function resolveDeletedBy(?string $uid): ?IUser {
131+
if (!$uid) {
132+
return null;
133+
}
134+
135+
$user = $this->userManager->get($uid);
136+
if ($user !== null) {
137+
return $user;
138+
}
139+
140+
try {
141+
$cloudId = $this->cloudIdManager->resolveCloudId($uid);
142+
} catch (\InvalidArgumentException $e) {
143+
return null;
144+
}
145+
146+
return $this->userManager->getFederatedUser($cloudId);
147+
}
122148
}

lib/private/User/Manager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCP\Config\IUserConfig;
1313
use OCP\DB\QueryBuilder\IQueryBuilder;
1414
use OCP\EventDispatcher\IEventDispatcher;
15+
use OCP\Federation\ICloudId;
1516
use OCP\HintException;
1617
use OCP\ICache;
1718
use OCP\ICacheFactory;

0 commit comments

Comments
 (0)