mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 11:01:54 +03:00
UBER-277 Reminders don't have notifications (#3315)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
58ba8fbe07
commit
2dfe0f330c
@ -137,6 +137,10 @@ export function createModel (builder: Builder): void {
|
||||
calendar.ids.CalendarNotificationGroup
|
||||
)
|
||||
|
||||
builder.mixin(calendar.class.Event, core.class.Class, notification.mixin.ClassCollaborators, {
|
||||
fields: ['participants']
|
||||
})
|
||||
|
||||
builder.createDoc(
|
||||
notification.class.NotificationType,
|
||||
core.space.Model,
|
||||
@ -145,7 +149,9 @@ export function createModel (builder: Builder): void {
|
||||
generated: false,
|
||||
label: calendar.string.Reminder,
|
||||
group: calendar.ids.CalendarNotificationGroup,
|
||||
txClasses: [],
|
||||
txClasses: [core.class.TxMixin],
|
||||
field: 'state',
|
||||
txMatch: { 'attributes.state': 'done' },
|
||||
objectClass: calendar.mixin.Reminder,
|
||||
allowedForAuthor: true,
|
||||
templates: {
|
||||
@ -168,7 +174,7 @@ export function createModel (builder: Builder): void {
|
||||
objectClass: calendar.mixin.Reminder,
|
||||
icon: calendar.icon.Reminder,
|
||||
txClass: core.class.TxMixin,
|
||||
label: calendar.string.CreatedReminder,
|
||||
label: calendar.string.Reminder,
|
||||
component: calendar.activity.ReminderViewlet,
|
||||
display: 'emphasized',
|
||||
editable: false,
|
||||
|
@ -28,6 +28,8 @@
|
||||
"@hcengineering/core": "^0.6.25",
|
||||
"@hcengineering/model": "^0.6.4",
|
||||
"@hcengineering/platform": "^0.6.9",
|
||||
"@hcengineering/server-notification": "^0.6.0",
|
||||
"@hcengineering/calendar": "^0.6.9",
|
||||
"@hcengineering/server-calendar": "^0.6.0",
|
||||
"@hcengineering/server-core": "^0.6.1"
|
||||
}
|
||||
|
@ -15,13 +15,23 @@
|
||||
|
||||
import { Builder } from '@hcengineering/model'
|
||||
|
||||
import calendar from '@hcengineering/calendar'
|
||||
import core, { Class, Doc } from '@hcengineering/core'
|
||||
import serverNotification from '@hcengineering/server-notification'
|
||||
import serverCalendar from '@hcengineering/server-calendar'
|
||||
import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core'
|
||||
|
||||
export { serverCalendarId } from '@hcengineering/server-calendar'
|
||||
|
||||
export function createModel (builder: Builder): void {
|
||||
builder.mixin(calendar.class.Event, core.class.Class, serverNotification.mixin.HTMLPresenter, {
|
||||
presenter: serverCalendar.function.EventHTMLPresenter
|
||||
})
|
||||
|
||||
builder.mixin(calendar.class.Event, core.class.Class, serverNotification.mixin.TextPresenter, {
|
||||
presenter: serverCalendar.function.EventTextPresenter
|
||||
})
|
||||
|
||||
builder.mixin<Class<Doc>, ObjectDDParticipant>(
|
||||
core.class.Doc,
|
||||
core.class.Class,
|
||||
|
@ -19,6 +19,7 @@ import {
|
||||
AttachedDoc,
|
||||
Class,
|
||||
Doc,
|
||||
DocumentQuery,
|
||||
Mixin,
|
||||
Ref,
|
||||
Space,
|
||||
@ -103,6 +104,7 @@ export interface NotificationType extends Doc {
|
||||
attachedToClass?: Ref<Class<Doc>>
|
||||
// use for update/mixin txes
|
||||
field?: string
|
||||
txMatch?: DocumentQuery<Tx>
|
||||
// use for space collaborators, not object
|
||||
spaceSubscribe?: boolean
|
||||
// allowed providers and default value for it
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user