-
Notifications
You must be signed in to change notification settings - Fork 306
fix: narrow outdated notification check to duplicate-risk events [WPB-21916] #21403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thisisamir98
wants to merge
6
commits into
dev
Choose a base branch
from
fix-missing-messages-outdated
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4d5449a
fix: narrow outdated notification check to duplicate-risk events
thisisamir98 f8fd896
rename variable to notificationSource
thisisamir98 ed3d61b
use is in logic
thisisamir98 f6e2a7e
remove optional type
thisisamir98 24c3189
refactor lastEventDate
thisisamir98 772fa93
t push Merge branch 'dev' of github.com:wireapp/wire-webapp into fix-…
thisisamir98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
libraries/core/src/notification/outdatedNotificationStreamEventTypes.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Wire | ||
| * Copyright (C) 2018 Wire Swiss GmbH | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see http://www.gnu.org/licenses/. | ||
| * | ||
| */ | ||
|
|
||
| import {CONVERSATION_EVENT} from '@wireapp/api-client/lib/event'; | ||
|
|
||
| import {NotificationSource} from './notificationSource.types'; | ||
| import {isOutdatedNotificationStreamEvent} from './outdatedNotificationStreamEventTypes'; | ||
|
|
||
| describe('isOutdatedNotificationStreamEvent', () => { | ||
| const eventTime = '2026-05-28T06:37:31.673Z'; | ||
| const lastEventDate = new Date(eventTime); | ||
|
|
||
| it('marks duplicate-risk events with an equal timestamp as outdated on the notification stream', () => { | ||
| expect( | ||
| isOutdatedNotificationStreamEvent( | ||
| {time: eventTime, type: CONVERSATION_EVENT.MEMBER_JOIN}, | ||
| NotificationSource.NOTIFICATION_STREAM, | ||
| lastEventDate, | ||
| ), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it('does not mark OTR message events with an equal timestamp as outdated', () => { | ||
| expect( | ||
| isOutdatedNotificationStreamEvent( | ||
| {time: eventTime, type: CONVERSATION_EVENT.OTR_MESSAGE_ADD}, | ||
| NotificationSource.NOTIFICATION_STREAM, | ||
| lastEventDate, | ||
| ), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it('does not apply the outdated check outside the notification stream', () => { | ||
| expect( | ||
| isOutdatedNotificationStreamEvent( | ||
| {time: eventTime, type: CONVERSATION_EVENT.MEMBER_JOIN}, | ||
| NotificationSource.WEBSOCKET, | ||
| lastEventDate, | ||
| ), | ||
| ).toBe(false); | ||
| }); | ||
| }); |
60 changes: 60 additions & 0 deletions
60
libraries/core/src/notification/outdatedNotificationStreamEventTypes.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Wire | ||
| * Copyright (C) 2018 Wire Swiss GmbH | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see http://www.gnu.org/licenses/. | ||
| * | ||
| */ | ||
|
|
||
| import {CONVERSATION_EVENT} from '@wireapp/api-client/lib/event'; | ||
|
|
||
| import {NotificationSource} from './notificationSource.types'; | ||
|
|
||
| /** | ||
| * Event types that can be handled locally (API response or pre-app init) and then | ||
| * replayed on the notification stream with the same timestamp. | ||
| * | ||
| * @see ConversationJoin.tsx (member-join via guest link) | ||
| * @see ConversationRepository injectEvent(..., BACKEND_RESPONSE) | ||
| */ | ||
| export const NOTIFICATION_STREAM_DUPLICATE_RISK_EVENT_TYPES: ReadonlySet<string> = new Set([ | ||
| CONVERSATION_EVENT.MEMBER_JOIN, | ||
| CONVERSATION_EVENT.MEMBER_LEAVE, | ||
| CONVERSATION_EVENT.CREATE, | ||
| CONVERSATION_EVENT.RENAME, | ||
| CONVERSATION_EVENT.PROTOCOL_UPDATE, | ||
| CONVERSATION_EVENT.MESSAGE_TIMER_UPDATE, | ||
| CONVERSATION_EVENT.RECEIPT_MODE_UPDATE, | ||
| CONVERSATION_EVENT.ADD_PERMISSION_UPDATE, | ||
| ]); | ||
|
|
||
| export function isOutdatedNotificationStreamEvent( | ||
| event: {time?: string; type: string}, | ||
| source: string, | ||
|
thisisamir98 marked this conversation as resolved.
Outdated
|
||
| lastEventDate?: Date, | ||
| ): boolean { | ||
| if (source !== NotificationSource.NOTIFICATION_STREAM) { | ||
| return false; | ||
| } | ||
|
|
||
| if (event.time === undefined || event.time.length === 0 || lastEventDate === undefined) { | ||
|
thisisamir98 marked this conversation as resolved.
Outdated
|
||
| return false; | ||
| } | ||
|
|
||
| if (!NOTIFICATION_STREAM_DUPLICATE_RISK_EVENT_TYPES.has(event.type)) { | ||
| return false; | ||
| } | ||
|
|
||
| return lastEventDate.getTime() >= new Date(event.time).getTime(); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.