UBERF-7513: Improve notifications model to allow external notifications channels (#6037)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2024-07-12 19:07:11 +07:00
committed by GitHub
parent 0fc0115c99
commit e4192b27fc
78 changed files with 1696 additions and 931 deletions
+31 -1
View File
@@ -16,7 +16,13 @@
import contact, { Employee, Person, PersonAccount } from '@hcengineering/contact'
import { Account, Class, Doc, Mixin, Ref, Tx, TxCUD } from '@hcengineering/core'
import { NotificationContent, NotificationType } from '@hcengineering/notification'
import {
BaseNotificationType,
InboxNotification,
NotificationContent,
NotificationProvider,
NotificationType
} from '@hcengineering/notification'
import { Metadata, Plugin, Resource, plugin } from '@hcengineering/platform'
import type { TriggerControl, TriggerFunc } from '@hcengineering/server-core'
@@ -129,7 +135,28 @@ export interface NotificationPresenter extends Class<Doc> {
presenter: Resource<NotificationContentProvider>
}
export interface UserInfo {
_id: Ref<Account>
account?: PersonAccount
person?: Person
}
export type NotificationProviderFunc = (
control: TriggerControl,
types: BaseNotificationType[],
object: Doc,
data: InboxNotification,
receiver: UserInfo,
sender: UserInfo
) => Promise<Tx[]>
export interface NotificationProviderResources extends Doc {
provider: Ref<NotificationProvider>
fn: Resource<NotificationProviderFunc>
}
export const NOTIFICATION_BODY_SIZE = 50
export const NOTIFICATION_TITLE_SIZE = 30
/**
* @public
@@ -140,6 +167,9 @@ export default plugin(serverNotificationId, {
PushPrivateKey: '' as Metadata<string>,
PushSubject: '' as Metadata<string>
},
class: {
NotificationProviderResources: '' as Ref<Class<NotificationProviderResources>>
},
mixin: {
HTMLPresenter: '' as Ref<Mixin<HTMLPresenter>>,
TextPresenter: '' as Ref<Mixin<TextPresenter>>,