Page MenuHomePhabricator

D5087.diff
No OneTemporary

D5087.diff

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
@@ -1,5 +1,7 @@
// @flow
+import type { MediaMessageServerDBContent } from 'lib/types/messages/media.js';
+
import { dbQuery, SQL } from '../database/database';
import type { Viewer } from '../session/viewer';
@@ -16,4 +18,24 @@
await dbQuery(query);
}
-export { assignMedia };
+async function assignMessageContainerToMedia(
+ viewer: Viewer,
+ mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent>,
+ containerID: string,
+): Promise<void> {
+ const mediaIDs: string[] = [];
+ for (const mediaContent of mediaMessageContents) {
+ mediaIDs.push(mediaContent.uploadID);
+ if (mediaContent.type === 'video') {
+ mediaIDs.push(mediaContent.thumbnailUploadID);
+ }
+ }
+ const query = SQL`
+ UPDATE uploads
+ SET container = ${containerID}
+ WHERE id IN (${mediaIDs}) AND uploader = ${viewer.id} AND container IS NULL
+ `;
+ await dbQuery(query);
+}
+
+export { assignMedia, assignMessageContainerToMedia };

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 6:05 AM (18 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569342
Default Alt Text
D5087.diff (1 KB)

Event Timeline