mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-02 18:44:25 -05:00
fix(collaboration): answer a wopi lock in a read-only session with 200 instead of locking
This commit is contained in:
1 parent
16a22a1506
commit
51cea608d5
2 files changed
+28
No files matched your search
@@ -222,6 +222,14 @@ func (f *FileConnector) Lock(ctx context.Context, lockID, oldLockID string) (*Co
|
||||
return NewResponse(400), nil
|
||||
}
|
||||
|
||||
// OnlyOffice locks on every open, a SetLock with a read-only token fails and the 500 becomes an error dialog
|
||||
// in OnlyOffice, so read-only and view-only sessions get their 200 without a lock
|
||||
if wopiContext.ViewMode == appproviderv1beta1.ViewMode_VIEW_MODE_READ_ONLY ||
|
||||
wopiContext.ViewMode == appproviderv1beta1.ViewMode_VIEW_MODE_VIEW_ONLY {
|
||||
logger.Debug().Msg("Lock: read-only session, skipping the lock")
|
||||
return NewResponseWithVersion(nil), nil
|
||||
}
|
||||
|
||||
var setOrRefreshStatus *rpcv1beta1.Status
|
||||
if oldLockID == "" {
|
||||
// If the oldLockID is empty, this is a "LOCK" request
|
||||
|
||||
@@ -171,6 +171,26 @@ var _ = Describe("FileConnector", func() {
|
||||
Expect(response.Headers).To(BeNil())
|
||||
})
|
||||
|
||||
It("Read-only session gets 200 without a lock", func() {
|
||||
gatewaySelector.EXPECT().Next().Unset()
|
||||
wopiCtx.ViewMode = appproviderv1beta1.ViewMode_VIEW_MODE_READ_ONLY
|
||||
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
|
||||
|
||||
response, err := fc.Lock(ctx, "abcdef123", "")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(response.Status).To(Equal(200))
|
||||
})
|
||||
|
||||
It("View-only session gets 200 without a lock", func() {
|
||||
gatewaySelector.EXPECT().Next().Unset()
|
||||
wopiCtx.ViewMode = appproviderv1beta1.ViewMode_VIEW_MODE_VIEW_ONLY
|
||||
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
|
||||
|
||||
response, err := fc.Lock(ctx, "abcdef123", "")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(response.Status).To(Equal(200))
|
||||
})
|
||||
|
||||
It("Set lock failed", func() {
|
||||
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
|
||||
|
||||
|
||||
Reference in new issue
Block a user