mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-30 05:25:00 +02:00
Employee email channel (#2711)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -39,24 +39,26 @@ export class ModifiedMiddleware extends BaseMiddleware implements Middleware {
|
||||
}
|
||||
|
||||
async tx (ctx: SessionContext, tx: Tx): Promise<TxMiddlewareResult> {
|
||||
tx.modifiedOn = Date.now()
|
||||
if (this.storage.hierarchy.isDerived(tx._class, core.class.TxCreateDoc)) {
|
||||
const createTx = tx as TxCreateDoc<Doc & { createOn: Timestamp }>
|
||||
const hasCreateOn = this.storage.hierarchy.findAttribute(createTx.objectClass, 'createOn')
|
||||
if (hasCreateOn !== undefined) {
|
||||
createTx.attributes.createOn = tx.modifiedOn
|
||||
}
|
||||
}
|
||||
if (this.storage.hierarchy.isDerived(tx._class, core.class.TxCollectionCUD)) {
|
||||
const coltx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
coltx.tx.modifiedOn = tx.modifiedOn
|
||||
if (this.storage.hierarchy.isDerived(coltx.tx._class, core.class.TxCreateDoc)) {
|
||||
const createTx = coltx.tx as TxCreateDoc<AttachedDoc & { createOn: Timestamp }>
|
||||
if (tx.modifiedBy !== core.account.System) {
|
||||
tx.modifiedOn = Date.now()
|
||||
if (this.storage.hierarchy.isDerived(tx._class, core.class.TxCreateDoc)) {
|
||||
const createTx = tx as TxCreateDoc<Doc & { createOn: Timestamp }>
|
||||
const hasCreateOn = this.storage.hierarchy.findAttribute(createTx.objectClass, 'createOn')
|
||||
if (hasCreateOn !== undefined) {
|
||||
createTx.attributes.createOn = tx.modifiedOn
|
||||
}
|
||||
}
|
||||
if (this.storage.hierarchy.isDerived(tx._class, core.class.TxCollectionCUD)) {
|
||||
const coltx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||
coltx.tx.modifiedOn = tx.modifiedOn
|
||||
if (this.storage.hierarchy.isDerived(coltx.tx._class, core.class.TxCreateDoc)) {
|
||||
const createTx = coltx.tx as TxCreateDoc<AttachedDoc & { createOn: Timestamp }>
|
||||
const hasCreateOn = this.storage.hierarchy.findAttribute(createTx.objectClass, 'createOn')
|
||||
if (hasCreateOn !== undefined) {
|
||||
createTx.attributes.createOn = tx.modifiedOn
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return await this.provideTx(ctx, tx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user