Card email notifications (#10509)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-02-16 16:08:31 +07:00
committed by GitHub
parent b572b0440d
commit 8484b37395
6 changed files with 40 additions and 6 deletions
+3
View File
@@ -32337,6 +32337,9 @@ importers:
'@hcengineering/view':
specifier: workspace:^0.7.0
version: link:../../plugins/view
'@hcengineering/workbench':
specifier: workspace:^0.7.0
version: link:../../plugins/workbench
devDependencies:
'@hcengineering/platform-rig':
specifier: workspace:^0.7.19
+12 -2
View File
@@ -469,7 +469,12 @@ export function createModel (builder: Builder): void {
group: card.ids.CardNotificationGroup,
txClasses: [core.class.TxUpdateDoc, core.class.TxMixin],
objectClass: card.class.Card,
defaultEnabled: false
defaultEnabled: false,
templates: {
textTemplate: '{body}',
htmlTemplate: '<p>{body}</p><p>{link}</p>',
subjectTemplate: '{title} updated'
}
},
card.ids.CardNotification
)
@@ -485,7 +490,12 @@ export function createModel (builder: Builder): void {
txClasses: [core.class.TxCreateDoc],
objectClass: chunter.class.ChatMessage,
attachedToClass: card.class.Card,
defaultEnabled: true
defaultEnabled: true,
templates: {
textTemplate: 'New message in {title} ({link}) from {senderName}: {message}',
htmlTemplate: '<p>New message in <b>{title}</b> <b>from {senderName}</b>: {message}<p>{link}</p>',
subjectTemplate: 'New message from {senderName} in {title}'
}
},
card.ids.CardMessageNotification
)
+4
View File
@@ -134,4 +134,8 @@ export function createModel (builder: Builder): void {
builder.mixin(card.class.Card, core.class.Class, serverNotification.mixin.TextPresenter, {
presenter: serverCard.function.CardTextPresenter
})
builder.mixin(card.class.Card, core.class.Class, serverNotification.mixin.HTMLPresenter, {
presenter: serverCard.function.CardHTMLPresenter
})
}
@@ -43,6 +43,7 @@
"@hcengineering/core": "workspace:^0.7.24",
"@hcengineering/platform": "workspace:^0.7.19",
"@hcengineering/server-core": "workspace:^0.7.18",
"@hcengineering/workbench": "workspace:^0.7.0",
"@hcengineering/communication-types": "workspace:^0.7.12",
"@hcengineering/communication-sdk-types": "workspace:^0.7.12",
"@hcengineering/communication": "workspace:^0.7.0",
+18 -3
View File
@@ -13,12 +13,13 @@
// limitations under the License.
//
import card, { Card, MasterTag, Tag } from '@hcengineering/card'
import card, { Card, cardId, MasterTag, Tag } from '@hcengineering/card'
import core, {
AccountUuid,
AnyAttribute,
ArrOf,
Class,
concatLink,
Data,
Doc,
DocumentUpdate,
@@ -41,8 +42,9 @@ import core, {
TxRemoveDoc,
TxUpdateDoc
} from '@hcengineering/core'
import { TriggerControl } from '@hcengineering/server-core'
import serverCore, { TriggerControl } from '@hcengineering/server-core'
import setting from '@hcengineering/setting'
import { workbenchId } from '@hcengineering/workbench'
import view from '@hcengineering/view'
import {
AddCollaboratorsEvent,
@@ -59,6 +61,7 @@ import { getEmployee, getPersonSpaces } from '@hcengineering/server-contact'
import contact, { Employee, formatName, Person } from '@hcengineering/contact'
import communication, { Direct } from '@hcengineering/communication'
import { CardPeer } from '@hcengineering/communication-types'
import { getMetadata } from '@hcengineering/platform'
async function OnAttribute (ctx: TxCreateDoc<AnyAttribute>[], control: TriggerControl): Promise<Tx[]> {
const attr = TxProcessor.createDoc2Doc(ctx[0])
@@ -882,10 +885,22 @@ export async function CardTextPresenter (doc: Doc): Promise<string> {
return card.title
}
export async function CardHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
const card = doc as Card
const front = control.branding?.front ?? getMetadata(serverCore.metadata.FrontUrl) ?? ''
const path = `${workbenchId}/${control.workspace.url}/${cardId}/${card._id}`
const link = concatLink(front, path)
return `<a href='${link}'>${card.title}</a>`
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default async () => ({
function: {
CardTextPresenter
CardTextPresenter,
CardHTMLPresenter
},
trigger: {
OnAttribute,
+2 -1
View File
@@ -31,7 +31,8 @@ export default plugin(serverCardId, {
CommunicationEnabled: '' as Metadata<boolean>
},
function: {
CardTextPresenter: '' as Resource<Presenter>
CardTextPresenter: '' as Resource<Presenter>,
CardHTMLPresenter: '' as Resource<Presenter>
},
trigger: {
OnAttribute: '' as Resource<TriggerFunc>,