| 963 | 963 | const max = parseInt(request.body.max ?? Number.MAX_SAFE_INTEGER); |
| 964 | 964 | const recentChats = allChatFiles.sort((a, b) => b.mtime - a.mtime).slice(0, max); |
| 965 | 965 | const jsonFilesPromise = recentChats.map((file) => { |
| 966 | + const withMetadata = Boolean(request.body.metadata); |
| 966 | 967 | return file.groupId |
| 967 | 968 | ? getChatInfo(file.filePath, { group: file.groupId }, true, withMetadata) |
| 968 | 969 | : getChatInfo(file.filePath, { avatar: file.pngFile }, false, withMetadata); |
| 969 | 970 | }); |
| 970 | 971 | |
| 971 | 972 | const chatData = (await Promise.allSettled(jsonFilesPromise)).filter(x => x.status === 'fulfilled').map(x => x.value); |