Skip to content

Commit 9baa711

Browse files
Jaume PujantellJaumePujantell
authored andcommitted
wopi: add UserCanOnlyComment option
If UserCanOnlyComment is set to true, the document is opened in comment only mode. In that case, UserCanWrite is superseded by UserCanOnlyComment. If UserCanOnlyComment is false, everything works as before. Signed-off-by: Jaume Pujantell <[email protected]> Change-Id: I3417aadc428e079bb1533e2432ea60a1e62d03fb
1 parent acb3b08 commit 9baa711

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

wsd/DocumentBroker.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,16 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr<ClientSession>&
13061306
// but this is more readily comprehensible and easier to reason about.
13071307
session->setWritePermission(wopiFileInfo->getUserCanWrite());
13081308

1309-
if (!wopiFileInfo->getUserCanWrite())
1309+
if (wopiFileInfo->getUserCanOnlyComment())
1310+
{
1311+
LOG_DBG("Setting session ["
1312+
<< sessionId << "] to readonly for UserCanOnlyComment=true and allowing comments");
1313+
session->setWritePermission(true);
1314+
session->setWritable(true);
1315+
session->setReadOnly(true);
1316+
session->setAllowChangeComments(true);
1317+
}
1318+
else if (!wopiFileInfo->getUserCanWrite())
13101319
{
13111320
// We can't write in the storage, so we can't even add comments.
13121321
LOG_DBG("Setting session [" << sessionId << "] to readonly for UserCanWrite=false");

wsd/wopi/WopiStorage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo& fileInfo, Poco::JSON::Ob
262262
JsonUtil::findJSONValue(object, "UserCanRename", _userCanRename);
263263
JsonUtil::findJSONValue(object, "BreadcrumbDocName", _breadcrumbDocName);
264264
JsonUtil::findJSONValue(object, "FileUrl", _fileUrl);
265+
JsonUtil::findJSONValue(object, "UserCanOnlyComment", _userCanOnlyComment);
265266

266267
// check if user is admin on the integrator side
267268
bool isAdminUser = false;

wsd/wopi/WopiStorage.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class WopiStorage : public StorageBase
8484
bool getSupportsRename() const { return _supportsRename; }
8585
bool getSupportsLocks() const { return _supportsLocks; }
8686
bool getUserCanRename() const { return _userCanRename; }
87+
bool getUserCanOnlyComment() const { return _userCanOnlyComment; }
8788

8889
const std::optional<bool> getIsAdminUser() const { return _isAdminUser; }
8990
const std::string& getIsAdminUserError() const { return _isAdminUserError; }
@@ -171,6 +172,8 @@ class WopiStorage : public StorageBase
171172
bool _userCanRename = false;
172173
/// If user is considered as admin on the integrator side
173174
std::optional<bool> _isAdminUser = std::nullopt;
175+
/// If user is limited to only writing/modifiyng comments
176+
bool _userCanOnlyComment = false;
174177

175178
/// error code if integration does not use isAdminUser field properly
176179
std::string _isAdminUserError;

0 commit comments

Comments
 (0)