Skip to content

Commit

Permalink
chore: Merge 4.56.0 into single-server (#6073)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored Dec 19, 2024
2 parents 5083a10 + a000522 commit 23d6648
Show file tree
Hide file tree
Showing 69 changed files with 1,092 additions and 557 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode VERSIONCODE as Integer
versionName "4.55.0"
versionName "4.56.0"
vectorDrawables.useSupportLibrary = true
if (!isFoss) {
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
Expand Down
11 changes: 10 additions & 1 deletion app/containers/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const styles = StyleSheet.create({
...sharedStyles.textMedium,
...sharedStyles.textAlignCenter
},
smallText: {
...sharedStyles.textBold,
fontSize: 12,
lineHeight: 18
},
disabled: {
opacity: 0.3
}
Expand Down Expand Up @@ -75,7 +80,11 @@ const Button: React.FC<IButtonProps> = ({
style
];

const textStyle = [styles.text, { color: isDisabled ? colors.buttonPrimaryDisabled : resolvedTextColor, fontSize }, styleText];
const textStyle = [
{ color: isDisabled ? colors.buttonPrimaryDisabled : resolvedTextColor, fontSize },
small ? styles.smallText : styles.text,
styleText
];

return (
<Touchable
Expand Down
1 change: 1 addition & 0 deletions app/containers/List/ListInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const styles = StyleSheet.create({
},
text: {
fontSize: 14,
lineHeight: 20,
...sharedStyles.textRegular
}
});
Expand Down
4 changes: 2 additions & 2 deletions app/containers/TextInput/FormTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const styles = StyleSheet.create({
paddingHorizontal: 16,
paddingVertical: 10,
borderWidth: 1,
borderRadius: 2
borderRadius: 4
},
inputIconLeft: {
paddingLeft: 45
Expand Down Expand Up @@ -117,7 +117,7 @@ export const FormTextInput = ({
(secureTextEntry || iconRight || showClearInput) && styles.inputIconRight,
{
backgroundColor: colors.surfaceRoom,
borderColor: colors.strokeLight,
borderColor: colors.strokeMedium,
color: colors.fontTitlesLabels
},
error?.error && {
Expand Down
52 changes: 36 additions & 16 deletions app/containers/TwoFactor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ import isEmpty from 'lodash/isEmpty';
import { sha256 } from 'js-sha256';
import Modal from 'react-native-modal';
import useDeepCompareEffect from 'use-deep-compare-effect';
import { connect } from 'react-redux';

import { FormTextInput } from '../TextInput';
import I18n from '../../i18n';
import EventEmitter from '../../lib/methods/helpers/events';
import { useTheme } from '../../theme';
import { themes } from '../../lib/constants';
import Button from '../Button';
import sharedStyles from '../../views/Styles';
import styles from './styles';
import { IApplicationState } from '../../definitions';
import { ICredentials } from '../../definitions';
import { Services } from '../../lib/services';
import { useAppSelector } from '../../lib/hooks';
import Toast from '../Toast';
import { showToast } from '../../lib/methods/helpers/showToast';
import log from '../../lib/methods/helpers/log';

export const TWO_FACTOR = 'TWO_FACTOR';

Expand All @@ -32,6 +34,7 @@ interface IMethods {
}

interface EventListenerMethod {
params?: ICredentials;
method?: keyof IMethods;
submit?: (param: string) => void;
cancel?: () => void;
Expand All @@ -55,15 +58,31 @@ const methods: IMethods = {
}
};

const TwoFactor = React.memo(({ isMasterDetail }: { isMasterDetail: boolean }) => {
const { theme } = useTheme();
const TwoFactor = React.memo(() => {
const { colors } = useTheme();
const { isMasterDetail } = useAppSelector(state => ({
isMasterDetail: state.app.isMasterDetail as boolean
}));
const [visible, setVisible] = useState(false);
const [data, setData] = useState<EventListenerMethod>({});
const [code, setCode] = useState<string>('');

const method = data.method ? methods[data.method] : null;
const isEmail = data.method === 'email';
const sendEmail = () => Services.sendEmailCode();
const params = data?.params;

const sendEmail = async () => {
try {
if (params?.user) {
const response = await Services.sendEmailCode(params?.user);
if (response.success) {
showToast(I18n.t('Two_Factor_Success_message'));
}
}
} catch (e) {
log(e)
}
};

useDeepCompareEffect(() => {
if (!isEmpty(data)) {
Expand Down Expand Up @@ -102,15 +121,15 @@ const TwoFactor = React.memo(({ isMasterDetail }: { isMasterDetail: boolean }) =
setData({});
};

const color = themes[theme].fontTitlesLabels;
const color = colors.fontTitlesLabels;
return (
<Modal avoidKeyboard useNativeDriver isVisible={visible} hideModalContentWhileAnimating>
<View style={styles.container} testID='two-factor'>
<View
style={[
styles.content,
isMasterDetail && [sharedStyles.modalFormSheet, styles.tablet],
{ backgroundColor: themes[theme].surfaceTint }
{ backgroundColor: colors.surfaceTint }
]}>
<Text style={[styles.title, { color }]}>{I18n.t(method?.title || 'Two_Factor_Authentication')}</Text>
{method?.text ? <Text style={[styles.subtitle, { color }]}>{I18n.t(method.text)}</Text> : null}
Expand All @@ -127,22 +146,23 @@ const TwoFactor = React.memo(({ isMasterDetail }: { isMasterDetail: boolean }) =
testID='two-factor-input'
/>
{isEmail ? (
<Text style={[styles.sendEmail, { color }]} onPress={sendEmail}>
{I18n.t('Resend_email')}
</Text>
<Button
small
title={I18n.t('Resend_email')}
style={[styles.button, { marginTop: 12 }]}
type='secondary'
onPress={sendEmail}
/>
) : null}
<View style={styles.buttonContainer}>
<Button title={I18n.t('Cancel')} type='secondary' style={styles.button} onPress={onCancel} />
<Button title={I18n.t('Verify')} type='primary' style={styles.button} onPress={onSubmit} testID='two-factor-send' />
</View>
</View>
<Toast />
</View>
</Modal>
);
});

const mapStateToProps = (state: IApplicationState) => ({
isMasterDetail: state.app.isMasterDetail
});

export default connect(mapStateToProps)(TwoFactor);
export default TwoFactor;
8 changes: 5 additions & 3 deletions app/containers/message/Urls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Clipboard from '@react-native-clipboard/clipboard';
import FastImage from 'react-native-fast-image';
import { dequal } from 'dequal';

import { useAppSelector } from '../../lib/hooks';
import Touchable from './Touchable';
import openLink from '../../lib/methods/helpers/openLink';
import sharedStyles from '../../views/Styles';
Expand Down Expand Up @@ -96,8 +97,8 @@ const UrlImage = ({ image, hasContent }: { image: string; hasContent: boolean })
overflow: 'hidden',
alignItems: 'center',
justifyContent: 'center',
...(imageDimensions.width <= 64 && { width: 64 }),
...(imageDimensions.height <= 64 && { height: 64 })
...imageDimensions.width <= 64 && { width: 64 },
...imageDimensions.height <= 64 && { height: 64 }
};
if (!hasContent) {
containerStyle = {
Expand Down Expand Up @@ -128,6 +129,7 @@ type TImageLoadedState = 'loading' | 'done' | 'error';
const Url = ({ url }: { url: IUrl }) => {
const { colors, theme } = useTheme();
const { baseUrl, user } = useContext(MessageContext);
const API_Embed = useAppSelector(state => state.settings.API_Embed);
const getImageUrl = () => {
const imageUrl = url.image || url.url;

Expand All @@ -146,7 +148,7 @@ const Url = ({ url }: { url: IUrl }) => {

const hasContent = !!(url.title || url.description);

if (!url || url?.ignoreParse) {
if (!url || url?.ignoreParse || !API_Embed) {
return null;
}

Expand Down
4 changes: 4 additions & 0 deletions app/definitions/IRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface IRequestTranscript {
subject: string;
}

export type TUserWaitingForE2EKeys = { userId: string; ts: Date };

export interface IRoom {
fname?: string;
_id: string;
Expand All @@ -34,6 +36,7 @@ export interface IRoom {
livechatData?: any;
tags?: string[];
e2eKeyId?: string;
usersWaitingForE2EKeys?: TUserWaitingForE2EKeys[];
avatarETag?: string;
latest?: string;
default?: boolean;
Expand Down Expand Up @@ -217,6 +220,7 @@ export interface IServerRoom extends IRocketChatRecord {
reactWhenReadOnly?: boolean;
joinCodeRequired?: boolean;
e2eKeyId?: string;
usersWaitingForE2EKeys?: TUserWaitingForE2EKeys[];
v?: {
_id?: string;
token?: string;
Expand Down
8 changes: 7 additions & 1 deletion app/definitions/ISubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Relation from '@nozbe/watermelondb/Relation';

import { ILastMessage, TMessageModel } from './IMessage';
import { IRocketChatRecord } from './IRocketChatRecord';
import { IOmnichannelSource, RoomID, RoomType } from './IRoom';
import { IOmnichannelSource, RoomID, RoomType, TUserWaitingForE2EKeys } from './IRoom';
import { IServedBy } from './IServedBy';
import { TThreadModel } from './IThread';
import { TThreadMessageModel } from './IThreadMessage';
Expand Down Expand Up @@ -35,6 +35,8 @@ export enum ERoomTypes {

type RelationModified<T extends Model> = { fetch(): Promise<T[]> } & Relation<T>;

type OldKey = { e2eKeyId: string; ts: Date; E2EKey: string };

export interface ISubscription {
_id: string;
id: string;
Expand Down Expand Up @@ -93,9 +95,11 @@ export interface ISubscription {
livechatData?: any;
tags?: string[];
E2EKey?: string;
oldRoomKeys?: OldKey[];
E2ESuggestedKey?: string | null;
encrypted?: boolean;
e2eKeyId?: string;
usersWaitingForE2EKeys?: TUserWaitingForE2EKeys[];
avatarETag?: string;
teamId?: string;
teamMain?: boolean;
Expand Down Expand Up @@ -153,7 +157,9 @@ export interface IServerSubscription extends IRocketChatRecord {
onHold?: boolean;
encrypted?: boolean;
E2EKey?: string;
oldRoomKeys?: OldKey[];
E2ESuggestedKey?: string | null;
usersWaitingForE2EKeys?: TUserWaitingForE2EKeys[];
unreadAlert?: 'default' | 'all' | 'mentions' | 'nothing';

fname?: unknown;
Expand Down
11 changes: 11 additions & 0 deletions app/definitions/rest/v1/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@ export type E2eEndpoints = {
'e2e.rejectSuggestedGroupKey': {
POST: (params: { rid: string }) => {};
};
'e2e.fetchUsersWaitingForGroupKey': {
GET: (params: { roomIds: string[] }) => {
usersWaitingForE2EKeys: any;
};
};
'e2e.provideUsersSuggestedGroupKeys': {
POST: (params: { usersSuggestedGroupKeys: any }) => void;
};
'e2e.setRoomKeyID': {
POST: (params: { rid: string; keyID: string }) => {};
};
'e2e.fetchMyKeys': {
GET: () => { public_key: string; private_key: string };
};
'e2e.resetRoomKey': {
POST: (params: { rid: string; e2eKey: string; e2eKeyId: string }) => void;
};
};
1 change: 1 addition & 0 deletions app/i18n/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@
"Translate": "ترجمة",
"Try_again": "حاول مجدداً",
"Two_Factor_Authentication": "المصادقة الثنائية",
"Two_Factor_Success_message": "تم إرسال رمز التحقق الثنائي العوامل! يرجى التحقق من بريدك الإلكتروني.",
"Type_message": "اكتب رسالة",
"UNARCHIVE": "إلغاء الأرشفة",
"unarchive": "إلغاء الأرشفة",
Expand Down
1 change: 1 addition & 0 deletions app/i18n/locales/bn-IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@
"Translate": "অনুবাদ করুন",
"Try_again": "আবার চেষ্টা করুন",
"Two_Factor_Authentication": "দুটি ধারণামূলক প্রমাণীকরণ",
"Two_Factor_Success_message": "দুই-স্তরের প্রমাণীকরণ কোড পাঠানো হয়েছে! অনুগ্রহ করে আপনার ইমেইল চেক করুন।",
"Type_message": "বার্তা লিখুন",
"Types": "ধরণ",
"UNARCHIVE": "আনআরকাইভ",
Expand Down
1 change: 1 addition & 0 deletions app/i18n/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@
"Troubleshooting": "Odstraňování problémů",
"Try_again": "Zkusit to znovu",
"Two_Factor_Authentication": "Dvoufaktorové ověřování",
"Two_Factor_Success_message": "Byl odeslán dvoufaktorový autentizační kód! Zkontrolujte svůj e-mail.",
"Type_message": "Zadejte zprávu",
"Types": "Typy",
"UNARCHIVE": "UNARCHIVOVAT",
Expand Down
1 change: 1 addition & 0 deletions app/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@
"Translate": "Übersetzen",
"Try_again": "Versuchen Sie es nochmal",
"Two_Factor_Authentication": "Zwei-Faktor-Authentifizierung",
"Two_Factor_Success_message": "Zwei-Faktor-Authentifizierungscode gesendet! Bitte überprüfen Sie Ihre E-Mail.",
"Type_message": "Nachricht schreiben",
"Types": "Typen",
"UNARCHIVE": "WIEDERHERSTELLEN",
Expand Down
12 changes: 11 additions & 1 deletion app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
"Dont_activate": "Don't activate now",
"Dont_Have_An_Account": "Don't you have an account?",
"Downloaded_file": "Downloaded file",
"E2E_Encryption": "E2E encryption",
"E2E_Encryption": "End-to-end encryption",
"E2E_encryption_change_password_confirmation": "Yes, change it",
"E2E_encryption_change_password_description": "You can now create encrypted private groups and direct messages. You may also change existing private groups or DMs to encrypted. \nThis is end to end encryption so the key to encode/decode your messages will not be saved on the workspace. For that reason you need to store your password somewhere safe. You will be required to enter it on other devices you wish to use e2e encryption on.",
"E2E_encryption_change_password_error": "Error while changing E2E key password!",
Expand Down Expand Up @@ -262,13 +262,17 @@
"Enable_writing_in_room": "Enable writing in room",
"Enabled": "Enabled",
"Enabled_E2E_Encryption_for_this_room": "enabled E2E encryption for this room",
"Encrypt__room_type__": "Encrypt {{room_type}}",
"Encrypt__room_type__info__room_name__": "Ensure only intended recipients can access messages and files in {{room_name}}.",
"Encrypted": "Encrypted",
"Encrypted_file": "Encrypted file",
"Encrypted_message": "Encrypted message",
"encrypted_room_description": "Enter your end-to-end encryption password to access.",
"encrypted_room_title": "{{room_name}} is encrypted",
"Encryption_error_desc": "It wasn't possible to decode your encryption key to be imported.",
"Encryption_error_title": "Your encryption password seems wrong",
"Encryption_keys_reset": "Encryption keys reset",
"Encryption_keys_reset_failed": "Encryption keys reset failed",
"End_to_end_encrypted_room": "End to end encrypted room",
"Enter_E2EE_Password": "Enter E2EE password",
"Enter_E2EE_Password_description": "To access your encrypted channels and direct messages, enter your encryption password. This is not stored on the server, so you’ll need to use it on every device.",
Expand Down Expand Up @@ -609,7 +613,12 @@
"Resend": "Resend",
"Resend_email": "Resend email",
"RESET": "RESET",
"Reset": "Reset",
"Reset_encryption_keys": "Reset encryption keys",
"Reset_encryption_keys_info__room_type__": "Resetting E2EE keys is only recommend if no {{room_type}} member has a valid key to regain access to the previously encrypted content.",
"Reset_password": "Reset password",
"Reset_room_key_message": "All members may lose access to previously encrypted content.",
"Reset_room_key_title": "Reset encryption key",
"resetting_password": "resetting password",
"Resume": "Resume",
"Return_to_waiting_line": "Return to waiting line",
Expand Down Expand Up @@ -760,6 +769,7 @@
"Troubleshooting": "Troubleshooting",
"Try_again": "Try again",
"Two_Factor_Authentication": "Two-factor authentication",
"Two_Factor_Success_message": "Two-factor authentication code sent! Please check your email.",
"Type_message": "Type message",
"Types": "Types",
"UNARCHIVE": "UNARCHIVE",
Expand Down
1 change: 1 addition & 0 deletions app/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"Translate": "Traducir",
"Try_again": "Intentar de nuevo",
"Two_Factor_Authentication": "Autenticación de doble factor",
"Two_Factor_Success_message": "¡Código de autenticación de dos factores enviado! Por favor, revisa tu correo electrónico.",
"Type_message": "Escribir mensaje",
"UNARCHIVE": "DESARCHIVAR",
"unarchive": "desarchivar",
Expand Down
1 change: 1 addition & 0 deletions app/i18n/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@
"Translate": "Käännä",
"Try_again": "Yritä uudelleen",
"Two_Factor_Authentication": "Kaksivaiheinen tunnistautuminen",
"Two_Factor_Success_message": "Kaksivaiheinen todennuskoodi lähetetty! Tarkista sähköpostisi.",
"Type_message": "Kirjoita viesti",
"Types": "Tyypit",
"UNARCHIVE": "PALAUTA ARKISTOSTA",
Expand Down
Loading

0 comments on commit 23d6648

Please sign in to comment.