Skip to content

Commit e885192

Browse files
authored
UBERF-8612: Fix modifiedOn for apply tx (#7292)
Signed-off-by: Andrey Sobolev <[email protected]>
1 parent 7295386 commit e885192

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

server/middleware/src/modified.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414
//
1515

16-
import core, { MeasureContext, Tx, systemAccountEmail, type SessionData } from '@hcengineering/core'
16+
import core, { MeasureContext, Tx, systemAccountEmail, type SessionData, type TxApplyIf } from '@hcengineering/core'
1717
import { BaseMiddleware, Middleware, TxMiddlewareResult, type PipelineContext } from '@hcengineering/server-core'
1818

1919
/**
@@ -33,12 +33,20 @@ export class ModifiedMiddleware extends BaseMiddleware implements Middleware {
3333
}
3434

3535
tx (ctx: MeasureContext<SessionData>, txes: Tx[]): Promise<TxMiddlewareResult> {
36-
for (const tx of txes) {
36+
const now = Date.now()
37+
function updateTx (tx: Tx): void {
3738
if (tx.modifiedBy !== core.account.System && ctx.contextData.userEmail !== systemAccountEmail) {
38-
tx.modifiedOn = Date.now()
39+
tx.modifiedOn = now
3940
tx.createdOn = tx.modifiedOn
4041
}
4142
}
43+
for (const tx of txes) {
44+
updateTx(tx)
45+
if (tx._class === core.class.TxApplyIf) {
46+
const atx = tx as TxApplyIf
47+
atx.txes.forEach(updateTx)
48+
}
49+
}
4250
return this.provideTx(ctx, txes)
4351
}
4452
}

0 commit comments

Comments
 (0)