diff --git a/keyserver/src/updaters/upload-updaters.js b/keyserver/src/updaters/upload-updaters.js --- a/keyserver/src/updaters/upload-updaters.js +++ b/keyserver/src/updaters/upload-updaters.js @@ -38,4 +38,22 @@ await dbQuery(query); } -export { assignImages, assignMessageContainerToMedia }; +async function assignUserContainerToMedia( + viewer: Viewer, + mediaID: string, +): Promise { + const query = SQL` + UPDATE uploads + SET container = ${viewer.id} + WHERE id = ${mediaID} + AND uploader = ${viewer.id} + AND container IS NULL + `; + await dbQuery(query); +} + +export { + assignImages, + assignMessageContainerToMedia, + assignUserContainerToMedia, +};