Merge pull request #54767 from nextcloud/ensureStringsFilesVersions

[stable31] fix(files_versions): ensure IDs, Author and Label are strings
This commit is contained in:
Git'Fellow 2025-08-30 19:13:06 +02:00 committed by GitHub
commit d0de33fa8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View file

@ -50,11 +50,11 @@ export async function fetchVersions(fileInfo: any): Promise<Version[]> {
.filter(({ mime }) => mime !== '')
.map(version => formatVersion(version, fileInfo))
const authorIds = new Set(versions.map(version => version.author))
const authorIds = new Set(versions.map(version => String(version.author)))
const authors = await axios.post(generateUrl('/displaynames'), { users: [...authorIds] })
for (const version of versions) {
const author = authors.data.users[version.author]
const author = authors.data.users[version.author ?? '']
if (author) {
version.authorName = author
}
@ -105,8 +105,8 @@ function formatVersion(version: any, fileInfo: any): Version {
return {
fileId: fileInfo.id,
// If version-label is defined make sure it is a string (prevent issue if the label is a number an PHP returns a number then)
label: version.props['version-label'] && String(version.props['version-label']),
author: version.props['version-author'] ?? null,
label: version.props['version-label'] ? String(version.props['version-label']) : '',
author: version.props['version-author'] ? String(version.props['version-author']) : null,
authorName: null,
filename: version.filename,
basename: moment(mtime).format('LLL'),

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long