Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3734240
D7336.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D7336.diff
View Options
diff --git a/keyserver/src/fetchers/message-fetchers.js b/keyserver/src/fetchers/message-fetchers.js
--- a/keyserver/src/fetchers/message-fetchers.js
+++ b/keyserver/src/fetchers/message-fetchers.js
@@ -28,7 +28,7 @@
import {
constructMediaFromMediaMessageContentsAndUploadRows,
- mediaFromRow,
+ imagesFromRow,
} from './upload-fetchers.js';
import {
dbQuery,
@@ -246,7 +246,7 @@
rows,
);
} else {
- media = rows.filter(row => row.uploadID).map(mediaFromRow);
+ media = rows.filter(row => row.uploadID).map(imagesFromRow);
}
const [row] = rows;
const localID = localIDFromCreationString(viewer, row.creation);
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
@@ -3,7 +3,7 @@
import ip from 'internal-ip';
import _keyBy from 'lodash/fp/keyBy.js';
-import type { Media } from 'lib/types/media-types.js';
+import type { Media, Image, EncryptedImage } from 'lib/types/media-types.js';
import { messageTypes } from 'lib/types/message-types.js';
import type { MediaMessageServerDBContent } from 'lib/types/messages/media.js';
import { getUploadIDsFromMediaMessageServerDBContents } from 'lib/types/messages/media.js';
@@ -97,45 +97,31 @@
return `${baseDomain}${uploadPath}`;
}
-function mediaFromRow(row: Object): Media {
+function imagesFromRow(row: Object): Image | EncryptedImage {
const uploadExtra = JSON.parse(row.uploadExtra);
- const { width, height, loop } = uploadExtra;
+ const { width, height } = uploadExtra;
const { uploadType: type, uploadSecret: secret } = row;
const id = row.uploadID.toString();
const dimensions = { width, height };
const uri = getUploadURL(id, secret);
const isEncrypted = !!uploadExtra.encryptionKey;
- if (type === 'photo') {
- if (!isEncrypted) {
- return { id, type: 'photo', uri, dimensions };
- }
- return {
- id,
- type: 'encrypted_photo',
- holder: uri,
- dimensions,
- encryptionKey: uploadExtra.encryptionKey,
- };
+ if (type !== 'photo') {
+ throw new ServerError('invalid_parameters');
}
-
- let video;
if (!isEncrypted) {
- video = { id, type: 'video', uri, dimensions };
- } else {
- video = {
- id,
- type: 'encrypted_video',
- holder: uri,
- dimensions,
- encryptionKey: uploadExtra.encryptionKey,
- };
+ return { id, type: 'photo', uri, dimensions };
}
- // $FlowFixMe add thumbnailID, thumbnailURI once they're in DB
- return loop ? { ...video, loop } : video;
+ return {
+ id,
+ type: 'encrypted_photo',
+ holder: uri,
+ dimensions,
+ encryptionKey: uploadExtra.encryptionKey,
+ };
}
-async function fetchMedia(
+async function fetchImages(
viewer: Viewer,
mediaIDs: $ReadOnlyArray<string>,
): Promise<$ReadOnlyArray<Media>> {
@@ -146,7 +132,7 @@
WHERE id IN (${mediaIDs}) AND uploader = ${viewer.id} AND container IS NULL
`;
const [result] = await dbQuery(query);
- return result.map(mediaFromRow);
+ return result.map(imagesFromRow);
}
async function fetchMediaForThread(
@@ -363,8 +349,8 @@
fetchUploadChunk,
getUploadSize,
getUploadURL,
- mediaFromRow,
- fetchMedia,
+ imagesFromRow,
+ fetchImages,
fetchMediaForThread,
fetchMediaFromMediaMessageContent,
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
@@ -45,13 +45,13 @@
import { fetchServerThreadInfos } from '../fetchers/thread-fetchers.js';
import { checkThreadPermission } from '../fetchers/thread-permission-fetchers.js';
import {
- fetchMedia,
+ fetchImages,
fetchMediaFromMediaMessageContent,
} from '../fetchers/upload-fetchers.js';
import { fetchKnownUserInfos } from '../fetchers/user-fetchers.js';
import type { Viewer } from '../session/viewer.js';
import {
- assignMedia,
+ assignImages,
assignMessageContainerToMedia,
} from '../updaters/upload-updaters.js';
import { validateInput } from '../utils/validation-utils.js';
@@ -130,6 +130,7 @@
}
const sendMultimediaMessageRequestInputValidator = t.union([
+ // This option is only used for messageTypes.IMAGES
tShape({
threadID: t.String,
localID: t.String,
@@ -176,7 +177,7 @@
localID,
);
const mediaPromise: Promise<$ReadOnlyArray<Media>> = request.mediaIDs
- ? fetchMedia(viewer, request.mediaIDs)
+ ? fetchImages(viewer, request.mediaIDs)
: fetchMediaFromMediaMessageContent(viewer, request.mediaMessageContents);
const [existingMessageInfo, media] = await Promise.all([
@@ -210,7 +211,7 @@
);
if (request.mediaIDs) {
- await assignMedia(viewer, request.mediaIDs, id, threadID);
+ await assignImages(viewer, request.mediaIDs, id, threadID);
} else {
await assignMessageContainerToMedia(
viewer,
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
@@ -6,7 +6,7 @@
import { dbQuery, SQL } from '../database/database.js';
import type { Viewer } from '../session/viewer.js';
-async function assignMedia(
+async function assignImages(
viewer: Viewer,
mediaIDs: $ReadOnlyArray<string>,
containerID: string,
@@ -38,4 +38,4 @@
await dbQuery(query);
}
-export { assignMedia, assignMessageContainerToMedia };
+export { assignImages, assignMessageContainerToMedia };
diff --git a/lib/types/message-types.js b/lib/types/message-types.js
--- a/lib/types/message-types.js
+++ b/lib/types/message-types.js
@@ -542,6 +542,7 @@
+sidebarCreation?: boolean,
};
export type SendMultimediaMessageRequest =
+ // This option is only used for messageTypes.IMAGES
| {
+threadID: string,
+localID: string,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 3:29 AM (6 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2844286
Default Alt Text
D7336.diff (5 KB)
Attached To
Mode
D7336: [keyserver][lib] Get rid of unused code for handling videos in mediaFromRow
Attached
Detach File
Event Timeline
Log In to Comment