From 7cacd11e61ac342b7ff9c2c828b6fc8264e950e1 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 30 Apr 2024 13:32:43 -0300 Subject: [PATCH 1/2] chore: Revert encrypted file description (#5668) --- .../components/RecordAudio/RecordAudio.tsx | 17 ++++----- app/containers/message/Attachments.tsx | 4 +-- app/containers/message/index.tsx | 3 +- app/definitions/IUpload.ts | 6 +--- app/lib/encryption/encryption.ts | 26 +++----------- app/lib/encryption/room.ts | 36 +------------------ app/lib/methods/sendFileMessage.ts | 20 +---------- .../RoomSettings/SwitchItemEncrypted.test.tsx | 6 ++-- app/views/ShareView/index.tsx | 4 +-- 9 files changed, 21 insertions(+), 101 deletions(-) diff --git a/app/containers/MessageComposer/components/RecordAudio/RecordAudio.tsx b/app/containers/MessageComposer/components/RecordAudio/RecordAudio.tsx index f93a3208d..0ec27650e 100644 --- a/app/containers/MessageComposer/components/RecordAudio/RecordAudio.tsx +++ b/app/containers/MessageComposer/components/RecordAudio/RecordAudio.tsx @@ -95,21 +95,16 @@ export const RecordAudio = (): ReactElement | null => { try { if (!rid) return; setRecordingAudio(false); - const fileURI = recordingRef.current?.getURI() as string; - const fileData = await getInfoAsync(fileURI); - - if (!fileData.exists) { - return; - } - - const fileInfo: IUpload = { - rid, + const fileURI = recordingRef.current?.getURI(); + const fileData = await getInfoAsync(fileURI as string); + const fileInfo = { name: `${Date.now()}${RECORDING_EXTENSION}`, + mime: 'audio/aac', type: 'audio/aac', store: 'Uploads', path: fileURI, - size: fileData.size - }; + size: fileData.exists ? fileData.size : null + } as IUpload; if (fileInfo) { if (permissionToUpload) { diff --git a/app/containers/message/Attachments.tsx b/app/containers/message/Attachments.tsx index d9cfcfa42..1e96dbaac 100644 --- a/app/containers/message/Attachments.tsx +++ b/app/containers/message/Attachments.tsx @@ -55,14 +55,14 @@ const AttachedActions = ({ attachment, getCustomEmoji }: { attachment: IAttachme const Attachments: React.FC = React.memo( ({ attachments, timeFormat, showAttachment, style, getCustomEmoji, isReply, author }: IMessageAttachments) => { - const { translateLanguage, isEncrypted } = useContext(MessageContext); + const { translateLanguage } = useContext(MessageContext); if (!attachments || attachments.length === 0) { return null; } const attachmentsElements = attachments.map((file: IAttachment, index: number) => { - const msg = isEncrypted ? '' : getMessageFromAttachment(file, translateLanguage); + const msg = getMessageFromAttachment(file, translateLanguage); if (file && file.image_url) { return ( {/* @ts-ignore*/} diff --git a/app/definitions/IUpload.ts b/app/definitions/IUpload.ts index 187e34881..a2935575b 100644 --- a/app/definitions/IUpload.ts +++ b/app/definitions/IUpload.ts @@ -1,10 +1,8 @@ import Model from '@nozbe/watermelondb/Model'; -import { E2EType, MessageType } from './IMessage'; - export interface IUpload { id?: string; - rid: string; + rid?: string; path: string; name?: string; tmid?: string; @@ -16,8 +14,6 @@ export interface IUpload { error?: boolean; subscription?: { id: string }; msg?: string; - t?: MessageType; - e2e?: E2EType; } export type TUploadModel = IUpload & Model; diff --git a/app/lib/encryption/encryption.ts b/app/lib/encryption/encryption.ts index 912465f46..05071d074 100644 --- a/app/lib/encryption/encryption.ts +++ b/app/lib/encryption/encryption.ts @@ -11,15 +11,7 @@ import log from '../methods/helpers/log'; import { store } from '../store/auxStore'; import { joinVectorData, randomPassword, splitVectorData, toString, utf8ToBuffer } from './utils'; import { EncryptionRoom } from './index'; -import { - IMessage, - ISubscription, - IUpload, - TMessageModel, - TSubscriptionModel, - TThreadMessageModel, - TThreadModel -} from '../../definitions'; +import { IMessage, ISubscription, TMessageModel, TSubscriptionModel, TThreadMessageModel, TThreadModel } from '../../definitions'; import { E2E_BANNER_TYPE, E2E_MESSAGE_TYPE, @@ -29,7 +21,6 @@ import { E2E_STATUS } from '../constants'; import { Services } from '../services'; -import { compareServerVersion } from '../methods/helpers'; class Encryption { ready: boolean; @@ -43,7 +34,6 @@ class Encryption { handshake: Function; decrypt: Function; encrypt: Function; - encryptUpload: Function; importRoomKey: Function; }; }; @@ -285,7 +275,7 @@ class Encryption { ]; toDecrypt = (await Promise.all( toDecrypt.map(async message => { - const { t, msg, tmsg, attachments } = message; + const { t, msg, tmsg } = message; let newMessage: TMessageModel = {} as TMessageModel; if (message.subscription) { const { id: rid } = message.subscription; @@ -294,8 +284,7 @@ class Encryption { t, rid, msg: msg as string, - tmsg, - attachments + tmsg }); } @@ -445,7 +434,7 @@ class Encryption { }; // Encrypt a message - encryptMessage = async (message: IMessage | IUpload) => { + encryptMessage = async (message: IMessage) => { const { rid } = message; const db = database.active; const subCollection = db.get('subscriptions'); @@ -467,11 +456,6 @@ class Encryption { } const roomE2E = await this.getRoomInstance(rid); - - const { version: serverVersion } = store.getState().server; - if ('path' in message && compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.8.0')) { - return roomE2E.encryptUpload(message); - } return roomE2E.encrypt(message); } catch { // Subscription not found @@ -483,7 +467,7 @@ class Encryption { }; // Decrypt a message - decryptMessage = async (message: Pick) => { + decryptMessage = async (message: Pick) => { const { t, e2e } = message; // Prevent create a new instance if this room was encrypted sometime ago diff --git a/app/lib/encryption/room.ts b/app/lib/encryption/room.ts index 55f90e349..090582a81 100644 --- a/app/lib/encryption/room.ts +++ b/app/lib/encryption/room.ts @@ -5,7 +5,7 @@ import ByteBuffer from 'bytebuffer'; import parse from 'url-parse'; import getSingleMessage from '../methods/getSingleMessage'; -import { IMessage, IUpload, IUser } from '../../definitions'; +import { IMessage, IUser } from '../../definitions'; import Deferred from './helpers/deferred'; import { debounce } from '../methods/helpers'; import database from '../database'; @@ -243,38 +243,8 @@ export default class EncryptionRoom { return message; }; - // Encrypt upload - encryptUpload = async (message: IUpload) => { - if (!this.ready) { - return message; - } - - try { - let description = ''; - - if (message.description) { - description = await this.encryptText(EJSON.stringify({ text: message.description })); - } - - return { - ...message, - t: E2E_MESSAGE_TYPE, - e2e: E2E_STATUS.PENDING, - description - }; - } catch { - // Do nothing - } - - return message; - }; - // Decrypt text decryptText = async (msg: string | ArrayBuffer) => { - if (!msg) { - return null; - } - msg = b64ToBuffer(msg.slice(12) as string); const [vector, cipherText] = splitVectorData(msg); @@ -305,10 +275,6 @@ export default class EncryptionRoom { tmsg = await this.decryptText(tmsg); } - if (message.attachments?.length) { - message.attachments[0].description = await this.decryptText(message.attachments[0].description as string); - } - const decryptedMessage: IMessage = { ...message, tmsg, diff --git a/app/lib/methods/sendFileMessage.ts b/app/lib/methods/sendFileMessage.ts index 0a9fd9d0c..8886f6064 100644 --- a/app/lib/methods/sendFileMessage.ts +++ b/app/lib/methods/sendFileMessage.ts @@ -4,16 +4,12 @@ import isEmpty from 'lodash/isEmpty'; import { FetchBlobResponse, StatefulPromise } from 'rn-fetch-blob'; import { Alert } from 'react-native'; -import { Encryption } from '../encryption'; import { IUpload, IUser, TUploadModel } from '../../definitions'; import i18n from '../../i18n'; import database from '../database'; import FileUpload from './helpers/fileUpload'; import { IFileUpload } from './helpers/fileUpload/interfaces'; import log from './helpers/log'; -import { E2E_MESSAGE_TYPE } from '../constants'; -import { store } from '../store/auxStore'; -import { compareServerVersion } from './helpers'; const uploadQueue: { [index: string]: StatefulPromise } = {}; @@ -89,8 +85,6 @@ export function sendFileMessage( } } - const encryptedFileInfo = await Encryption.encryptMessage(fileInfo); - const formData: IFileUpload[] = []; formData.push({ name: 'file', @@ -102,7 +96,7 @@ export function sendFileMessage( if (fileInfo.description) { formData.push({ name: 'description', - data: encryptedFileInfo.description + data: fileInfo.description }); } @@ -120,18 +114,6 @@ export function sendFileMessage( }); } - const { version: serverVersion } = store.getState().server; - if (encryptedFileInfo.t === E2E_MESSAGE_TYPE && compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.8.0')) { - formData.push({ - name: 't', - data: encryptedFileInfo.t - }); - formData.push({ - name: 'e2e', - data: encryptedFileInfo.e2e - }); - } - const headers = { ...RocketChatSettings.customHeaders, 'Content-Type': 'multipart/form-data', diff --git a/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx b/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx index 1f18b44a6..a5f536d5a 100644 --- a/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx +++ b/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx @@ -45,7 +45,7 @@ describe('SwitchItemEncrypted', () => { const component = screen.queryByTestId(testEncrypted.testSwitchID); expect(component).toBeTruthy(); }); - + it('should change value of switch', () => { render( { expect(onPressMock).toHaveReturnedWith({ value: !testEncrypted.encrypted }); } }); - + it('label when encrypted and isTeam are false and is a public channel', () => { render( { const component = screen.queryByTestId(testEncrypted.testLabelID); expect(component?.props.children).toBe(i18n.t('Channel_hint_encrypted_not_available')); }); - + it('label when encrypted and isTeam are true and is a private team', () => { testEncrypted.isTeam = true; testEncrypted.type = true; diff --git a/app/views/ShareView/index.tsx b/app/views/ShareView/index.tsx index 6212ddd02..c1df448aa 100644 --- a/app/views/ShareView/index.tsx +++ b/app/views/ShareView/index.tsx @@ -257,7 +257,6 @@ class ShareView extends Component { return sendFileMessage( room.rid, { - rid: room.rid, name, description, size, @@ -351,8 +350,7 @@ class ShareView extends Component { selectedMessages, onSendMessage: this.send, onRemoveQuoteMessage: this.onRemoveQuoteMessage - }} - > + }}> Date: Tue, 30 Apr 2024 13:53:10 -0300 Subject: [PATCH 2/2] chore: Bump version to 4.49.0 (#5673) --- android/app/build.gradle | 2 +- ios/RocketChatRN.xcodeproj/project.pbxproj | 4 ++-- ios/RocketChatRN/Info.plist | 2 +- ios/ShareRocketChatRN/Info.plist | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 5c9807252..cd6013525 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -147,7 +147,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode VERSIONCODE as Integer - versionName "4.48.0" + versionName "4.49.0" vectorDrawables.useSupportLibrary = true if (!isFoss) { manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] diff --git a/ios/RocketChatRN.xcodeproj/project.pbxproj b/ios/RocketChatRN.xcodeproj/project.pbxproj index e6ef83461..0a6214efa 100644 --- a/ios/RocketChatRN.xcodeproj/project.pbxproj +++ b/ios/RocketChatRN.xcodeproj/project.pbxproj @@ -2896,7 +2896,7 @@ INFOPLIST_FILE = NotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 4.48.0; + MARKETING_VERSION = 4.49.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG"; @@ -2936,7 +2936,7 @@ INFOPLIST_FILE = NotificationService/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 4.48.0; + MARKETING_VERSION = 4.49.0; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE"; PRODUCT_BUNDLE_IDENTIFIER = chat.rocket.reactnative.NotificationService; diff --git a/ios/RocketChatRN/Info.plist b/ios/RocketChatRN/Info.plist index 6a9f66567..e23b4bb69 100644 --- a/ios/RocketChatRN/Info.plist +++ b/ios/RocketChatRN/Info.plist @@ -26,7 +26,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 4.48.0 + 4.49.0 CFBundleSignature ???? CFBundleURLTypes diff --git a/ios/ShareRocketChatRN/Info.plist b/ios/ShareRocketChatRN/Info.plist index b84970bef..776ca2a07 100644 --- a/ios/ShareRocketChatRN/Info.plist +++ b/ios/ShareRocketChatRN/Info.plist @@ -26,7 +26,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 4.48.0 + 4.49.0 CFBundleVersion 1 KeychainGroup diff --git a/package.json b/package.json index 7182e4830..4780969c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rocket-chat-reactnative", - "version": "4.48.0", + "version": "4.49.0", "private": true, "scripts": { "start": "react-native start",