diff --git a/browser/src/map/Map.js b/browser/src/map/Map.js index db4579da8bdaf..acef20ba6d0cc 100644 --- a/browser/src/map/Map.js +++ b/browser/src/map/Map.js @@ -280,7 +280,6 @@ L.Map = L.Evented.extend({ this.on('docloaded', function(e) { this._docLoaded = e.status; if (this._docLoaded) { - app.socket.sendMessage('blockingcommandstatus isRestrictedUser=' + this.Restriction.isRestrictedUser + ' isLockedUser=' + this.Locking.isLockedUser); app.idleHandler.notifyActive(); if (!document.hasFocus()) { this.fire('editorgotfocus'); diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index d752df7cc640e..38ea9fe986afb 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -1249,7 +1249,24 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/, #if ENABLE_FEATURE_LOCK sendLockedInfo(); #endif - return forwardToChild(oss.str(), docBroker); + +#if ENABLE_FEATURE_RESTRICTION + sendRestrictionInfo(); +#endif + + bool result = forwardToChild(oss.str(), docBroker); +#if ENABLE_FEATURE_LOCK || ENABLE_FEATURE_RESTRICTION + if (result) + { + forwardToChild( + std::string("blockingcommandstatus isRestrictedUser=") + + (CommandControl::RestrictionManager::isRestrictedUser() ? "true" : "false") + + std::string(" isLockedUser=") + + (CommandControl::LockManager::isLockedUser() ? "true" : "false"), + docBroker); + } +#endif + return result; } catch (const Poco::SyntaxException&) { @@ -1292,6 +1309,27 @@ void ClientSession::sendLockedInfo() } #endif +#if ENABLE_FEATURE_RESTRICTION +void ClientSession::sendRestrictionInfo() +{ + Poco::JSON::Object::Ptr restrictionInfo = new Poco::JSON::Object(); + restrictionInfo->set("IsRestrictedUser", + CommandControl::RestrictionManager::isRestrictedUser()); + + // Poco:Dynamic:Var does not support std::unordred_set so converted to std::vector + std::vector restrictedCommandList( + CommandControl::RestrictionManager::getRestrictedCommandList().begin(), + CommandControl::RestrictionManager::getRestrictedCommandList().end()); + restrictionInfo->set("RestrictedCommandList", restrictedCommandList); + + std::ostringstream ossRestrictionInfo; + restrictionInfo->stringify(ossRestrictionInfo); + const std::string restrictionInfoString = ossRestrictionInfo.str(); + LOG_TRC("Sending command restriction info to client: " << restrictionInfoString); + sendTextFrame("restrictedCommands: " + restrictionInfoString); +} +#endif + bool ClientSession::getCommandValues(const char *buffer, int length, const StringVector& tokens, const std::shared_ptr& docBroker) { diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp index e52a52c7e49b3..02a2eaaa1a569 100644 --- a/wsd/ClientSession.hpp +++ b/wsd/ClientSession.hpp @@ -262,6 +262,10 @@ class ClientSession final : public Session void sendLockedInfo(); #endif +#if ENABLE_FEATURE_RESTRICTION + void sendRestrictionInfo(); +#endif + /// Process an SVG to replace embedded file:/// media URIs with public http URLs. std::string processSVGContent(const std::string& svg); diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index c16abfbdc0697..4146e8377ca9f 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1002,22 +1002,6 @@ bool DocumentBroker::download(const std::shared_ptr& session, con } } -#if ENABLE_FEATURE_RESTRICTION - Object::Ptr restrictionInfo = new Object(); - restrictionInfo->set("IsRestrictedUser", CommandControl::RestrictionManager::isRestrictedUser()); - - // Poco:Dynamic:Var does not support std::unordred_set so converted to std::vector - std::vector restrictedCommandList(CommandControl::RestrictionManager::getRestrictedCommandList().begin(), - CommandControl::RestrictionManager::getRestrictedCommandList().end()); - restrictionInfo->set("RestrictedCommandList", restrictedCommandList); - - std::ostringstream ossRestrictionInfo; - restrictionInfo->stringify(ossRestrictionInfo); - const std::string restrictionInfoString = ossRestrictionInfo.str(); - LOG_TRC("Sending command restriction info to client: " << restrictionInfoString); - session->sendMessage("restrictedCommands: " + restrictionInfoString); -#endif - #if ENABLE_SUPPORT_KEY if (!COOLWSD::OverrideWatermark.empty()) watermarkText = COOLWSD::OverrideWatermark;