OverviewFilesCommitsIssuesDocsReleasesPeers

keet-cli commits / db56911

Fix file.preview to generate real httpLinks via blob server
getLocalFiles() returns raw DB entries without httpLinks. Now file.preview uses core.files.getFileLink() to generate authenticated blob server URLs, fixing grey placeholder images in Godot chat. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
db5691163ac4373d4cdbd945f50b3608cfa4d836
by plankatron <fleeky@gmail.com> · 2026-02-17T18:47:52.000Z

Changed files (1) +27 -9

lib/router.js +27 -9
……@@ -771,21 +771,39 @@ export class Router {
771771 async _filePreview (params) {
772772 if (!params.roomId) throw new Error('Missing required param: roomId')
773773 if (!params.fileId) throw new Error('Missing required param: fileId')
774 // getFileEntry is broken — use getLocalFiles + search
774
775 // getLocalFiles returns raw DB entries (without httpLinks)
775776 const files = await this.backend.api.core.getLocalFiles(params.roomId)
776777 const entries = Array.isArray(files) ? files : (files?.data || files?.entries || [])
778
779 // Match file by blob ID — handle Buffer vs string comparison
780 const targetId = String(params.fileId)
777781 const entry = entries.find(f => {
778 const id = f.id || f.fileId || f.pointer?.externalBlob?.id
779 return id === params.fileId
782 const fileObj = f.file || f
783 const blobId = fileObj?.pointer?.externalBlob?.id
784 if (!blobId) return false
785 const idStr = Buffer.isBuffer(blobId) ? blobId.toString('hex') : String(blobId)
786 return idStr === targetId
780787 })
781788 if (!entry) throw new Error('File not found: ' + params.fileId)
789
790 // Generate httpLink using FileManager's blob server
791 const fileObj = entry.file || entry
792 let httpLink = ''
793 try {
794 httpLink = String(await this.core.files.getFileLink(entry.roomKey, fileObj) || '')
795 } catch (err) {
796 console.error('[keet-daemon] getFileLink error:', err.message)
797 }
798
799 const meta = fileObj?.metadata || {}
782800 return {
783 name: entry.fileName || entry.name || 'file',
784 type: entry.mimeType || entry.type || '',
785 size: entry.size || 0,
786 httpLink: entry.httpLink || '',
787 fullHttpLink: entry.httpLink || '',
788 dimensions: entry.dimensions || null
801 name: meta.name || 'file',
802 type: meta.mimetype || '',
803 size: meta.size || 0,
804 httpLink,
805 fullHttpLink: httpLink,
806 dimensions: meta.dimensions || null
789807 }
790808 }
791809