mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
UBERF-6807: fix empty objects channels in chat (#5533)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
6c2fdb520b
commit
56400846f3
@ -24,7 +24,9 @@ import core, {
|
||||
type Domain,
|
||||
type Ref,
|
||||
type TxCUD,
|
||||
type TxCollectionCUD
|
||||
type TxCollectionCUD,
|
||||
type Class,
|
||||
type DocumentQuery
|
||||
} from '@hcengineering/core'
|
||||
import {
|
||||
tryMigrate,
|
||||
@ -237,16 +239,16 @@ async function migrateInboxNotifications (client: MigrationClient): Promise<void
|
||||
}
|
||||
}
|
||||
|
||||
export async function removeHiddenNotifications (client: MigrationClient): Promise<void> {
|
||||
const processedIds: Ref<DocNotifyContext>[] = []
|
||||
|
||||
export async function removeNotifications (
|
||||
client: MigrationClient,
|
||||
query: DocumentQuery<DocNotifyContext>
|
||||
): Promise<void> {
|
||||
while (true) {
|
||||
const contexts = await client.find<DocNotifyContext>(
|
||||
DOMAIN_NOTIFICATION,
|
||||
{
|
||||
_class: notification.class.DocNotifyContext,
|
||||
_id: { $nin: processedIds },
|
||||
hidden: true
|
||||
...query
|
||||
},
|
||||
{ limit: 500 }
|
||||
)
|
||||
@ -257,8 +259,6 @@ export async function removeHiddenNotifications (client: MigrationClient): Promi
|
||||
|
||||
const ids = contexts.map(({ _id }) => _id)
|
||||
|
||||
processedIds.push(...ids)
|
||||
|
||||
await client.deleteMany(DOMAIN_NOTIFICATION, {
|
||||
_class: notification.class.CommonInboxNotification,
|
||||
docNotifyContext: { $in: ids }
|
||||
@ -268,6 +268,16 @@ export async function removeHiddenNotifications (client: MigrationClient): Promi
|
||||
_class: notification.class.ActivityInboxNotification,
|
||||
docNotifyContext: { $in: ids }
|
||||
})
|
||||
|
||||
await client.deleteMany(DOMAIN_NOTIFICATION, {
|
||||
_class: notification.class.MentionInboxNotification,
|
||||
docNotifyContext: { $in: ids }
|
||||
})
|
||||
|
||||
await client.deleteMany(DOMAIN_NOTIFICATION, {
|
||||
_class: notification.class.DocNotifyContext,
|
||||
_id: { $in: ids }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,8 +291,18 @@ export const notificationOperation: MigrateOperation = {
|
||||
])
|
||||
await tryMigrate(client, notificationId, [
|
||||
{
|
||||
state: 'remove-hidden-notifications',
|
||||
func: removeHiddenNotifications
|
||||
state: 'delete-hidden-notifications',
|
||||
func: async (client) => {
|
||||
await removeNotifications(client, { hidden: true })
|
||||
}
|
||||
}
|
||||
])
|
||||
await tryMigrate(client, notificationId, [
|
||||
{
|
||||
state: 'delete-invalid-notifications',
|
||||
func: async (client) => {
|
||||
await removeNotifications(client, { attachedToClass: 'chunter:class:Comment' as Ref<Class<Doc>> })
|
||||
}
|
||||
}
|
||||
])
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user