Page MenuHomePhabricator

D11990.diff
No OneTemporary

D11990.diff

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
@@ -146,7 +146,9 @@
};
}
-async function fetchImages(
+// This function technically fetches all kinds of unassigned media,
+// but it's only called by legacy clients that only support images
+async function fetchUnassignedImages(
viewer: Viewer,
mediaIDs: $ReadOnlyArray<string>,
): Promise<$ReadOnlyArray<Media>> {
@@ -154,7 +156,10 @@
SELECT id AS uploadID, secret AS uploadSecret,
type AS uploadType, extra AS uploadExtra
FROM uploads
- WHERE id IN (${mediaIDs}) AND uploader = ${viewer.id} AND container IS NULL
+ WHERE id IN (${mediaIDs})
+ AND uploader = ${viewer.id}
+ AND container IS NULL
+ AND user_container IS NULL
`;
const [result] = await dbQuery(query);
return result.map(imagesFromRow);
@@ -279,7 +284,7 @@
return { media };
}
-async function fetchUploadsForMessage(
+async function fetchUnassignedUploadsForMessage(
viewer: Viewer,
mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent>,
): Promise<$ReadOnlyArray<Object>> {
@@ -289,18 +294,24 @@
SELECT id AS uploadID, secret AS uploadSecret,
type AS uploadType, extra AS uploadExtra
FROM uploads
- WHERE id IN (${uploadIDs}) AND uploader = ${viewer.id} AND container IS NULL
+ WHERE id IN (${uploadIDs})
+ AND uploader = ${viewer.id}
+ AND container IS NULL
+ AND user_container IS NULL
`;
const [uploads] = await dbQuery(query);
return uploads;
}
-async function fetchMediaFromMediaMessageContent(
+async function fetchUnassignedMediaFromMediaMessageContent(
viewer: Viewer,
mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent>,
): Promise<$ReadOnlyArray<Media>> {
- const uploads = await fetchUploadsForMessage(viewer, mediaMessageContents);
+ const uploads = await fetchUnassignedUploadsForMessage(
+ viewer,
+ mediaMessageContents,
+ );
return constructMediaFromMediaMessageContentsAndUploadRows(
mediaMessageContents,
@@ -401,8 +412,8 @@
getUploadURL,
makeUploadURI,
imagesFromRow,
- fetchImages,
+ fetchUnassignedImages,
fetchMediaForThread,
- fetchMediaFromMediaMessageContent,
+ fetchUnassignedMediaFromMediaMessageContent,
constructMediaFromMediaMessageContentsAndUploadRows,
};
diff --git a/keyserver/src/responders/message-responders.js b/keyserver/src/responders/message-responders.js
--- a/keyserver/src/responders/message-responders.js
+++ b/keyserver/src/responders/message-responders.js
@@ -51,8 +51,8 @@
import { fetchServerThreadInfos } from '../fetchers/thread-fetchers.js';
import { checkThreadPermission } from '../fetchers/thread-permission-fetchers.js';
import {
- fetchImages,
- fetchMediaFromMediaMessageContent,
+ fetchUnassignedImages,
+ fetchUnassignedMediaFromMediaMessageContent,
} from '../fetchers/upload-fetchers.js';
import { fetchKnownUserInfos } from '../fetchers/user-fetchers.js';
import type { Viewer } from '../session/viewer.js';
@@ -178,8 +178,11 @@
localID,
);
const mediaPromise: Promise<$ReadOnlyArray<Media>> = request.mediaIDs
- ? fetchImages(viewer, request.mediaIDs)
- : fetchMediaFromMediaMessageContent(viewer, request.mediaMessageContents);
+ ? fetchUnassignedImages(viewer, request.mediaIDs)
+ : fetchUnassignedMediaFromMediaMessageContent(
+ viewer,
+ request.mediaMessageContents,
+ );
const [existingMessageInfo, media] = await Promise.all([
existingMessageInfoPromise,

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 2:20 AM (5 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2559376
Default Alt Text
D11990.diff (3 KB)

Event Timeline