@@ -11,6 +11,7 @@ import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
1111import { getCurrentUser } from '@nextcloud/auth'
1212import { joinPaths , encodePath } from '@nextcloud/paths'
1313import moment from '@nextcloud/moment'
14+ import axios from '@nextcloud/axios'
1415
1516import client from '../utils/davClient.js'
1617import davRequest from '../utils/davRequest.js'
@@ -20,6 +21,7 @@ export interface Version {
2021 fileId : string , // The id of the file associated to the version.
2122 label : string , // 'Current version' or ''
2223 author : string | null , // UID for the author of the version
24+ authorName : string | null , // Display name of the author
2325 filename : string , // File name relative to the version DAV endpoint
2426 basename : string , // A base name generated from the mtime
2527 mime : string , // Empty for the current version, else the actual mime type of the version
@@ -30,7 +32,7 @@ export interface Version {
3032 permissions : string , // Only readable: 'R'
3133 previewUrl : string , // Preview URL of the version
3234 url : string , // Download URL of the version
33- source : string , // The WebDAV endpoint of the ressource
35+ source : string , // The WebDAV endpoint of the resource
3436 fileVersion : string | null , // The version id, null for the current version
3537}
3638
@@ -43,10 +45,22 @@ export async function fetchVersions(fileInfo: any): Promise<Version[]> {
4345 details : true ,
4446 } ) as ResponseDataDetailed < FileStat [ ] >
4547
46- return response . data
48+ const versions = response . data
4749 // Filter out root
4850 . filter ( ( { mime } ) => mime !== '' )
4951 . map ( version => formatVersion ( version , fileInfo ) )
52+
53+ const authorIds = new Set ( versions . map ( version => version . author ) )
54+ const authors = await axios . post ( generateUrl ( '/displaynames' ) , { users : [ ...authorIds ] } )
55+
56+ for ( const version of versions ) {
57+ const author = authors . data . users [ version . author ]
58+ if ( author ) {
59+ version . authorName = author
60+ }
61+ }
62+
63+ return versions
5064 } catch ( exception ) {
5165 logger . error ( 'Could not fetch version' , { exception } )
5266 throw exception
@@ -93,6 +107,7 @@ function formatVersion(version: any, fileInfo: any): Version {
93107 // 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)
94108 label : version . props [ 'version-label' ] && String ( version . props [ 'version-label' ] ) ,
95109 author : version . props [ 'version-author' ] ?? null ,
110+ authorName : null ,
96111 filename : version . filename ,
97112 basename : moment ( mtime ) . format ( 'LLL' ) ,
98113 mime : version . mime ,
0 commit comments