fix(systemtags): Cast tag display name to string

Signed-off-by: Christopher Ng <chrng8@gmail.com>
pull/41335/head
Christopher Ng 7 months ago
parent 0983ce19b1
commit c2780796c0

@ -31,7 +31,7 @@ import { davClient } from './davClient.js'
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 />
@ -46,7 +46,7 @@ export const fetchTags = async (): Promise<TagWithId[]> => {
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>[]>

@ -24,7 +24,7 @@ import type { FileStat, ResponseDataDetailed } from 'webdav'
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'
@ -32,7 +32,7 @@ export const fetchTagsForFile = async (fileId: number): Promise<TagWithId[]> =>
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>[]>

@ -35,7 +35,7 @@ export const defaultBaseTag: BaseTag = {
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[]
}

Loading…
Cancel
Save