mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-15 04:49:00 +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,
|
Tx,
|
||||||
TxCollectionCUD,
|
TxCollectionCUD,
|
||||||
TxCreateDoc,
|
TxCreateDoc,
|
||||||
|
TxCUD,
|
||||||
TxMixin,
|
TxMixin,
|
||||||
TxProcessor,
|
TxProcessor,
|
||||||
TxRemoveDoc,
|
TxRemoveDoc,
|
||||||
@ -987,12 +988,24 @@ class MongoTxAdapter extends MongoAdapterBase implements TxAdapter {
|
|||||||
.sort({ _id: 1 })
|
.sort({ _id: 1 })
|
||||||
.toArray()
|
.toArray()
|
||||||
// We need to put all core.account.System transactions first
|
// We need to put all core.account.System transactions first
|
||||||
const systemTr: Tx[] = []
|
const systemTx: Tx[] = []
|
||||||
const userTx: 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