mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 08:20:39 +00:00
Notification fix (#2330)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
e2db2c7a81
commit
2c681a88a9
@ -32,6 +32,7 @@ import core, {
|
|||||||
TxCollectionCUD,
|
TxCollectionCUD,
|
||||||
TxCreateDoc,
|
TxCreateDoc,
|
||||||
TxCUD,
|
TxCUD,
|
||||||
|
TxFactory,
|
||||||
TxProcessor
|
TxProcessor
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import notification, {
|
import notification, {
|
||||||
@ -50,7 +51,8 @@ import serverNotification, {
|
|||||||
createLastViewTx,
|
createLastViewTx,
|
||||||
getEmployeeAccount,
|
getEmployeeAccount,
|
||||||
getEmployeeAccountById,
|
getEmployeeAccountById,
|
||||||
getUpdateLastViewTx
|
getUpdateLastViewTx,
|
||||||
|
getEmployee
|
||||||
} from '@hcengineering/server-notification'
|
} from '@hcengineering/server-notification'
|
||||||
import { replaceAll } from './utils'
|
import { replaceAll } from './utils'
|
||||||
import { Content } from './types'
|
import { Content } from './types'
|
||||||
@ -209,9 +211,19 @@ export async function createNotificationTxes (
|
|||||||
const content = await getContent(doc, senderName, type, control, data)
|
const content = await getContent(doc, senderName, type, control, data)
|
||||||
|
|
||||||
if (await isAllowed(control, receiver, notification.ids.PlatformNotification)) {
|
if (await isAllowed(control, receiver, notification.ids.PlatformNotification)) {
|
||||||
const createNotificationTx = await getPlatformNotificationTx(ptx, type, content?.text, action)
|
const target = await getEmployee(receiver.employee, control)
|
||||||
|
if (target !== undefined) {
|
||||||
|
const createNotificationTx = await getPlatformNotificationTx(
|
||||||
|
ptx,
|
||||||
|
type,
|
||||||
|
control.txFactory,
|
||||||
|
target,
|
||||||
|
content?.text,
|
||||||
|
action
|
||||||
|
)
|
||||||
|
|
||||||
res.push(createNotificationTx)
|
res.push(createNotificationTx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content !== undefined && (await isAllowed(control, receiver, notification.ids.EmailNotification))) {
|
if (content !== undefined && (await isAllowed(control, receiver, notification.ids.EmailNotification))) {
|
||||||
@ -227,6 +239,8 @@ export async function createNotificationTxes (
|
|||||||
async function getPlatformNotificationTx (
|
async function getPlatformNotificationTx (
|
||||||
ptx: TxCollectionCUD<Doc, AttachedDoc>,
|
ptx: TxCollectionCUD<Doc, AttachedDoc>,
|
||||||
type: Ref<NotificationType>,
|
type: Ref<NotificationType>,
|
||||||
|
txFactory: TxFactory,
|
||||||
|
target: Employee,
|
||||||
text?: string,
|
text?: string,
|
||||||
action?: NotificationAction
|
action?: NotificationAction
|
||||||
): Promise<TxCollectionCUD<Doc, Notification>> {
|
): Promise<TxCollectionCUD<Doc, Notification>> {
|
||||||
@ -254,14 +268,7 @@ async function getPlatformNotificationTx (
|
|||||||
createTx.attributes.action = action
|
createTx.attributes.action = action
|
||||||
}
|
}
|
||||||
|
|
||||||
const createNotificationTx: TxCollectionCUD<Doc, Notification> = {
|
return txFactory.createTxCollectionCUD(target._class, target._id, target.space, 'notifications', createTx)
|
||||||
...ptx,
|
|
||||||
_id: generateId(),
|
|
||||||
collection: 'notifications',
|
|
||||||
tx: createTx
|
|
||||||
}
|
|
||||||
|
|
||||||
return createNotificationTx
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getEmailNotificationTx (
|
async function getEmailNotificationTx (
|
||||||
|
@ -19,12 +19,7 @@ import login from '@hcengineering/login'
|
|||||||
import { NotificationAction } from '@hcengineering/notification'
|
import { NotificationAction } from '@hcengineering/notification'
|
||||||
import { getMetadata, Resource } from '@hcengineering/platform'
|
import { getMetadata, Resource } from '@hcengineering/platform'
|
||||||
import { TriggerControl } from '@hcengineering/server-core'
|
import { TriggerControl } from '@hcengineering/server-core'
|
||||||
import {
|
import { getEmployeeAccount, getEmployeeAccountById, getUpdateLastViewTx } from '@hcengineering/server-notification'
|
||||||
getEmployee,
|
|
||||||
getEmployeeAccount,
|
|
||||||
getEmployeeAccountById,
|
|
||||||
getUpdateLastViewTx
|
|
||||||
} from '@hcengineering/server-notification'
|
|
||||||
import { createNotificationTxes } from '@hcengineering/server-notification-resources'
|
import { createNotificationTxes } from '@hcengineering/server-notification-resources'
|
||||||
import task, { Issue, Task, taskId } from '@hcengineering/task'
|
import task, { Issue, Task, taskId } from '@hcengineering/task'
|
||||||
import view from '@hcengineering/view'
|
import view from '@hcengineering/view'
|
||||||
@ -63,11 +58,6 @@ export async function addAssigneeNotification (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = await getEmployee(assignee, control)
|
|
||||||
if (target === undefined) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const receiver = await getEmployeeAccount(assignee, control)
|
const receiver = await getEmployeeAccount(assignee, control)
|
||||||
if (receiver === undefined) {
|
if (receiver === undefined) {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user