Skip to content

Commit

Permalink
accept current user filelock
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Sep 28, 2023
1 parent c6dc44f commit 6652f3c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,16 @@ private function lock(Wopi $wopi, string $lock): JSONResponse {
} catch (NoLockProviderException|PreConditionNotMetException $e) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
} catch (OwnerLockedException $e) {

// This is a quick custom patch to allow richdocuments to accept lock from current user
/** @var OCP\IUserSession $userSession */
$userSession = \OC::$server->get(\OCP\IUserSession::class);
$known = $e->getLock();
if ($known->getType() === ILock::TYPE_USER &&
$known->getOwner() === $userSession->getUser()->getUID()) {
return new JSONResponse();
}

return new JSONResponse([], Http::STATUS_LOCKED);
} catch (\Exception $e) {
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
Expand Down

0 comments on commit 6652f3c

Please sign in to comment.