mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-17 18:05:42 +02:00
Card email notifications (#10509)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Generated
+3
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user