Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/error display name #278

Merged
merged 3 commits into from
Apr 2, 2024
Merged
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
1 change: 1 addition & 0 deletions lib/Controller/LockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ private function buildOCSResponse($format, DataResponse $data) {
if ($data->getStatus() === Http::STATUS_LOCKED) {
/** @var FileLock $lock */
$lock = $data->getData();
$this->lockService->injectMetadata($lock);
$message = $this->l10n->t('File is currently locked by %s', [$lock->getDisplayName()]);
}
if ($data->getStatus() === Http::STATUS_PRECONDITION_FAILED) {
Expand Down
15 changes: 2 additions & 13 deletions lib/Service/LockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,24 +333,13 @@ public function getLockFromFileId(int $fileId): FileLock {
public function injectMetadata(FileLock $lock): FileLock {
$displayName = null;
if ($lock->getType() === ILock::TYPE_USER) {
if (!method_exists($this->userManager, 'getDisplayName')) {
// TODO: Remove once 25 is the minimum supported version
$displayName = $this->userManager->get($lock->getOwner())->getDisplayName();
} else {
$displayName = $this->userManager->getDisplayName($lock->getOwner());
}
$displayName = $this->userManager->getDisplayName($lock->getOwner());
}
if ($lock->getType() === ILock::TYPE_APP) {
$displayName = $this->getAppName($lock->getOwner()) ?? null;
}
if ($lock->getType() === ILock::TYPE_TOKEN) {
if (!method_exists($this->userManager, 'getDisplayName')) {
// TODO: Remove once 25 is the minimum supported version
$user = $this->userManager->get($lock->getOwner());
$displayName = $user ? $user->getDisplayName(): $lock->getDisplayName();
} else {
$displayName = $this->userManager->getDisplayName($lock->getOwner()) ?? $lock->getDisplayName();
}
$displayName = $this->userManager->getDisplayName($lock->getOwner()) ?? $lock->getDisplayName();
come-nc marked this conversation as resolved.
Show resolved Hide resolved
}

if ($displayName) {
Expand Down
19 changes: 5 additions & 14 deletions lib/Tools/Db/ExtendedQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
use OCP\DB\QueryBuilder\ICompositeExpression;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\ILogger;
use Psr\Log\LoggerInterface;

class ExtendedQueryBuilder extends QueryBuilder {
Expand All @@ -59,19 +58,11 @@ class ExtendedQueryBuilder extends QueryBuilder {
* ExtendedQueryBuilder constructor.
*/
public function __construct() {
if (\OCP\Util::getVersion()[0] >= 24) {
parent::__construct(
OC::$server->get(IDBConnection::class),
OC::$server->get(SystemConfig::class),
OC::$server->get(LoggerInterface::class)
);
} else {
parent::__construct(
OC::$server->get(IDBConnection::class),
OC::$server->get(SystemConfig::class),
OC::$server->get(ILogger::class)
);
}
parent::__construct(
OC::$server->get(IDBConnection::class),
OC::$server->get(SystemConfig::class),
OC::$server->get(LoggerInterface::class)
);
}


Expand Down
Loading