]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(systemtags): Cast tag display name to string
authorChristopher Ng <chrng8@gmail.com>
Wed, 8 Nov 2023 02:20:49 +0000 (18:20 -0800)
committerChristopher Ng <chrng8@gmail.com>
Thu, 16 Nov 2023 01:13:14 +0000 (17:13 -0800)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/systemtags/src/services/api.ts
apps/systemtags/src/services/files.ts
apps/systemtags/src/utils.ts

index 0e3b7e09c6e40a949e79889f72e517edda039fb4..4872036fa9235954ce3d0f39f1ad3d10c99fdd95 100644 (file)
@@ -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>[]>
index 7dbd04c53509e8c3de3aff5ef981ba3bc3405027..35a087d04d160c7ad9588104d973b51134dcab22 100644 (file)
@@ -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>[]>
index c72c5975f03f8966afcaf88514a330a7f4b4e972..602594199aaa2a7642865a1de09a47924b12ae61 100644 (file)
@@ -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[]
 }