Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32210357
D5087.1765130917.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D5087.1765130917.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
Sun, Dec 7, 6:08 PM (19 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5845340
Default Alt Text
D5087.1765130917.diff (1 KB)
Attached To
Mode
D5087: [keyserver] Introduce `assignMessageContainerToMedia(...)` in `upload-updaters`
Attached
Detach File
Event Timeline
Log In to Comment