diff --git a/ts/components/conversation/Timestamp.tsx b/ts/components/conversation/Timestamp.tsx index e277062f8..589593340 100644 --- a/ts/components/conversation/Timestamp.tsx +++ b/ts/components/conversation/Timestamp.tsx @@ -13,8 +13,6 @@ type Props = { isConversationListItem?: boolean; }; -const UPDATE_FREQUENCY = 60 * 1000; - const TimestampContainerListItem = styled.div` flex-shrink: 0; margin-inline-start: 6px; @@ -28,6 +26,8 @@ const TimestampContainerListItem = styled.div` color: var(--color-text); `; +const UPDATE_FREQUENCY = 60 * 1000; + const TimestampContainerNotListItem = styled.div` font-size: 11px; line-height: 16px; diff --git a/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx b/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx index bbbd100a3..065ae17c4 100644 --- a/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx +++ b/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx @@ -19,7 +19,7 @@ import { useIsPrivate, } from '../../../hooks/useParamSelector'; import { MemoConversationListItemContextMenu } from '../../menu/ConversationListItemContextMenu'; -import { HeaderItem } from './HeaderItem'; +import { ConversationListItemHeaderItem } from './HeaderItem'; import { MessageItem } from './MessageItem'; // tslint:disable-next-line: no-empty-interface @@ -127,7 +127,7 @@ const ConversationListItem = (props: Props) => { >
- +
diff --git a/ts/components/leftpane/conversation-list-item/HeaderItem.tsx b/ts/components/leftpane/conversation-list-item/HeaderItem.tsx index c8e69fc72..a50260e5b 100644 --- a/ts/components/leftpane/conversation-list-item/HeaderItem.tsx +++ b/ts/components/leftpane/conversation-list-item/HeaderItem.tsx @@ -73,7 +73,7 @@ const ListItemIcons = () => { ); }; -export const HeaderItem = () => { +export const ConversationListItemHeaderItem = () => { const conversationId = useContext(ContextConversationId); const convoProps = useHeaderItemProps(conversationId); diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 1be4dafac..739ca67c4 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -362,29 +362,28 @@ export async function isMessageDuplicate({ serverTimestamp, }: MessageId) { const { Errors } = window.Signal.Types; - // serverId is only used for opengroupv2 + // serverTimestamp is only used for opengroupv2 try { let result; if (serverTimestamp) { // first try to find a duplicate with the same serverTimestamp from this sender - if (serverTimestamp) { - result = await getMessageBySenderAndServerTimestamp({ - source, - serverTimestamp, - }); - } + + result = await getMessageBySenderAndServerTimestamp({ + source, + serverTimestamp, + }); + // if we have a result, it means a specific user sent two messages either with the same serverTimestamp. // no need to do anything else, those messages must be the same // Note: this test is not based on which conversation the user sent the message // but we consider that a user sending two messages with the same serverTimestamp is unlikely return Boolean(result); - } else { - result = await getMessageBySender({ - source, - sourceDevice, - sentAt: timestamp, - }); } + result = await getMessageBySender({ + source, + sourceDevice, + sentAt: timestamp, + }); if (!result) { return false; diff --git a/ts/receiver/hashDuplicateFilter.ts b/ts/receiver/hashDuplicateFilter.ts deleted file mode 100644 index b7680cc41..000000000 --- a/ts/receiver/hashDuplicateFilter.ts +++ /dev/null @@ -1,48 +0,0 @@ -import _ from 'lodash'; -import { SignalService } from '../protobuf'; -import { sha256 } from '../session/crypto'; - -const recentHashByConvo = new Map>(); - -const maxHashToKeepPerConvo = 10; - -export function isDuplicateBasedOnHash( - dataMessage: SignalService.DataMessage, - conversationId: string, - sender: string -): boolean { - const toUseForHash = { - ..._.omit( - SignalService.DataMessage.toObject(dataMessage), - 'timestamp', - 'profile', - 'preview', - 'profileKey' - ), - conversationId, - sender, - }; - - if (!recentHashByConvo.has(conversationId)) { - recentHashByConvo.set(conversationId, new Array()); - } - const newHash = sha256(JSON.stringify(toUseForHash)); - - // this can only be set based on the .set above() - let recentHashForConvo = recentHashByConvo.get(conversationId) as Array; - - // this hash already exists for this convo - if (recentHashForConvo.some(n => n === newHash)) { - return true; - } - // push the new hash at the end - recentHashForConvo.push(newHash); - if (recentHashForConvo.length > maxHashToKeepPerConvo) { - // slice the last maxHashToKeepPerConvo hashes - recentHashForConvo = recentHashForConvo?.slice(-maxHashToKeepPerConvo); - } - recentHashByConvo.set(conversationId, recentHashForConvo); - return false; -} - -// build a hash of the data and check against recent messages diff --git a/ts/receiver/receiver.ts b/ts/receiver/receiver.ts index abb9c2f93..0e2212ce1 100644 --- a/ts/receiver/receiver.ts +++ b/ts/receiver/receiver.ts @@ -26,7 +26,6 @@ import { OpenGroupRequestCommonType } from '../session/apis/open_group_api/openg import { handleMessageJob } from './queuedJob'; import { fromBase64ToArray } from '../session/utils/String'; import { removeMessagePadding } from '../session/crypto/BufferPadding'; -import { isDuplicateBasedOnHash } from './hashDuplicateFilter'; import { createTaskWithTimeout } from '../session/utils/TaskWithTimeout'; import { perfEnd, perfStart } from '../session/utils/Performance'; @@ -317,7 +316,7 @@ export async function handleOpenGroupV2Message( source: sender, message: dataMessage, }; - // WARNING this is very important that the isMessageDuplicate is made in the conversation.queueJob + // WARNING this is important that the isMessageDuplicate is made in the conversation.queueJob const isDuplicate = await isMessageDuplicate(messageCreationData); if (isDuplicate) { @@ -325,10 +324,6 @@ export async function handleOpenGroupV2Message( return; } - if (isDuplicateBasedOnHash(dataMessage, conversationId, sender)) { - window?.log?.info('Received duplicate message based on hash. Dropping it.'); - return; - } // this line just create an empty message with some basic stuff set. // the whole decoding of data is happening in handleMessageJob() const msg = createMessage(messageCreationData, !isMe);