Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32170966
D15323.1765059042.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D15323.1765059042.diff
View Options
diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js
--- a/web/input/input-state-container.react.js
+++ b/web/input/input-state-container.react.js
@@ -18,6 +18,7 @@
import { queueReportsActionType } from 'lib/actions/report-actions.js';
import {
type BlobServiceUploadAction,
+ type FarcasterMediaUploadAction,
type DeleteUploadInput,
updateMultimediaMessageMediaActionType,
} from 'lib/actions/upload-actions.js';
@@ -33,6 +34,7 @@
import { useNewThickThread, useNewThinThread } from 'lib/hooks/thread-hooks.js';
import {
useBlobServiceUpload,
+ useFarcasterMediaUpload,
useDeleteUpload,
} from 'lib/hooks/upload-hooks.js';
import { getNextLocalUploadID } from 'lib/media/media-utils.js';
@@ -139,6 +141,7 @@
+dispatchActionPromise: DispatchActionPromise,
+calendarQuery: () => CalendarQuery,
+blobServiceUpload: BlobServiceUploadAction,
+ +farcasterMediaUpload: FarcasterMediaUploadAction,
+deleteUpload: (input: DeleteUploadInput) => Promise<void>,
+sendMultimediaMessage: (
messageInfo: RawMultimediaMessageInfo,
@@ -812,27 +815,33 @@
}
const { uri, file: fixedFile, mediaType, dimensions } = result;
- let encryptionResponse;
- const encryptionStart = Date.now();
- try {
- encryptionResponse = await encryptFile(fixedFile);
- } catch (e) {
- return {
- steps,
- result: {
- success: false,
- reason: 'encryption_exception',
- time: Date.now() - encryptionStart,
- exceptionMessage: getMessageForException(e),
- },
- };
- }
- const { result: encryptionResult, steps: encryptionSteps } =
- encryptionResponse;
- steps.push(...encryptionSteps);
+ const supportsEncryptedMultimedia =
+ threadSpecs[threadInfo.type].protocol().supportsEncryptedMultimedia;
- if (!encryptionResult.success) {
- return { steps, result: encryptionResult };
+ let encryptionResult;
+ if (supportsEncryptedMultimedia) {
+ let encryptionResponse;
+ const encryptionStart = Date.now();
+ try {
+ encryptionResponse = await encryptFile(fixedFile);
+ } catch (e) {
+ return {
+ steps,
+ result: {
+ success: false,
+ reason: 'encryption_exception',
+ time: Date.now() - encryptionStart,
+ exceptionMessage: getMessageForException(e),
+ },
+ };
+ }
+ const { steps: encryptionSteps } = encryptionResponse;
+ steps.push(...encryptionSteps);
+
+ encryptionResult = encryptionResponse.result;
+ if (!encryptionResult.success) {
+ return { steps, result: encryptionResult };
+ }
}
const { steps: thumbHashSteps, result: thumbHashResult } =
@@ -928,33 +937,50 @@
this.handleAbortCallback(threadID, localID, abort),
};
- const { mediaType, blobHash, dimensions, thumbHash } = upload;
- invariant(
- mediaType === 'encrypted_photo' || mediaType === 'encrypted_video',
- 'uploaded media should be encrypted',
- );
- invariant(
- encryptionKey && blobHash && dimensions,
- 'incomplete encrypted upload',
- );
+ const supportsEncryptedMultimedia =
+ threadSpecs[threadInfo.type].protocol().supportsEncryptedMultimedia;
- uploadResult = await this.props.blobServiceUpload({
- uploadInput: {
- blobInput: {
- type: 'file',
- file: upload.file,
+ if (supportsEncryptedMultimedia) {
+ const { mediaType, blobHash, dimensions, thumbHash } = upload;
+ invariant(
+ mediaType === 'encrypted_photo' || mediaType === 'encrypted_video',
+ 'uploaded media should be encrypted',
+ );
+ invariant(
+ encryptionKey && blobHash && dimensions,
+ 'incomplete encrypted upload',
+ );
+
+ uploadResult = await this.props.blobServiceUpload({
+ uploadInput: {
+ blobInput: {
+ type: 'file',
+ file: upload.file,
+ },
+ blobHash,
+ encryptionKey,
+ dimensions,
+ loop: false,
+ thumbHash,
},
- blobHash,
- encryptionKey,
- dimensions,
- loop: false,
- thumbHash,
- },
- keyserverOrThreadIDForMetadata: uploadMultimediaMetadataToKeyserver
- ? threadID
- : null,
- callbacks,
- });
+ keyserverOrThreadIDForMetadata: uploadMultimediaMetadataToKeyserver
+ ? threadID
+ : null,
+ callbacks,
+ });
+ } else {
+ const { mediaType, file, dimensions, thumbHash } = upload;
+ invariant(mediaType === 'photo', 'farcaster media cannot be encrypted');
+ uploadResult = await this.props.farcasterMediaUpload({
+ mediaInput: {
+ uploadInput: { type: 'file', file },
+ dimensions,
+ loop: false,
+ thumbHash,
+ },
+ callbacks,
+ });
+ }
} catch (e) {
uploadExceptionMessage = getMessageForException(e);
if (uploadExceptionMessage === 'invalid_csat') {
@@ -1683,6 +1709,7 @@
);
const calendarQuery = useSelector(nonThreadCalendarQuery);
const callBlobServiceUpload = useBlobServiceUpload();
+ const callFarcasterMediaUpload = useFarcasterMediaUpload();
const callDeleteUpload = useDeleteUpload();
const callSendMultimediaMessage =
useInputStateContainerSendMultimediaMessage();
@@ -1723,6 +1750,7 @@
pendingRealizedThreadIDs={pendingToRealizedThreadIDs}
calendarQuery={calendarQuery}
blobServiceUpload={callBlobServiceUpload}
+ farcasterMediaUpload={callFarcasterMediaUpload}
deleteUpload={callDeleteUpload}
sendMultimediaMessage={callSendMultimediaMessage}
sendTextMessage={callSendTextMessage}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 10:10 PM (20 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5841075
Default Alt Text
D15323.1765059042.diff (5 KB)
Attached To
Mode
D15323: [web] Support Farcaster media in input-state-container
Attached
Detach File
Event Timeline
Log In to Comment