UBER-902: Fix transactions (#3748)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-09-27 22:21:06 +07:00 committed by GitHub
parent 41e5e047d9
commit f0112d06bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -237,6 +237,21 @@ export class TxOperations implements Omit<Client, 'notify'> {
if (hierarchy.isMixin(it[0])) {
await ops.updateMixin(doc._id, baseClass, doc.space, it[0], it[1], modifiedOn, modifiedBy)
} else {
if (hierarchy.isDerived(it[0], core.class.AttachedDoc)) {
const adoc = doc as unknown as AttachedDoc
return await this.updateCollection(
it[0],
doc.space,
adoc._id,
adoc.attachedTo,
adoc.attachedToClass,
adoc.collection,
it[1],
retrieve,
modifiedOn,
modifiedBy
)
}
await ops.updateDoc(it[0], doc.space, doc._id, it[1], retrieve, modifiedOn, modifiedBy)
}
}

View File

@ -428,8 +428,19 @@ async function isShouldNotify (
let allowed = false
const emailTypes: NotificationType[] = []
const types = await getMatchedTypes(control, tx, originTx, isOwn, isSpace)
const personAccount = await getPersonAccountById(user, control)
for (const type of types) {
if (type.allowedForAuthor !== true && tx.modifiedBy === user) continue
const modifiedAccount = await getPersonAccountById(tx.modifiedBy, control)
if (
type.allowedForAuthor !== true &&
(tx.modifiedBy === user ||
// Also check if we have different account for same user.
(personAccount?.person !== undefined && personAccount?.person === modifiedAccount?.person))
) {
continue
}
if (control.hierarchy.hasMixin(type, serverNotification.mixin.TypeMatch)) {
const mixin = control.hierarchy.as(type, serverNotification.mixin.TypeMatch)
if (mixin.func !== undefined) {