From 10252ee9bd626a737f10b5e6e55b5408f787bd6e Mon Sep 17 00:00:00 2001 From: Artem Savchenko Date: Fri, 21 Nov 2025 18:23:31 +0700 Subject: [PATCH 1/3] Remove notifications migration Signed-off-by: Artem Savchenko --- models/notification/src/migration.ts | 90 ++-------------------------- 1 file changed, 6 insertions(+), 84 deletions(-) diff --git a/models/notification/src/migration.ts b/models/notification/src/migration.ts index 06fa9a35d4c..d60b450a9d5 100644 --- a/models/notification/src/migration.ts +++ b/models/notification/src/migration.ts @@ -44,12 +44,9 @@ import notification, { type BrowserNotification, type DocNotifyContext, type InboxNotification, - type OldCollaborators, - type ReactionInboxNotification, - type ActivityInboxNotification + type OldCollaborators } from '@hcengineering/notification' import { DOMAIN_PREFERENCE } from '@hcengineering/preference' -import activity, { type ActivityMessage, type DocUpdateMessage, type Reaction } from '@hcengineering/activity' import { DOMAIN_SPACE, @@ -59,7 +56,6 @@ import { getSocialIdFromOldAccount } from '@hcengineering/model-core' import { DOMAIN_DOC_NOTIFY, DOMAIN_NOTIFICATION, DOMAIN_USER_NOTIFY } from './index' -import { DOMAIN_ACTIVITY, DOMAIN_REACTION } from '@hcengineering/model-activity' export async function removeNotifications ( client: MigrationClient, @@ -316,85 +312,11 @@ async function migrateCollaborators (client: MigrationClient): Promise { } async function migrateReactionNotifications (client: MigrationClient): Promise { - const hierarchy = client.hierarchy - const iterator = await client.traverse(DOMAIN_DOC_NOTIFY, { - _class: notification.class.DocNotifyContext - }) - - try { - while (true) { - const contexts = await iterator.next(500) - const res: ReactionInboxNotification[] = [] - const removeIds: Ref[] = [] - if (contexts == null || contexts.length === 0) break - const filtered = contexts.filter((it) => hierarchy.isDerived(it.objectClass, activity.class.ActivityMessage)) - if (filtered.length === 0) continue - - for (const context of filtered) { - const notifications = await client.find(DOMAIN_NOTIFICATION, { - docNotifyContext: context._id, - _class: notification.class.ActivityInboxNotification, - attachedToClass: activity.class.DocUpdateMessage - }) - if (notifications.length === 0) continue - const messages = await client.find(DOMAIN_ACTIVITY, { - _id: { $in: notifications.map((it) => it.attachedTo) as Ref[] }, - _class: activity.class.DocUpdateMessage, - objectClass: activity.class.Reaction - }) - const contextMessage = ( - await client.find(DOMAIN_ACTIVITY, { _id: context.objectId as any }) - )[0] - if (contextMessage == null) continue - const newContext = ( - await client.find(DOMAIN_DOC_NOTIFY, { - user: context.user, - objectId: contextMessage.attachedTo - }) - )[0] - if (newContext == null) { - continue - } - for (const it of notifications) { - const reactionMessage = messages.find((m) => m._id === it.attachedTo) - if (reactionMessage == null) continue - const emoji = - it.data ?? - (await client.find(DOMAIN_REACTION, { _id: reactionMessage.objectId as Ref }))[0].emoji - if (emoji == null || emoji.trim() === '') continue - res.push({ - _id: it._id as Ref, - _class: notification.class.ReactionInboxNotification, - space: it.space, - emoji, - user: it.user, - docNotifyContext: newContext._id, - objectId: newContext.objectId, - objectClass: newContext.objectClass, - ref: reactionMessage.objectId as Ref, - attachedTo: reactionMessage.attachedTo as Ref, - attachedToClass: reactionMessage.attachedToClass as Ref>, - isViewed: it.isViewed, - archived: it.archived, - modifiedOn: it.modifiedOn, - createdBy: it.createdBy, - createdOn: it.createdOn, - modifiedBy: it.modifiedBy - }) - } - } - - if (removeIds.length > 0) { - await client.deleteMany(DOMAIN_NOTIFICATION, { _id: { $in: removeIds } }) - } - - if (res.length > 0) { - await client.create(DOMAIN_NOTIFICATION, res) - } - } - } catch (e) { - console.error(e) - } + /* + Do nothining for now, since previos implementation was very slow and caused issues in production. + Old inbox is used in production now, so later add a tool to migrate old reaction notifications if needed. + TODO: UBERF-14185 + */ } /** From cb919ee991a4dc3120a825bb5a5fc299879f21d6 Mon Sep 17 00:00:00 2001 From: Artem Savchenko Date: Fri, 21 Nov 2025 18:28:00 +0700 Subject: [PATCH 2/3] Fix typo Signed-off-by: Artem Savchenko --- models/notification/src/migration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/notification/src/migration.ts b/models/notification/src/migration.ts index d60b450a9d5..a47936f1876 100644 --- a/models/notification/src/migration.ts +++ b/models/notification/src/migration.ts @@ -313,7 +313,7 @@ async function migrateCollaborators (client: MigrationClient): Promise { async function migrateReactionNotifications (client: MigrationClient): Promise { /* - Do nothining for now, since previos implementation was very slow and caused issues in production. + Do nothing for now, since previos implementation was very slow and caused issues in production. Old inbox is used in production now, so later add a tool to migrate old reaction notifications if needed. TODO: UBERF-14185 */ From 1cfea3fdb750f5a4dc903aabacf693ee87352bd4 Mon Sep 17 00:00:00 2001 From: Artem Savchenko Date: Fri, 21 Nov 2025 18:34:05 +0700 Subject: [PATCH 3/3] Fix typo Signed-off-by: Artem Savchenko --- models/notification/src/migration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/notification/src/migration.ts b/models/notification/src/migration.ts index a47936f1876..5bc85e0183e 100644 --- a/models/notification/src/migration.ts +++ b/models/notification/src/migration.ts @@ -313,7 +313,7 @@ async function migrateCollaborators (client: MigrationClient): Promise { async function migrateReactionNotifications (client: MigrationClient): Promise { /* - Do nothing for now, since previos implementation was very slow and caused issues in production. + Do nothing for now, since previous implementation was very slow and caused issues in production. Old inbox is used in production now, so later add a tool to migrate old reaction notifications if needed. TODO: UBERF-14185 */