mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-21 03:42:24 +02:00
UBER-277 Reminders don't have notifications (#3315)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hcengineering/core": "^0.6.25",
|
||||
"@hcengineering/calendar": "^0.6.9"
|
||||
"@hcengineering/platform": "^0.6.9",
|
||||
"@hcengineering/calendar": "^0.6.9",
|
||||
"@hcengineering/server-core": "^0.6.1",
|
||||
"@hcengineering/server-notification-resources": "^0.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,11 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import calendar from '@hcengineering/calendar'
|
||||
import calendar, { Event } from '@hcengineering/calendar'
|
||||
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
|
||||
import { getResource } from '@hcengineering/platform'
|
||||
import { TriggerControl } from '@hcengineering/server-core'
|
||||
import { getHTMLPresenter, getTextPresenter } from '@hcengineering/server-notification-resources'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@@ -32,9 +35,40 @@ export async function FindReminders (
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function EventHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string | undefined> {
|
||||
const event = doc as Event
|
||||
const target = (await control.findAll(event.attachedToClass, { _id: event.attachedTo }, { limit: 1 }))[0]
|
||||
if (target !== undefined) {
|
||||
const HTMLPresenter = getHTMLPresenter(target._class, control.hierarchy)
|
||||
const htmlPart =
|
||||
HTMLPresenter !== undefined ? await (await getResource(HTMLPresenter.presenter))(target, control) : undefined
|
||||
return htmlPart
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function EventTextPresenter (doc: Doc, control: TriggerControl): Promise<string | undefined> {
|
||||
const event = doc as Event
|
||||
const target = (await control.findAll(event.attachedToClass, { _id: event.attachedTo }, { limit: 1 }))[0]
|
||||
if (target !== undefined) {
|
||||
const TextPresenter = getTextPresenter(target._class, control.hierarchy)
|
||||
if (TextPresenter === undefined) return
|
||||
return await (
|
||||
await getResource(TextPresenter.presenter)
|
||||
)(target, control)
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export default async () => ({
|
||||
function: {
|
||||
EventHTMLPresenter,
|
||||
EventTextPresenter,
|
||||
FindReminders
|
||||
}
|
||||
})
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hcengineering/core": "^0.6.25",
|
||||
"@hcengineering/server-notification": "^0.6.0",
|
||||
"@hcengineering/platform": "^0.6.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
|
||||
import type { Plugin, Resource } from '@hcengineering/platform'
|
||||
import { plugin } from '@hcengineering/platform'
|
||||
import { Presenter } from '@hcengineering/server-notification'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@@ -28,6 +29,8 @@ export const serverCalendarId = 'server-calendar' as Plugin
|
||||
*/
|
||||
export default plugin(serverCalendarId, {
|
||||
function: {
|
||||
EventHTMLPresenter: '' as Resource<Presenter>,
|
||||
EventTextPresenter: '' as Resource<Presenter>,
|
||||
FindReminders: '' as Resource<
|
||||
(
|
||||
doc: Doc,
|
||||
|
||||
@@ -38,7 +38,8 @@ import core, {
|
||||
TxProcessor,
|
||||
TxRemoveDoc,
|
||||
TxUpdateDoc,
|
||||
generateId
|
||||
generateId,
|
||||
matchQuery
|
||||
} from '@hcengineering/core'
|
||||
import notification, {
|
||||
ClassCollaborators,
|
||||
@@ -159,11 +160,17 @@ async function getHtmlPart (doc: Doc, control: TriggerControl): Promise<string |
|
||||
return htmlPart
|
||||
}
|
||||
|
||||
function getHTMLPresenter (_class: Ref<Class<Doc>>, hierarchy: Hierarchy): HTMLPresenter | undefined {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function getHTMLPresenter (_class: Ref<Class<Doc>>, hierarchy: Hierarchy): HTMLPresenter | undefined {
|
||||
return hierarchy.classHierarchyMixin(_class, serverNotification.mixin.HTMLPresenter)
|
||||
}
|
||||
|
||||
function getTextPresenter (_class: Ref<Class<Doc>>, hierarchy: Hierarchy): TextPresenter | undefined {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function getTextPresenter (_class: Ref<Class<Doc>>, hierarchy: Hierarchy): TextPresenter | undefined {
|
||||
return hierarchy.classHierarchyMixin(_class, serverNotification.mixin.TextPresenter)
|
||||
}
|
||||
|
||||
@@ -362,6 +369,10 @@ function isTypeMatched (
|
||||
if (!fieldUpdated(type.field, (extractedTx as TxMixin<Doc, Doc>).attributes)) return false
|
||||
}
|
||||
}
|
||||
if (type.txMatch !== undefined) {
|
||||
const res = matchQuery([extractedTx], type.txMatch, extractedTx._class, control.hierarchy, true)
|
||||
if (res.length === 0) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user