From af001fc9affd89a24856d1669896f9a51ff1712a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 4 Mar 2024 16:19:43 +0100 Subject: [PATCH] fix(dav): remove sharing attributes from default dav fetch and change duplicate registration from `error` to `warn` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- __tests__/dav/davProperties.spec.ts | 20 ++++++++++---------- lib/dav/davProperties.ts | 5 +---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/__tests__/dav/davProperties.spec.ts b/__tests__/dav/davProperties.spec.ts index 5fedfdb6..e07fa593 100644 --- a/__tests__/dav/davProperties.spec.ts +++ b/__tests__/dav/davProperties.spec.ts @@ -19,6 +19,9 @@ describe('DAV Properties', () => { beforeEach(() => { delete window._nc_dav_properties delete window._nc_dav_namespaces + + logger.error = vi.fn() + logger.warn = vi.fn() }) test('getDavNameSpaces fall back to defaults', () => { @@ -51,54 +54,51 @@ describe('DAV Properties', () => { }) test('registerDavProperty registers successfully', () => { - logger.error = vi.fn() - expect(window._nc_dav_namespaces).toBeUndefined() expect(window._nc_dav_properties).toBeUndefined() expect(registerDavProperty('my:prop', { my: 'https://example.com/ns' })).toBe(true) + expect(logger.warn).not.toBeCalled() expect(logger.error).not.toBeCalled() expect(getDavProperties().includes('my:prop')).toBe(true) expect(getDavNameSpaces().includes('xmlns:my="https://example.com/ns"')).toBe(true) }) - test('registerDavProperty fails when registered multipletimes', () => { - logger.error = vi.fn() - + test('registerDavProperty fails when registered multiple times', () => { expect(window._nc_dav_namespaces).toBeUndefined() expect(window._nc_dav_properties).toBeUndefined() expect(registerDavProperty('my:prop', { my: 'https://example.com/ns' })).toBe(true) expect(registerDavProperty('my:prop')).toBe(false) - expect(logger.error).toBeCalled() + expect(logger.warn).toBeCalled() + expect(logger.error).not.toBeCalled() // but still included expect(getDavProperties().includes('my:prop')).toBe(true) expect(getDavNameSpaces().includes('xmlns:my="https://example.com/ns"')).toBe(true) }) test('registerDavProperty fails with invalid props', () => { - logger.error = vi.fn() - expect(window._nc_dav_namespaces).toBeUndefined() expect(window._nc_dav_properties).toBeUndefined() expect(registerDavProperty('my:prop:invalid', { my: 'https://example.com/ns' })).toBe(false) expect(logger.error).toBeCalled() + expect(logger.warn).not.toBeCalled() expect(getDavProperties().includes('my:prop')).toBe(false) expect(registerDavProperty('', { my: 'https://example.com/ns' })).toBe(false) expect(logger.error).toBeCalled() + expect(logger.warn).not.toBeCalled() expect(getDavProperties().includes('my:prop')).toBe(false) }) test('registerDavProperty fails with missing namespace', () => { - logger.error = vi.fn() - expect(window._nc_dav_namespaces).toBeUndefined() expect(window._nc_dav_properties).toBeUndefined() expect(registerDavProperty('my:prop', { other: 'https://example.com/ns' })).toBe(false) expect(logger.error).toBeCalled() + expect(logger.warn).not.toBeCalled() expect(getDavProperties().includes('my:prop')).toBe(false) }) }) diff --git a/lib/dav/davProperties.ts b/lib/dav/davProperties.ts index 7cfa55ed..e5a56ff2 100644 --- a/lib/dav/davProperties.ts +++ b/lib/dav/davProperties.ts @@ -35,16 +35,13 @@ export const defaultDavProperties = [ 'nc:has-preview', 'nc:is-encrypted', 'nc:mount-type', - 'nc:share-attributes', 'oc:comments-unread', 'oc:favorite', 'oc:fileid', 'oc:owner-display-name', 'oc:owner-id', 'oc:permissions', - 'oc:share-types', 'oc:size', - 'ocs:share-permissions', ] export const defaultDavNamespaces = { @@ -72,7 +69,7 @@ export const registerDavProperty = function(prop: string, namespace: DavProperty // Check duplicates if (window._nc_dav_properties.find((search) => search === prop)) { - logger.error(`${prop} already registered`, { prop }) + logger.warn(`${prop} already registered`, { prop }) return false }