2022-03-24 21:46:17 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
|
|
|
|
import { ContactSpoofingReviewDialog } from '../../components/conversation/ContactSpoofingReviewDialog';
|
|
|
|
|
|
|
|
import type { ConversationType } from '../ducks/conversations';
|
2022-12-21 03:25:10 +00:00
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
2022-03-24 21:46:17 +00:00
|
|
|
import type { GetConversationByIdType } from '../selectors/conversations';
|
|
|
|
import { getConversationSelector } from '../selectors/conversations';
|
|
|
|
import { ContactSpoofingType } from '../../util/contactSpoofing';
|
2022-12-21 03:25:10 +00:00
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
2022-03-24 21:46:17 +00:00
|
|
|
|
2022-12-21 03:25:10 +00:00
|
|
|
export type PropsType =
|
|
|
|
| {
|
|
|
|
conversationId: string;
|
|
|
|
onClose: () => void;
|
|
|
|
} & (
|
|
|
|
| {
|
|
|
|
type: ContactSpoofingType.DirectConversationWithSameTitle;
|
|
|
|
possiblyUnsafeConversation: ConversationType;
|
|
|
|
safeConversation: ConversationType;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: ContactSpoofingType.MultipleGroupMembersWithSameTitle;
|
|
|
|
groupConversationId: string;
|
|
|
|
collisionInfoByTitle: Record<
|
|
|
|
string,
|
|
|
|
Array<{
|
|
|
|
oldName?: string;
|
|
|
|
conversation: ConversationType;
|
|
|
|
}>
|
|
|
|
>;
|
|
|
|
}
|
|
|
|
);
|
2022-03-24 21:46:17 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function SmartContactSpoofingReviewDialog(
|
|
|
|
props: PropsType
|
|
|
|
): JSX.Element {
|
2022-03-24 21:46:17 +00:00
|
|
|
const { type } = props;
|
|
|
|
|
|
|
|
const getConversation = useSelector<StateType, GetConversationByIdType>(
|
|
|
|
getConversationSelector
|
|
|
|
);
|
|
|
|
|
2022-12-21 03:25:10 +00:00
|
|
|
const {
|
|
|
|
acceptConversation,
|
|
|
|
blockAndReportSpam,
|
|
|
|
blockConversation,
|
|
|
|
deleteConversation,
|
|
|
|
removeMember,
|
|
|
|
} = useConversationsActions();
|
|
|
|
const { showContactModal } = useGlobalModalActions();
|
|
|
|
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const theme = useSelector(getTheme);
|
|
|
|
|
|
|
|
const sharedProps = {
|
|
|
|
acceptConversation,
|
|
|
|
blockAndReportSpam,
|
|
|
|
blockConversation,
|
|
|
|
deleteConversation,
|
|
|
|
getPreferredBadge,
|
|
|
|
i18n,
|
|
|
|
removeMember,
|
|
|
|
showContactModal,
|
|
|
|
theme,
|
|
|
|
};
|
|
|
|
|
2022-03-24 21:46:17 +00:00
|
|
|
if (type === ContactSpoofingType.MultipleGroupMembersWithSameTitle) {
|
|
|
|
return (
|
|
|
|
<ContactSpoofingReviewDialog
|
|
|
|
{...props}
|
2022-12-21 03:25:10 +00:00
|
|
|
{...sharedProps}
|
2022-03-24 21:46:17 +00:00
|
|
|
group={getConversation(props.groupConversationId)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-21 03:25:10 +00:00
|
|
|
return <ContactSpoofingReviewDialog {...props} {...sharedProps} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|