From 48acd094dc2833b1bb3fdde60105810de3e93aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 20 Nov 2024 21:03:38 +0000 Subject: [PATCH] move the shared config to before the docbroker is created MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Caolán McNamara Change-Id: Ic39fa7f6f40e2eddb14e38fa255905e2f73131b0 --- wsd/DocumentBroker.cpp | 11 ----------- wsd/RequestVettingStation.cpp | 34 +++++++++++++++++++++++++++++++--- wsd/RequestVettingStation.hpp | 5 ++--- wsd/wopi/WopiStorage.cpp | 16 +--------------- wsd/wopi/WopiStorage.hpp | 3 --- 5 files changed, 34 insertions(+), 35 deletions(-) diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 8c04aea024cf..9758e01d36b0 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1440,7 +1440,6 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr& } const std::string userSettingsUri = wopiFileInfo->getUserSettingsUri(); - const std::string sharedSettingsUri = wopiFileInfo->getSharedSettingsUri(); // Pass the ownership to the client session. session->setWopiFileInfo(wopiFileInfo); @@ -1454,16 +1453,6 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr& if (!userSettingsUri.empty()) asyncInstallPresets(userSettingsUri, wopiStorage->getJailPresetsPath()); - // TODO for testing, just put these into the same destination autotext as - // user autotext for now - if (!sharedSettingsUri.empty()) - { - // if this wopi server has some shared settings we want to have a subForKit for those settings - // TODO, this is just for testing - std::string presetsPath = Poco::Path(COOLWSD::ChildRoot, JailUtil::CHILDROOT_TMP_SHARED_PRESETS_PATH).toString(); - asyncInstallPresets(sharedSettingsUri, presetsPath); - } - return templateSource; } diff --git a/wsd/RequestVettingStation.cpp b/wsd/RequestVettingStation.cpp index 95c690aa06ab..df95eac0fe60 100644 --- a/wsd/RequestVettingStation.cpp +++ b/wsd/RequestVettingStation.cpp @@ -143,12 +143,40 @@ void RequestVettingStation::sendUnauthorizedErrorAndShutdown() } void RequestVettingStation::createWopiDocBroker(const std::string& docKey, - const std::string& configId, const std::string& url, const Poco::URI& uriPublic, bool isReadOnly) { - assert(_checkFileInfo && "_checkFileInfo must exist"); + assert(_checkFileInfo && _checkFileInfo->wopiInfo() && "wopiInfo must exist"); + + std::string configId; + + std::string sharedSettingsUri; + if (auto settingsJSON = _checkFileInfo->wopiInfo()->get("SettingsJSON").extract()) + JsonUtil::findJSONValue(settingsJSON, "SharedSettings", sharedSettingsUri); + if (!sharedSettingsUri.empty()) + { + // If this wopi server has some shared settings we want to ensure a subForKit for those + // settings. + // TODO, this is just for testing, create a new one each time and we don't actually make any + // real use of this yet + // In reality we could download the server config around here and consider the + // wopi info incomplete until that is available, at which point we kick off the docbroker + // in the knowledge that the subForKit is populated + configId = "testing-id"; + +#if 0 + // TODO for testing, just put these into the same destination autotext as + // user autotext for now + + // if this wopi server has some shared settings we want to have a subForKit for those settings + // TODO, this is just for testing + std::string presetsPath = Poco::Path(COOLWSD::ChildRoot, JailUtil::CHILDROOT_TMP_SHARED_PRESETS_PATH).toString(); + asyncInstallPresets(sharedSettingsUri, presetsPath); +#endif + + COOLWSD::spawnSubForKit(configId); + } std::string sslVerifyResult = _checkFileInfo->getSslVerifyMessage(); // We have a valid CheckFileInfo result; Create the DocBroker. @@ -265,7 +293,7 @@ void RequestVettingStation::handleRequest(const std::string& id, _checkFileInfo->state() == CheckFileInfo::State::Pass && _checkFileInfo->wopiInfo()) { - createWopiDocBroker(docKey, url, "testing-id", uriPublic, isReadOnly); + createWopiDocBroker(docKey, url, uriPublic, isReadOnly); } else if (_checkFileInfo == nullptr || _checkFileInfo->state() == CheckFileInfo::State::None || diff --git a/wsd/RequestVettingStation.hpp b/wsd/RequestVettingStation.hpp index e32e4c93dc94..fb60c8effb1d 100644 --- a/wsd/RequestVettingStation.hpp +++ b/wsd/RequestVettingStation.hpp @@ -82,9 +82,8 @@ class RequestVettingStation final : public std::enable_shared_from_thisget("SettingsJSON").extract()) - { - JsonUtil::findJSONValue(settingsJSON, "SharedSettings", _sharedSettingsUri); JsonUtil::findJSONValue(settingsJSON, "UserSettings", _userSettingsUri); - } + JsonUtil::findJSONValue(object, "WatermarkText", _watermarkText); JsonUtil::findJSONValue(object, "UserCanWrite", _userCanWrite); JsonUtil::findJSONValue(object, "PostMessageOrigin", _postMessageOrigin); @@ -355,18 +353,6 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo& fileInfo, Poco::JSON::Ob _watermarkText = overrideWatermarks; if (isTemplate(getFilename())) _disableExport = true; - - if (!_sharedSettingsUri.empty()) - { - // TODO for testing - // if this wopi server has some shared settings we want to have a subForKit for those settings - // TODO, this is just for testing, create a new one each time and we don't actually make any - // real use of this yet - // In reality we could download the server config around here and consider the - // wopi info incomplete until that is available, at which point we kick off the docbroker - // in the knowledge that the subForKit is populated - COOLWSD::spawnSubForKit("testing-id"); - } } StorageBase::LockUpdateResult WopiStorage::updateLockState(const Authorization& auth, diff --git a/wsd/wopi/WopiStorage.hpp b/wsd/wopi/WopiStorage.hpp index 1db32ce8a8b3..eba147529f2b 100644 --- a/wsd/wopi/WopiStorage.hpp +++ b/wsd/wopi/WopiStorage.hpp @@ -53,7 +53,6 @@ class WopiStorage : public StorageBase const std::string& getUserExtraInfo() const { return _userExtraInfo; } const std::string& getUserPrivateInfo() const { return _userPrivateInfo; } const std::string& getUserSettingsUri() const { return _userSettingsUri; } - const std::string& getSharedSettingsUri() const { return _sharedSettingsUri; } const std::string& getWatermarkText() const { return _watermarkText; } const std::string& getTemplateSaveAs() const { return _templateSaveAs; } const std::string& getTemplateSource() const { return _templateSource; } @@ -106,8 +105,6 @@ class WopiStorage : public StorageBase std::string _userPrivateInfo; /// Uri to get settings json for this user, for autotext location, etc. std::string _userSettingsUri; - /// Uri to get settings json for this wopi server, for autotext location, etc. - std::string _sharedSettingsUri; /// In case a watermark has to be rendered on each tile. std::string _watermarkText; /// In case we want to use this file as a template, it should be first re-saved under this name (using PutRelativeFile).