Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBER-902: Fix transactions #3748

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/core/src/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
13 changes: 12 additions & 1 deletion server-plugins/notification-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down