Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Db/RowCellUsergroupMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class RowCellUsergroupMapper extends RowCellMapperSuper {
use RowCellBulkFetchTrait;

protected string $table = 'tables_row_cells_usergroup';
private ?string $userId = null;

public function __construct(
IDBConnection $db,
Expand All @@ -30,6 +31,10 @@ public function __construct(
parent::__construct($db, $this->table, RowCellUsergroup::class);
}

public function setUserId(string $userId): void {
$this->userId = $userId;
}

public function filterValueToQueryParam(Column $column, mixed $value): mixed {
return $value;
}
Expand All @@ -49,7 +54,7 @@ public function formatRowData(Column $column, array $row) {
if ($valueType === UsergroupType::USER) {
$displayName = $this->userManager->getDisplayName($value) ?? $value;
} elseif ($valueType === UsergroupType::CIRCLE) {
$displayName = $this->circleHelper->getCircleDisplayName($value, ($this->userSession->getUser()?->getUID() ?: '')) ?: $value;
$displayName = $this->circleHelper->getCircleDisplayName($value, $this->userId ?? ($this->userSession->getUser()?->getUID() ?: '')) ?: $value;
} elseif ($valueType === UsergroupType::GROUP) {
$displayName = $this->groupHelper->getGroupDisplayName($value) ?: $value;
}
Expand Down
7 changes: 4 additions & 3 deletions lib/Helper/CircleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
class CircleHelper {
private bool $circlesEnabled;
private ?CirclesManager $circlesManager;
private array $federatedUsers = [];

/**
* @psalm-suppress UndefinedClass
Expand Down Expand Up @@ -55,14 +56,14 @@ public function getCircleDisplayName(string $circleId, string $userId): string {
}

try {
$federatedUser = $this->circlesManager->getFederatedUser($userId, Member::TYPE_USER);
$this->circlesManager->startSession($federatedUser);
$this->federatedUsers[$userId] ??= $this->circlesManager->getFederatedUser($userId, Member::TYPE_USER);
$this->circlesManager->startSession($this->federatedUsers[$userId]);

$circle = $this->circlesManager->getCircle($circleId);
return $circle ? ($circle->getDisplayName() ?: $circleId) : $circleId;
} catch (Throwable $e) {
if ($e->getCode() === 404) {
return $this->l10n->t('Deleted team %s.', [$circleId]);
return $this->l10n->t('Team not found');
}

$this->logger->warning('Failed to get circle display name: ' . $e->getMessage(), [
Expand Down
6 changes: 6 additions & 0 deletions lib/Middleware/ShareControlMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use InvalidArgumentException;
use OCA\Tables\Constants\ShareReceiverType;
use OCA\Tables\Db\RowCellUsergroupMapper;
use OCA\Tables\Db\Share;
use OCA\Tables\Errors\NotFoundError;
use OCA\Tables\Errors\PermissionError;
Expand Down Expand Up @@ -41,6 +42,7 @@ public function __construct(
private readonly IOCMDiscoveryService $ocmDiscoveryService,
private readonly ICloudIdManager $cloudIdManager,
private readonly ConfigService $configService,
private readonly RowCellUsergroupMapper $usergroupMapper,
) {
}

Expand All @@ -56,6 +58,10 @@ public function beforeController(Controller $controller, string $methodName): vo
$tokenInput = $this->request->getParam('token', '');
$this->assertShareTokenIsValidAndExisting($tokenInput);
$this->assertIsAccessible($tokenInput);

if ($this->share->getReceiverType() === ShareReceiverType::REMOTE) {
$this->usergroupMapper->setUserId($this->share->getReceiver());
}
}
}

Expand Down
Loading