Delete cached discovery file if settings are changed
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
parent
aa89c908a7
commit
5dd6344629
@ -11,45 +11,38 @@
|
|||||||
|
|
||||||
namespace OCA\Richdocuments\Controller;
|
namespace OCA\Richdocuments\Controller;
|
||||||
|
|
||||||
|
use OCA\Richdocuments\WOPI\DiscoveryManager;
|
||||||
use \OCP\AppFramework\Controller;
|
use \OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\Files\IAppData;
|
||||||
use \OCP\IRequest;
|
use \OCP\IRequest;
|
||||||
use \OCP\IL10N;
|
use \OCP\IL10N;
|
||||||
|
|
||||||
use OCA\Richdocuments\AppConfig;
|
use OCA\Richdocuments\AppConfig;
|
||||||
use OCA\Richdocuments\Filter;
|
|
||||||
|
|
||||||
class SettingsController extends Controller{
|
class SettingsController extends Controller{
|
||||||
/** @var IL10N */
|
/** @var IL10N */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
/** @var AppConfig */
|
/** @var AppConfig */
|
||||||
private $appConfig;
|
private $appConfig;
|
||||||
|
/** @var DiscoveryManager */
|
||||||
|
private $discoveryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $appName
|
* @param string $appName
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param IL10N $l10n
|
* @param IL10N $l10n
|
||||||
* @param AppConfig $appConfig
|
* @param AppConfig $appConfig
|
||||||
* @param string $userId
|
* @param DiscoveryManager $discoveryManager
|
||||||
*/
|
*/
|
||||||
public function __construct($appName,
|
public function __construct($appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
AppConfig $appConfig,
|
AppConfig $appConfig,
|
||||||
$userId) {
|
DiscoveryManager $discoveryManager) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->appConfig = $appConfig;
|
$this->appConfig = $appConfig;
|
||||||
}
|
$this->discoveryManager = $discoveryManager;
|
||||||
|
|
||||||
/**
|
|
||||||
* @NoAdminRequired
|
|
||||||
*/
|
|
||||||
public function getSupportedMimes(){
|
|
||||||
return array(
|
|
||||||
'status' => 'success',
|
|
||||||
'mimes' => Filter::getAll()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +58,7 @@ class SettingsController extends Controller{
|
|||||||
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
||||||
|
|
||||||
$colon = strpos($wopi_url, ':', 0);
|
$colon = strpos($wopi_url, ':', 0);
|
||||||
if (\OC::$server->getRequest()->getServerProtocol() !== substr($wopi_url, 0, $colon)){
|
if ($this->request->getServerProtocol() !== substr($wopi_url, 0, $colon)){
|
||||||
$message = $this->l10n->t('Saved with error: Collabora Online should use the same protocol as the server installation.');
|
$message = $this->l10n->t('Saved with error: Collabora Online should use the same protocol as the server installation.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,13 +67,12 @@ class SettingsController extends Controller{
|
|||||||
$this->appConfig->setAppValue('doc_format', $doc_format);
|
$this->appConfig->setAppValue('doc_format', $doc_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
$richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
|
$this->discoveryManager->refretch();
|
||||||
$richMemCache->clear('discovery.xml');
|
|
||||||
|
|
||||||
$response = array(
|
$response = [
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'data' => array('message' => (string) $message)
|
'data' => array('message' => (string) $message)
|
||||||
);
|
];
|
||||||
|
|
||||||
return new JSONResponse($response);
|
return new JSONResponse($response);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ class DiscoveryManager {
|
|||||||
$this->appData = $appData->newFolder('richdocuments');
|
$this->appData = $appData->newFolder('richdocuments');
|
||||||
}
|
}
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->l10n = $l10n;
|
|
||||||
$this->timeFactory = $timeFactory;
|
$this->timeFactory = $timeFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +73,6 @@ class DiscoveryManager {
|
|||||||
return $decodedFile['data'];
|
return $decodedFile['data'];
|
||||||
}
|
}
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
$file = $this->appData->newFile('discovery.xml');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$remoteHost = $this->config->getAppValue('richdocuments', 'wopi_url');
|
$remoteHost = $this->config->getAppValue('richdocuments', 'wopi_url');
|
||||||
@ -96,4 +94,8 @@ class DiscoveryManager {
|
|||||||
);
|
);
|
||||||
return $responseBody;
|
return $responseBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function refretch() {
|
||||||
|
$this->appData->getFile('discovery.xml')->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user