mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 20:57:45 +02:00
Move notifications to person spaces (#6263)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
import { Account, Doc, Ref, TxOperations } from '@hcengineering/core'
|
||||
import notification, { DocNotifyContext } from '@hcengineering/notification'
|
||||
import { IntlString } from '@hcengineering/platform'
|
||||
import { PersonSpace } from '@hcengineering/contact'
|
||||
import github from '@hcengineering/github'
|
||||
|
||||
export async function createNotification (
|
||||
client: TxOperations,
|
||||
forDoc: Doc,
|
||||
data: { user: Ref<Account>, message: IntlString, props: Record<string, any> }
|
||||
data: { user: Ref<Account>, space: Ref<PersonSpace>, message: IntlString, props: Record<string, any> }
|
||||
): Promise<void> {
|
||||
let docNotifyContext = await client.findOne(notification.class.DocNotifyContext, { attachedTo: forDoc._id })
|
||||
let docNotifyContext = await client.findOne(notification.class.DocNotifyContext, { objectId: forDoc._id })
|
||||
|
||||
if (docNotifyContext?._id === undefined) {
|
||||
const docNotifyContextId = await client.createDoc(notification.class.DocNotifyContext, forDoc.space, {
|
||||
attachedTo: forDoc._id,
|
||||
attachedToClass: forDoc._class,
|
||||
const docNotifyContextId = await client.createDoc(notification.class.DocNotifyContext, data.space, {
|
||||
objectId: forDoc._id,
|
||||
objectClass: forDoc._class,
|
||||
objectSpace: forDoc.space,
|
||||
user: data.user,
|
||||
isPinned: false
|
||||
})
|
||||
@@ -21,7 +23,6 @@ export async function createNotification (
|
||||
}
|
||||
|
||||
// Check if we had already same notification send, and just unmark it viewed.
|
||||
|
||||
const existing = await client.findOne(notification.class.CommonInboxNotification, {
|
||||
user: data.user,
|
||||
message: data.message,
|
||||
@@ -32,7 +33,7 @@ export async function createNotification (
|
||||
isViewed: false
|
||||
})
|
||||
} else {
|
||||
await client.createDoc(notification.class.CommonInboxNotification, forDoc.space, {
|
||||
await client.createDoc(notification.class.CommonInboxNotification, data.space, {
|
||||
user: data.user,
|
||||
icon: github.icon.Github,
|
||||
message: data.message,
|
||||
|
||||
Reference in New Issue
Block a user