Page MenuHomePhabricator

D7335.diff
No OneTemporary

D7335.diff

diff --git a/lib/facts/comm-staff-community.js b/lib/facts/comm-staff-community.js
new file mode 100644
--- /dev/null
+++ b/lib/facts/comm-staff-community.js
@@ -0,0 +1,11 @@
+// @flow
+
+type CommStaffCommunity = {
+ +id: string,
+};
+
+const commStaffCommunity: CommStaffCommunity = {
+ id: '311733',
+};
+
+export default commStaffCommunity;
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -1561,6 +1561,13 @@
});
}
+function threadInfoInsideCommunity(
+ threadInfo: RawThreadInfo | ThreadInfo,
+ communityID: string,
+): boolean {
+ return threadInfo.community === communityID || threadInfo.id === communityID;
+}
+
export {
threadHasPermission,
viewerIsMember,
@@ -1627,4 +1634,5 @@
validChatNameRegex,
chatNameMaxLength,
patchThreadInfoToIncludeMentionedMembersOfParent,
+ threadInfoInsideCommunity,
};
diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js
--- a/native/input/input-state-container.react.js
+++ b/native/input/input-state-container.react.js
@@ -22,6 +22,7 @@
type MultimediaUploadCallbacks,
type MultimediaUploadExtras,
} from 'lib/actions/upload-actions.js';
+import commStaffCommunity from 'lib/facts/comm-staff-community.js';
import { pathFromURI, replaceExtension } from 'lib/media/file-utils.js';
import {
isLocalUploadID,
@@ -43,6 +44,7 @@
threadIsPending,
threadIsPendingSidebar,
patchThreadInfoToIncludeMentionedMembersOfParent,
+ threadInfoInsideCommunity,
} from 'lib/shared/thread-utils.js';
import type { CalendarQuery } from 'lib/types/entry-types.js';
import type {
@@ -160,8 +162,6 @@
replyCallbacks: Array<(message: string) => void> = [];
pendingThreadCreations = new Map<string, Promise<string>>();
pendingThreadUpdateHandlers = new Map<string, (ThreadInfo) => mixed>();
- // 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
@@ -558,6 +558,10 @@
}
}
+ shouldEncryptMedia(threadInfo: ThreadInfo): boolean {
+ return threadInfoInsideCommunity(threadInfo, commStaffCommunity.id);
+ }
+
sendMultimediaMessage = async (
selections: $ReadOnlyArray<NativeMediaSelection>,
threadInfo: ThreadInfo,
@@ -644,7 +648,7 @@
creatorID,
media,
},
- { forceMultimediaMessageType: this.sendEncryptedMedia },
+ { forceMultimediaMessageType: this.shouldEncryptMedia(threadInfo) },
);
this.props.dispatch({
type: createLocalMessageActionType,
@@ -653,16 +657,17 @@
},
);
- await this.uploadFiles(localMessageID, uploadFileInputs);
+ await this.uploadFiles(localMessageID, uploadFileInputs, threadInfo);
};
async uploadFiles(
localMessageID: string,
uploadFileInputs: $ReadOnlyArray<UploadFileInput>,
+ threadInfo: ThreadInfo,
) {
const results = await Promise.all(
uploadFileInputs.map(uploadFileInput =>
- this.uploadFile(localMessageID, uploadFileInput),
+ this.uploadFile(localMessageID, uploadFileInput, threadInfo),
),
);
const errors = [...new Set(results.filter(Boolean))];
@@ -674,6 +679,7 @@
async uploadFile(
localMessageID: string,
uploadFileInput: UploadFileInput,
+ threadInfo: ThreadInfo,
): Promise<?string> {
const { ids, selection } = uploadFileInput;
const { localMediaID } = ids;
@@ -739,7 +745,7 @@
}
let encryptionSteps = [];
- if (this.sendEncryptedMedia) {
+ if (this.shouldEncryptMedia(threadInfo)) {
const encryptionStart = Date.now();
try {
const { result: encryptionResult, ...encryptionReturn } =
@@ -1428,7 +1434,7 @@
};
});
- await this.uploadFiles(localMessageID, uploadFileInputs);
+ await this.uploadFiles(localMessageID, uploadFileInputs, threadInfo);
};
retryMessage = async (

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 2, 11:55 PM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609349
Default Alt Text
D7335.diff (4 KB)

Event Timeline