mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 21:27:46 +02:00
UBER-174: Introduce createOn every there (#3222)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -13,16 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, {
|
||||
AttachedDoc,
|
||||
Doc,
|
||||
MeasureContext,
|
||||
ServerStorage,
|
||||
Timestamp,
|
||||
Tx,
|
||||
TxCollectionCUD,
|
||||
TxCreateDoc
|
||||
} from '@hcengineering/core'
|
||||
import core, { MeasureContext, ServerStorage, Tx } from '@hcengineering/core'
|
||||
import { BroadcastFunc, Middleware, SessionContext, TxMiddlewareResult } from '@hcengineering/server-core'
|
||||
import { BaseMiddleware } from './base'
|
||||
|
||||
@@ -46,24 +37,7 @@ export class ModifiedMiddleware extends BaseMiddleware implements Middleware {
|
||||
async tx (ctx: SessionContext, tx: Tx): Promise<TxMiddlewareResult> {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
tx.createOn = tx.createOn ?? tx.modifiedOn
|
||||
}
|
||||
return await this.provideTx(ctx, tx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user