Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3345450
D5087.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5087.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D5087: [keyserver] Introduce `assignMessageContainerToMedia(...)` in `upload-updaters`
Attached
Detach File
Event Timeline
Log In to Comment