diff --git a/models/controlled-documents/src/index.ts b/models/controlled-documents/src/index.ts index 5f333087a7..fb4860d61a 100644 --- a/models/controlled-documents/src/index.ts +++ b/models/controlled-documents/src/index.ts @@ -1218,6 +1218,28 @@ export function defineNotifications (builder: Builder): void { documents.notification.StateNotification ) + builder.createDoc( + notification.class.NotificationType, + core.space.Model, + { + hidden: false, + generated: false, + allowedForAuthor: true, + label: documents.string.Review, + group: documents.notification.DocumentsNotificationGroup, + field: 'controlledState', + txClasses: [core.class.TxUpdateDoc], + objectClass: documents.class.ControlledDocument, + defaultEnabled: true, + templates: { + textTemplate: '{sender} marked {doc} as reviewed', + htmlTemplate: '

{sender} marked {doc} as reviewed

', + subjectTemplate: '{doc} reviewed' + } + }, + documents.notification.ReviewNotification + ) + builder.createDoc( notification.class.NotificationType, core.space.Model, @@ -1243,7 +1265,11 @@ export function defineNotifications (builder: Builder): void { builder.createDoc(notification.class.NotificationProviderDefaults, core.space.Model, { provider: notification.providers.InboxNotificationProvider, ignoredTypes: [], - enabledTypes: [documents.notification.StateNotification, documents.notification.ContentNotification] + enabledTypes: [ + documents.notification.StateNotification, + documents.notification.ContentNotification, + documents.notification.ReviewNotification + ] }) generateClassNotificationTypes( diff --git a/models/server-controlled-documents/src/index.ts b/models/server-controlled-documents/src/index.ts index a97537945b..1bbeeac478 100644 --- a/models/server-controlled-documents/src/index.ts +++ b/models/server-controlled-documents/src/index.ts @@ -72,6 +72,15 @@ export function createModel (builder: Builder): void { presenter: serverDocuments.function.ControlledDocumentHTMLPresenter }) + builder.mixin( + documents.notification.ReviewNotification, + notification.class.NotificationType, + serverNotification.mixin.TypeMatch, + { + func: serverDocuments.function.DocumentReviewedTypeMatch + } + ) + builder.mixin( documents.notification.CoAuthorsNotification, notification.class.NotificationType, diff --git a/plugins/controlled-documents/src/plugin.ts b/plugins/controlled-documents/src/plugin.ts index 0460f81531..d3460f1875 100644 --- a/plugins/controlled-documents/src/plugin.ts +++ b/plugins/controlled-documents/src/plugin.ts @@ -336,7 +336,8 @@ export const documentsPlugin = plugin(documentsId, { ProductChangeControl: '' as Ref }, notification: { - CoAuthorsNotification: '' as Ref + CoAuthorsNotification: '' as Ref, + ReviewNotification: '' as Ref }, viewlet: { DocumentSpaceTable: '' as Ref diff --git a/server-plugins/controlled-documents-resources/src/index.ts b/server-plugins/controlled-documents-resources/src/index.ts index b3815e706d..d7695a72b7 100644 --- a/server-plugins/controlled-documents-resources/src/index.ts +++ b/server-plugins/controlled-documents-resources/src/index.ts @@ -448,6 +448,21 @@ async function CoAuthorsTypeMatch ( return false } +async function DocumentReviewedTypeMatch ( + originTx: TxCUD, + _doc: Doc, + _person: Ref, + _socialIds: PersonId[], + _type: NotificationType, + _control: TriggerControl +): Promise { + if (originTx._class !== core.class.TxUpdateDoc) return false + + const tx = originTx as TxUpdateDoc + + return tx.operations.controlledState === ControlledDocumentState.Reviewed +} + // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export default async () => ({ trigger: { @@ -460,6 +475,7 @@ export default async () => ({ function: { ControlledDocumentTextPresenter, ControlledDocumentHTMLPresenter, - CoAuthorsTypeMatch + CoAuthorsTypeMatch, + DocumentReviewedTypeMatch } }) diff --git a/server-plugins/controlled-documents/src/index.ts b/server-plugins/controlled-documents/src/index.ts index 9dd154976f..407b4a89be 100644 --- a/server-plugins/controlled-documents/src/index.ts +++ b/server-plugins/controlled-documents/src/index.ts @@ -27,6 +27,7 @@ export default plugin(serverDocumentsId, { function: { ControlledDocumentTextPresenter: '' as Resource, ControlledDocumentHTMLPresenter: '' as Resource, - CoAuthorsTypeMatch: '' as TypeMatchFunc + CoAuthorsTypeMatch: '' as TypeMatchFunc, + DocumentReviewedTypeMatch: '' as TypeMatchFunc } })