mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 11:50:56 +00:00
TSK-1153: Fix server model load exceptions (#2967)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
12404949d0
commit
93dd4489d7
@ -45,6 +45,7 @@ import core, {
|
||||
Tx,
|
||||
TxCollectionCUD,
|
||||
TxCreateDoc,
|
||||
TxCUD,
|
||||
TxMixin,
|
||||
TxProcessor,
|
||||
TxRemoveDoc,
|
||||
@ -987,12 +988,24 @@ class MongoTxAdapter extends MongoAdapterBase implements TxAdapter {
|
||||
.sort({ _id: 1 })
|
||||
.toArray()
|
||||
// We need to put all core.account.System transactions first
|
||||
const systemTr: Tx[] = []
|
||||
const systemTx: Tx[] = []
|
||||
const userTx: Tx[] = []
|
||||
|
||||
model.forEach((tx) => (tx.modifiedBy === core.account.System ? systemTr : userTx).push(tx))
|
||||
// Ignore Employee accounts.
|
||||
function isEmployeeAccount (tx: Tx): boolean {
|
||||
return (
|
||||
(tx._class === core.class.TxCreateDoc ||
|
||||
tx._class === core.class.TxUpdateDoc ||
|
||||
tx._class === core.class.TxRemoveDoc) &&
|
||||
(tx as TxCUD<Doc>).objectClass === 'contact:class:EmployeeAccount'
|
||||
)
|
||||
}
|
||||
|
||||
return systemTr.concat(userTx)
|
||||
model.forEach((tx) =>
|
||||
(tx.modifiedBy === core.account.System && !isEmployeeAccount(tx) ? systemTx : userTx).push(tx)
|
||||
)
|
||||
|
||||
return systemTx.concat(userTx)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user