Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3398124
D7434.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7434.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
@@ -32,6 +32,7 @@
useModalContext,
type PushModal,
} from 'lib/components/modal-provider.react.js';
+import commStaffCommunity from 'lib/facts/comm-staff-community.js';
import { getNextLocalUploadID } from 'lib/media/media-utils.js';
import { pendingToRealizedThreadIDsSelector } from 'lib/selectors/thread-selectors.js';
import {
@@ -46,6 +47,7 @@
threadIsPending,
threadIsPendingSidebar,
patchThreadInfoToIncludeMentionedMembersOfParent,
+ threadInfoInsideCommunity,
} from 'lib/shared/thread-utils.js';
import type { CalendarQuery } from 'lib/types/entry-types.js';
import type {
@@ -71,6 +73,7 @@
type ClientNewThreadRequest,
type NewThreadResult,
type ThreadInfo,
+ type RawThreadInfo,
threadTypes,
} from 'lib/types/thread-types.js';
import {
@@ -106,6 +109,7 @@
+drafts: { +[key: string]: string },
+viewerID: ?string,
+messageStoreMessages: { +[id: string]: RawMessageInfo },
+ +threadStoreThreadInfos: { +[id: string]: RawThreadInfo },
+pendingRealizedThreadIDs: $ReadOnlyMap<string, string>,
+dispatch: Dispatch,
+dispatchActionPromise: DispatchActionPromise,
@@ -163,8 +167,6 @@
};
replyCallbacks: Array<(message: string) => void> = [];
pendingThreadCreations = new Map<string, Promise<string>>();
- // TODO: we want to send encrypted media if thread is in the Comm community
- sendEncryptedMedia: boolean = false;
// When the user sends a multimedia message that triggers the creation of a
// sidebar, the sidebar gets created right away, but the message needs to wait
@@ -330,7 +332,7 @@
creatorID,
media,
},
- { forceMultimediaMessageType: this.sendEncryptedMedia },
+ { forceMultimediaMessageType: this.shouldEncryptMedia(threadID) },
);
newMessageInfos.set(messageID, messageInfo);
}
@@ -374,6 +376,14 @@
return rawMessageInfo;
}
+ shouldEncryptMedia(threadID: ?string): boolean {
+ if (!threadID) {
+ return false;
+ }
+ const threadInfo = this.props.threadStoreThreadInfos[threadID];
+ return threadInfoInsideCommunity(threadInfo, commStaffCommunity.id);
+ }
+
async sendMultimediaMessage(messageInfo: RawMultimediaMessageInfo) {
if (!threadIsPending(messageInfo.threadID)) {
this.props.dispatchActionPromise(
@@ -632,7 +642,7 @@
const { pushModal } = this.props;
const appendResults = await Promise.all(
- files.map(file => this.appendFile(file, selectionTime)),
+ files.map(file => this.appendFile(threadID, file, selectionTime)),
);
if (appendResults.some(({ result }) => !result.success)) {
@@ -682,6 +692,7 @@
}
async appendFile(
+ threadID: ?string,
file: File,
selectTime: number,
): Promise<{
@@ -723,7 +734,7 @@
const { uri, file: fixedFile, mediaType, dimensions } = result;
let encryptionResult;
- if (this.sendEncryptedMedia) {
+ if (this.shouldEncryptMedia(threadID)) {
let encryptionResponse;
const encryptionStart = Date.now();
try {
@@ -1502,6 +1513,9 @@
const messageStoreMessages = useSelector(
state => state.messageStore.messages,
);
+ const threadStoreThreadInfos = useSelector(
+ state => state.threadStore.threadInfos,
+ );
const pendingToRealizedThreadIDs = useSelector(state =>
pendingToRealizedThreadIDsSelector(state.threadStore.threadInfos),
);
@@ -1541,6 +1555,7 @@
drafts={drafts}
viewerID={viewerID}
messageStoreMessages={messageStoreMessages}
+ threadStoreThreadInfos={threadStoreThreadInfos}
pendingRealizedThreadIDs={pendingToRealizedThreadIDs}
calendarQuery={calendarQuery}
uploadMultimedia={callUploadMultimedia}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 9:09 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2608941
Default Alt Text
D7434.diff (3 KB)
Attached To
Mode
D7434: [web] Gate encrypted media uploads on Comm staff community
Attached
Detach File
Event Timeline
Log In to Comment