You've already forked onlyoffice-owncloud
mirror of
https://github.com/ONLYOFFICE/onlyoffice-owncloud.git
synced 2025-07-30 10:43:07 +03:00
unlock federated key
This commit is contained in:
committed by
Sergey Linnik
parent
1c2f58a82b
commit
32f48d081e
@ -520,7 +520,7 @@ class CallbackController extends Controller {
|
||||
|
||||
if ($isForcesave
|
||||
&& $file->getStorage()->instanceOfStorage(SharingExternalStorage::class)) {
|
||||
KeyManager::lockFederatedKey($file, $isForcesave);
|
||||
KeyManager::lockFederatedKey($file, $isForcesave, null);
|
||||
}
|
||||
|
||||
//lock the key when forcesave and unlock if last forcesave is broken
|
||||
@ -531,6 +531,11 @@ class CallbackController extends Controller {
|
||||
return $file->putContent($newData);
|
||||
});
|
||||
|
||||
if ($isForcesave
|
||||
&& $file->getStorage()->instanceOfStorage(SharingExternalStorage::class)) {
|
||||
KeyManager::lockFederatedKey($file, false, $isForcesave);
|
||||
}
|
||||
|
||||
//unlock key for future federated save
|
||||
KeyManager::lock($fileId, false);
|
||||
KeyManager::setForcesave($fileId, $isForcesave);
|
||||
|
@ -117,6 +117,7 @@ class FederationController extends OCSController {
|
||||
* @param string $shareToken - access token
|
||||
* @param string $path - file path
|
||||
* @param bool $lock - status
|
||||
* @param bool $fs - status
|
||||
*
|
||||
* @return Result
|
||||
*
|
||||
@ -124,7 +125,7 @@ class FederationController extends OCSController {
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*/
|
||||
public function keylock($shareToken, $path, $lock) {
|
||||
public function keylock($shareToken, $path, $lock, $fs) {
|
||||
list ($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path);
|
||||
|
||||
if (isset($error)) {
|
||||
@ -135,6 +136,9 @@ class FederationController extends OCSController {
|
||||
$fileId = $file->getId();
|
||||
|
||||
KeyManager::lock($fileId, $lock);
|
||||
if (!empty($fs)) {
|
||||
KeyManager::setForcesave($fileId, $fs);
|
||||
}
|
||||
|
||||
$this->logger->debug("Federated request lock for " . $fileId, ["app" => $this->appName]);
|
||||
return new Result();
|
||||
|
@ -159,8 +159,9 @@ class KeyManager {
|
||||
*
|
||||
* @param File $file - file
|
||||
* @param bool $lock - status
|
||||
* @param bool $fs - status
|
||||
*/
|
||||
public static function lockFederatedKey($file, $lock = true) {
|
||||
public static function lockFederatedKey($file, $lock = true, $fs) {
|
||||
$logger = \OC::$server->getLogger();
|
||||
|
||||
$remote = $file->getStorage()->getRemote();
|
||||
@ -177,6 +178,9 @@ class KeyManager {
|
||||
"lock" => $lock
|
||||
]
|
||||
];
|
||||
if (!empty($fs)) {
|
||||
$data["body"]["fs"] = $fs;
|
||||
}
|
||||
|
||||
$response = $client->post($remote . "/ocs/v2.php/apps/" . self::App_Name . "/api/v1/keylock?format=json", $data);
|
||||
$body = \json_decode($response->getBody(), true);
|
||||
|
Reference in New Issue
Block a user