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: Return X-WOPI-Lock when a manual lock from outside exists #442

Merged
merged 1 commit into from
May 16, 2023
Merged
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
12 changes: 11 additions & 1 deletion lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ private function getLock(Wopi $wopi): JSONResponse {
try {
$response = new JSONResponse();
$locks = $this->lockManager->getLocks($wopi->getFileid());
$existingLock = array_pop($locks);
$existingLock = array_shift($locks);
$response->addHeader('X-WOPI-Lock', $existingLock->getToken());
return $response;
} catch (NoLockProviderException|PreConditionNotMetException $e) {
Expand Down Expand Up @@ -671,6 +671,16 @@ public function postFile($fileId, $access_token) {
$wopiOverride = $this->request->getHeader('X-WOPI-Override');

if ($this->lockManager->isLockProviderAvailable()) {
$locks = $this->lockManager->getLocks($wopi->getFileid());
$existingLock = array_shift($locks);
$outsideLocked = $existingLock && $existingLock->getOwner() !== 'officeonline';
if ($outsideLocked) {
$result = new JSONResponse();
$result->setStatus(Http::STATUS_CONFLICT);
$result->addHeader('X-WOPI-Lock', $existingLock->getToken());
$result->addHeader('X-WOPI-LockFailureReason', 'File already locked by ' . $existingLock->getOwner());
return $result;
}
// Currently we do not use the return value of those methods,
// as we perform actual WOPI lock token handling through the apps own lock table
switch ($wopiOverride) {
Expand Down