From 8060411d02f6a734393be28ed60507d633ed004d Mon Sep 17 00:00:00 2001 From: Zeeshan Akram <97m.zeeshan@gmail.com> Date: Fri, 19 Jul 2024 18:05:49 +0500 Subject: [PATCH 1/3] fix: set notification.dispatch_block field for all type of notifications --- src/utils/notification/helpers.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/utils/notification/helpers.ts b/src/utils/notification/helpers.ts index 9c112224d..e2023a284 100644 --- a/src/utils/notification/helpers.ts +++ b/src/utils/notification/helpers.ts @@ -12,6 +12,7 @@ import { RecipientType, Unread, } from '../../model' +import { getCurrentBlockHeight } from '../blockHeight' import { uniqueId } from '../crypto' import { getNextIdForEntity } from '../nextEntityId' import { EntityManagerOverlay } from '../overlay' @@ -153,7 +154,7 @@ async function addOffChainNotification( account: Flat, recipient: RecipientType, notificationType: NotificationType, - dispatchBlock?: number + dispatchBlock: number ) { // get notification Id from orion_db in any case const nextNotificationId = await getNextIdForEntity(em, OFFCHAIN_NOTIFICATION_ID_TAG) @@ -163,8 +164,8 @@ async function addOffChainNotification( account.id, recipient, notificationType, - undefined, - dispatchBlock + dispatchBlock, + undefined ) const pref = preferencesForNotification(account.notificationPreferences, notificationType) @@ -184,7 +185,7 @@ async function addRuntimeNotification( recipient: RecipientType, notificationType: NotificationType, event: Event, - dispatchBlock?: number + dispatchBlock: number ) { // get notification Id from orion_db in any case const nextNotificationId = await getNextIdForEntity(overlay, RUNTIME_NOTIFICATION_ID_TAG) @@ -205,8 +206,8 @@ async function addRuntimeNotification( account.id, recipient, notificationType, - event, - dispatchBlock + dispatchBlock, + event ) const pref = preferencesForNotification(account.notificationPreferences, notificationType) @@ -248,8 +249,8 @@ const createNotification = ( accountId: string, recipient: RecipientType, notificationType: NotificationType, - event?: Event, - dispatchBlock?: number + dispatchBlock: number, + event?: Event ) => { return new Notification({ id, @@ -284,15 +285,16 @@ export const addNotification = async ( recipient, notificationType, event, - dispatchBlock + dispatchBlock ?? event.inBlock ) } else { + const { lastProcessedBlock } = await getCurrentBlockHeight(store as EntityManager) await addOffChainNotification( store as EntityManager, account, recipient, notificationType, - dispatchBlock + dispatchBlock ?? lastProcessedBlock ) } } From 1caf9ed17e56bfb418d61220bdb6d85d3bff1e55 Mon Sep 17 00:00:00 2001 From: Zeeshan Akram <97m.zeeshan@gmail.com> Date: Fri, 19 Jul 2024 18:12:45 +0500 Subject: [PATCH 2/3] address review comment --- src/utils/notification/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/notification/helpers.ts b/src/utils/notification/helpers.ts index e2023a284..738e901de 100644 --- a/src/utils/notification/helpers.ts +++ b/src/utils/notification/helpers.ts @@ -285,7 +285,7 @@ export const addNotification = async ( recipient, notificationType, event, - dispatchBlock ?? event.inBlock + dispatchBlock || event.inBlock ) } else { const { lastProcessedBlock } = await getCurrentBlockHeight(store as EntityManager) From 87340a1089baef78e4592836fe074b5206d20fd0 Mon Sep 17 00:00:00 2001 From: Zeeshan Akram <97m.zeeshan@gmail.com> Date: Fri, 19 Jul 2024 18:17:44 +0500 Subject: [PATCH 3/3] bump package version and update changelog --- CHANGELOG.md | 7 ++++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a9aa497..65c831704 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -# 4.0.4 +# 4.0.6 + +## Bug Fixes: +- Fixed: Set `Notification.dispatchBlock` field for all type of notifications (both future and immediate), to allow querying notifications by block number at which they should be delivered - [#344](https://github.com/Joystream/orion/pull/344) + +# 4.0.5 ## Bug Fixes: - Fixed: avoiding IDs override/conflict while creating concurrent runtime notifications by reading/updating the `nextEntityId` from the `overlay` instead of DB - [#342](https://github.com/Joystream/orion/pull/342) diff --git a/package-lock.json b/package-lock.json index 9f82045bd..dc6c9b99a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orion", - "version": "4.0.5", + "version": "4.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orion", - "version": "4.0.5", + "version": "4.0.6", "hasInstallScript": true, "workspaces": [ "network-tests" diff --git a/package.json b/package.json index ef4247b79..bbc40125b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orion", - "version": "4.0.5", + "version": "4.0.6", "engines": { "node": ">=16" },