Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(systemtags): Cast tag display name to string
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Nov 16, 2023
commit c2780796c0fb1f9cf2a8b535d689a4b5743a09cc
4 changes: 2 additions & 2 deletions apps/systemtags/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand All @@ -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>[]>
Expand Down
4 changes: 2 additions & 2 deletions apps/systemtags/src/services/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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'

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>[]>
Expand Down
2 changes: 1 addition & 1 deletion apps/systemtags/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
}

Expand Down