Files
huly-platform/models/server-notification/src/index.ts
T
2025-05-12 14:42:58 +07:00

111 lines
3.6 KiB
TypeScript

//
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021, 2022 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
import { type Builder, Mixin } from '@hcengineering/model'
import contact from '@hcengineering/contact'
import core from '@hcengineering/core'
import { TClass } from '@hcengineering/model-core'
import { TNotificationType } from '@hcengineering/model-notification'
import notification from '@hcengineering/notification'
import { type Resource } from '@hcengineering/platform'
import serverCore from '@hcengineering/server-core'
import serverNotification, {
type HTMLPresenter,
type NotificationContentProvider,
type NotificationPresenter,
type Presenter,
type TextPresenter,
type TypeMatch,
type TypeMatchFunc
} from '@hcengineering/server-notification'
export { serverNotificationId } from '@hcengineering/server-notification'
@Mixin(serverNotification.mixin.HTMLPresenter, core.class.Class)
export class THTMLPresenter extends TClass implements HTMLPresenter {
presenter!: Resource<Presenter>
}
@Mixin(serverNotification.mixin.TextPresenter, core.class.Class)
export class TTextPresenter extends TClass implements TextPresenter {
presenter!: Resource<Presenter>
}
@Mixin(serverNotification.mixin.NotificationPresenter, core.class.Class)
export class TNotificationPresenter extends TClass implements NotificationPresenter {
presenter!: Resource<NotificationContentProvider>
}
@Mixin(serverNotification.mixin.TypeMatch, notification.class.NotificationType)
export class TTypeMatch extends TNotificationType implements TypeMatch {
func!: TypeMatchFunc
}
export function createModel (builder: Builder): void {
builder.createModel(THTMLPresenter, TTextPresenter, TTypeMatch, TNotificationPresenter)
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverNotification.trigger.OnAttributeCreate,
txMatch: {
objectClass: core.class.Attribute,
_class: core.class.TxCreateDoc
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverNotification.trigger.OnAttributeUpdate,
txMatch: {
objectClass: core.class.Attribute,
_class: core.class.TxUpdateDoc
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverNotification.trigger.OnDocRemove,
txMatch: {
_class: core.class.TxRemoveDoc
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverNotification.trigger.OnEmployeeDeactivate,
isAsync: true,
txMatch: {
_class: core.class.TxMixin,
mixin: contact.mixin.Employee
}
})
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverNotification.trigger.PushNotificationsHandler,
isAsync: true,
txMatch: {
_class: core.class.TxCreateDoc,
objectClass: notification.class.InboxNotification
}
})
builder.mixin(
notification.ids.MentionNotificationType,
notification.class.NotificationType,
serverNotification.mixin.TypeMatch,
{
func: serverNotification.function.MentionTypeMatch
}
)
}