Skip to content

Commit 2cef21d

Browse files
authored
Fix opening an office document from a link (#3020)
When a directory is shared with a link in read+write mode, and an office document is opened from this link, the stack must use the edit mode of OnlyOffice. It was forced to view (read-only) before this commit for all documents opened from a sharing link.
1 parent 33001ed commit 2cef21d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

web/notes/notes.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ func OpenNoteURL(c echo.Context) error {
295295
if pdoc.Type == permission.TypeShareByLink || pdoc.Type == permission.TypeSharePreview {
296296
code := middlewares.GetRequestToken(c)
297297
open.AddShareByLinkCode(code)
298-
readOnly = true
299298
}
300299

301300
sharingID := c.QueryParam("SharingID") // Cozy to Cozy sharing

web/office/office.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/cozy/cozy-stack/model/permission"
1111
"github.com/cozy/cozy-stack/model/sharing"
1212
"github.com/cozy/cozy-stack/model/vfs"
13+
"github.com/cozy/cozy-stack/pkg/consts"
1314
"github.com/cozy/cozy-stack/pkg/jsonapi"
1415
"github.com/cozy/cozy-stack/web/middlewares"
1516
"github.com/labstack/echo/v4"
@@ -36,7 +37,14 @@ func Open(c echo.Context) error {
3637
if pdoc.Type == permission.TypeShareByLink || pdoc.Type == permission.TypeSharePreview {
3738
code := middlewares.GetRequestToken(c)
3839
open.AddShareByLinkCode(code)
39-
readOnly = true
40+
if !readOnly {
41+
readOnly = true
42+
for _, perm := range pdoc.Permissions {
43+
if perm.Type == consts.Files && !perm.Verbs.ReadOnly() {
44+
readOnly = false
45+
}
46+
}
47+
}
4048
}
4149

4250
sharingID := c.QueryParam("SharingID") // Cozy to Cozy sharing

0 commit comments

Comments
 (0)