diff --git a/keyserver/src/fetchers/upload-fetchers.js b/keyserver/src/fetchers/upload-fetchers.js --- a/keyserver/src/fetchers/upload-fetchers.js +++ b/keyserver/src/fetchers/upload-fetchers.js @@ -116,6 +116,20 @@ return result.map(mediaFromRow); } +async function fetchMediaForThread( + threadID: string, +): Promise<$ReadOnlyArray> { + const query = SQL` + SELECT id AS uploadID, secret AS uploadSecret, + type AS uploadType, extra AS uploadExtra + FROM uploads + WHERE thread = ${threadID} AND filename NOT LIKE 'thumb%' + ORDER BY creation_time DESC + `; + const [uploads] = await dbQuery(query); + return uploads.map(mediaFromRow); +} + async function fetchUploadsForMessage( viewer: Viewer, mediaMessageContents: $ReadOnlyArray, @@ -204,6 +218,7 @@ getUploadURL, mediaFromRow, fetchMedia, + fetchMediaForThread, fetchMediaFromMediaMessageContent, constructMediaFromMediaMessageContentsAndUploadRows, };