Skip to content

Commit

Permalink
move the shared config to before the docbroker is created
Browse files Browse the repository at this point in the history
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ic39fa7f6f40e2eddb14e38fa255905e2f73131b0
  • Loading branch information
caolanm committed Nov 22, 2024
1 parent 31c6458 commit 48acd09
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
11 changes: 0 additions & 11 deletions wsd/DocumentBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,6 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr<ClientSession>&
}

const std::string userSettingsUri = wopiFileInfo->getUserSettingsUri();
const std::string sharedSettingsUri = wopiFileInfo->getSharedSettingsUri();

// Pass the ownership to the client session.
session->setWopiFileInfo(wopiFileInfo);
Expand All @@ -1454,16 +1453,6 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr<ClientSession>&
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;
}

Expand Down
34 changes: 31 additions & 3 deletions wsd/RequestVettingStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Poco::JSON::Object::Ptr>())
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.
Expand Down Expand Up @@ -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 ||
Expand Down
5 changes: 2 additions & 3 deletions wsd/RequestVettingStation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ class RequestVettingStation final : public std::enable_shared_from_this<RequestV
void createClientSession(const std::string& docKey, const std::string& url,
const Poco::URI& uriPublic, const bool isReadOnly);

void createWopiDocBroker(const std::string& docKey, const std::string& configId,
const std::string& url, const Poco::URI& uriPublic,
bool isReadOnly);
void createWopiDocBroker(const std::string& docKey, const std::string& url,
const Poco::URI& uriPublic, bool isReadOnly);

/// Send unauthorized error to the client and disconnect the socket.
/// Includes SSL verification status, if available, as the error code.
Expand Down
16 changes: 1 addition & 15 deletions wsd/wopi/WopiStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,8 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo& fileInfo, Poco::JSON::Ob
JsonUtil::findJSONValue(object, "UserExtraInfo", _userExtraInfo);
JsonUtil::findJSONValue(object, "UserPrivateInfo", _userPrivateInfo);
if (auto settingsJSON = object->get("SettingsJSON").extract<Poco::JSON::Object::Ptr>())
{
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);
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions wsd/wopi/WopiStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 48acd09

Please sign in to comment.