mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 17:05:16 +03:00
UBERF-8612: Fix modifiedOn for apply tx (#7292)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
7295386e91
commit
e88519257b
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import core, { MeasureContext, Tx, systemAccountEmail, type SessionData } from '@hcengineering/core'
|
import core, { MeasureContext, Tx, systemAccountEmail, type SessionData, type TxApplyIf } from '@hcengineering/core'
|
||||||
import { BaseMiddleware, Middleware, TxMiddlewareResult, type PipelineContext } from '@hcengineering/server-core'
|
import { BaseMiddleware, Middleware, TxMiddlewareResult, type PipelineContext } from '@hcengineering/server-core'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,12 +33,20 @@ export class ModifiedMiddleware extends BaseMiddleware implements Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tx (ctx: MeasureContext<SessionData>, txes: Tx[]): Promise<TxMiddlewareResult> {
|
tx (ctx: MeasureContext<SessionData>, txes: Tx[]): Promise<TxMiddlewareResult> {
|
||||||
for (const tx of txes) {
|
const now = Date.now()
|
||||||
|
function updateTx (tx: Tx): void {
|
||||||
if (tx.modifiedBy !== core.account.System && ctx.contextData.userEmail !== systemAccountEmail) {
|
if (tx.modifiedBy !== core.account.System && ctx.contextData.userEmail !== systemAccountEmail) {
|
||||||
tx.modifiedOn = Date.now()
|
tx.modifiedOn = now
|
||||||
tx.createdOn = tx.modifiedOn
|
tx.createdOn = tx.modifiedOn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const tx of txes) {
|
||||||
|
updateTx(tx)
|
||||||
|
if (tx._class === core.class.TxApplyIf) {
|
||||||
|
const atx = tx as TxApplyIf
|
||||||
|
atx.txes.forEach(updateTx)
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.provideTx(ctx, txes)
|
return this.provideTx(ctx, txes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user