Skip to content

Commit

Permalink
Merge pull request #268 from nextcloud/backport/231/stable27
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Mar 21, 2024
2 parents ea5ba01 + a1a6919 commit 24223b8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/Controller/LockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCP\Files\Lock\ILock;
use OCP\Files\Lock\LockContext;
use OCP\Files\Lock\OwnerLockedException;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserSession;

Expand All @@ -55,19 +56,24 @@
*/
class LockController extends OCSController {
use TLogger;

private IUserSession $userSession;
private FileService $fileService;
private LockService $lockService;
private IL10N $l10n;
private int $ocsVersion;

public function __construct(
IRequest $request, IUserSession $userSession, FileService $fileService, LockService $lockService
IRequest $request,
IUserSession $userSession,
FileService $fileService,
LockService $lockService,
IL10N $l10n
) {
parent::__construct(Application::APP_ID, $request);
$this->userSession = $userSession;
$this->fileService = $fileService;
$this->lockService = $lockService;
$this->l10n = $l10n;

// We need to overload some implementation from the OCSController here
// to be able to push a custom message and data when returning other
Expand Down Expand Up @@ -147,12 +153,12 @@ private function buildOCSResponse($format, DataResponse $data) {
if ($data->getStatus() === Http::STATUS_LOCKED) {
/** @var FileLock $lock */
$lock = $data->getData();
$message = 'File is currently locked by ' . $lock->getOwner();
$message = $this->l10n->t('File is currently locked by %s', [$lock->getOwner()]);
}
if ($data->getStatus() === Http::STATUS_PRECONDITION_FAILED) {
/** @var FileLock $lock */
$lock = $data->getData();
$message = 'File is not locked';
$message = $this->l10n->t('File is not locked');
}

$containedData = $data->getData();
Expand Down

0 comments on commit 24223b8

Please sign in to comment.