import { formatTag, parseIdFromLocation, parseTags } from '../utils'
import { logger } from '../logger.js'
-export const fetchTagsBody = `<?xml version="1.0"?>
+export const fetchTagsPayload = `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:prop>
<oc:id />
const path = '/systemtags'
try {
const { data: tags } = await davClient.getDirectoryContents(path, {
- data: fetchTagsBody,
+ data: fetchTagsPayload,
details: true,
glob: '/systemtags/*', // Filter out first empty tag
}) as ResponseDataDetailed<Required<FileStat>[]>
import type { ServerTagWithId, Tag, TagWithId } from '../types.js'
import { davClient } from './davClient.js'
-import { createTag, fetchTagsBody } from './api.js'
+import { createTag, fetchTagsPayload } from './api.js'
import { formatTag, parseTags } from '../utils.js'
import { logger } from '../logger.js'
const path = '/systemtags-relations/files/' + fileId
try {
const { data: tags } = await davClient.getDirectoryContents(path, {
- data: fetchTagsBody,
+ data: fetchTagsPayload,
details: true,
glob: '/systemtags-relations/files/*/*', // Filter out first empty tag
}) as ResponseDataDetailed<Required<FileStat>[]>
export const parseTags = (tags: { props: DAVResultResponseProps }[]): TagWithId[] => {
return tags.map(({ props }) => Object.fromEntries(
Object.entries(props)
- .map(([key, value]) => [camelCase(key), value]),
+ .map(([key, value]) => [camelCase(key), camelCase(key) === 'displayName' ? String(value) : value]),
)) as TagWithId[]
}