@@ -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
@@ -31,7 +33,7 @@ export interface Version {
3133 hasPreview : boolean , // Whether the version has a preview
3234 previewUrl : string , // Preview URL of the version
3335 url : string , // Download URL of the version
34- source : string , // The WebDAV endpoint of the ressource
36+ source : string , // The WebDAV endpoint of the resource
3537 fileVersion : string | null , // The version id, null for the current version
3638}
3739
@@ -44,10 +46,21 @@ export async function fetchVersions(fileInfo: any): Promise<Version[]> {
4446 details : true ,
4547 } ) as ResponseDataDetailed < FileStat [ ] >
4648
47- return response . data
49+ const versions = response . data
4850 // Filter out root
4951 . filter ( ( { mime } ) => mime !== '' )
5052 . map ( version => formatVersion ( version , fileInfo ) )
53+
54+ const authors = await axios . post ( generateUrl ( '/displaynames' ) , { users : [ ...versions . map ( version => version . author ) ] } )
55+
56+ versions . forEach ( version => {
57+ const author = authors . data . users [ version . author ]
58+ if ( author ) {
59+ version . authorName = author
60+ }
61+ } )
62+
63+ return versions
5164 } catch ( exception ) {
5265 logger . error ( 'Could not fetch version' , { exception } )
5366 throw exception
@@ -94,6 +107,7 @@ function formatVersion(version: any, fileInfo: any): Version {
94107 // 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)
95108 label : version . props [ 'version-label' ] && String ( version . props [ 'version-label' ] ) ,
96109 author : version . props [ 'version-author' ] ?? null ,
110+ authorName : null ,
97111 filename : version . filename ,
98112 basename : moment ( mtime ) . format ( 'LLL' ) ,
99113 mime : version . mime ,
0 commit comments