[wopi] Send warning on forced view mode; For bug 76155

This commit is contained in:
Sergey Konovalov
2025-08-19 16:00:29 +03:00
parent ce20e34048
commit 2a8bf6b238
3 changed files with 7 additions and 3 deletions

View File

@ -248,6 +248,7 @@ exports.VKEY_TIME_EXPIRE = -124;
exports.VKEY_TIME_INCORRECT = -125;
exports.EDITOR_CHANGES = -160;
exports.PASSWORD = -180;
exports.FORCED_VIEW_MODE = -200;
//Quorum queues internally only support two priorities: high and normal.
//Messages without a priority set will be mapped to normal as will priorities 0 - 4.

View File

@ -556,8 +556,8 @@ function sendData(ctx, conn, data) {
const type = data ? data.type : null;
ctx.logger.debug('sendData: type = %s', type);
}
function sendDataWarning(ctx, conn, msg) {
sendData(ctx, conn, {type: "warning", message: msg});
function sendDataWarning(ctx, conn, code, description) {
sendData(ctx, conn, {type: "warning", code: code, message: description});
}
function sendDataMessage(ctx, conn, msg) {
if (!conn.permissions || false !== conn.permissions.chat) {
@ -2351,6 +2351,7 @@ exports.install = function(server, callbackFunction) {
if (decoded.userAuth) {
data.documentCallbackUrl = JSON.stringify(decoded.userAuth);
data.mode = decoded.userAuth.mode;
data.forcedViewMode = decoded.userAuth.forcedViewMode;
}
if (decoded.queryParams) {
let queryParams = decoded.queryParams;
@ -2822,6 +2823,8 @@ exports.install = function(server, callbackFunction) {
}
return;
}
} else if (data.forcedViewMode) {
sendDataWarning(ctx, conn, constants.FORCED_VIEW_MODE, "Forced view mode");
}
//Set the unique ID
if (bIsRestore) {

View File

@ -578,7 +578,7 @@ async function prepareDocumentForEditing(ctx, wopiSrc, fileInfo, userAuth, fileT
if (!preOpenRes && userAuth.mode !== 'view') {
ctx.logger.error('prepareDocumentForEditing error: lock failed, fallback to view mode');
userAuth.mode = 'view';
params.forcedViewMode = true;
userAuth.forcedViewMode = true;
return await prepareDocumentForEditing(ctx, wopiSrc, fileInfo, userAuth, fileType, baseUrl, params);
}
}