Skip to content

Commit

Permalink
UBER-902: Fix transactions
Browse files Browse the repository at this point in the history
* Fix activity for github
* Fix notifications

Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo committed Sep 27, 2023
1 parent 41e5e04 commit 29db52e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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

0 comments on commit 29db52e

Please sign in to comment.