mirror of
https://github.com/hcengineering/platform.git
synced 2025-03-19 21:31:30 +00:00
Try to fix double notification contexts for pull requests (#6300)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
2e59df60da
commit
87cea20887
@ -323,8 +323,7 @@ export async function pushInboxNotifications (
|
|||||||
modifiedOn: Timestamp,
|
modifiedOn: Timestamp,
|
||||||
shouldUpdateTimestamp = true
|
shouldUpdateTimestamp = true
|
||||||
): Promise<TxCreateDoc<InboxNotification> | undefined> {
|
): Promise<TxCreateDoc<InboxNotification> | undefined> {
|
||||||
const context = contexts.find((context) => context.user === receiver._id && context.objectId === objectId)
|
const context = getDocNotifyContext(control, contexts, objectId, receiver._id)
|
||||||
|
|
||||||
let docNotifyContextId: Ref<DocNotifyContext>
|
let docNotifyContextId: Ref<DocNotifyContext>
|
||||||
|
|
||||||
if (context === undefined) {
|
if (context === undefined) {
|
||||||
@ -732,9 +731,7 @@ export async function getNotificationTxes (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const context = docNotifyContexts.find(
|
const context = getDocNotifyContext(control, docNotifyContexts, message.attachedTo, receiver.account._id)
|
||||||
(context) => context.objectId === message.attachedTo && context.user === receiver.account._id
|
|
||||||
)
|
|
||||||
|
|
||||||
if (context === undefined) {
|
if (context === undefined) {
|
||||||
await createNotifyContext(
|
await createNotifyContext(
|
||||||
@ -1584,7 +1581,7 @@ async function updateCollaborators (ctx: MeasureContext, control: TriggerControl
|
|||||||
for (const addedUser of addedInfo) {
|
for (const addedUser of addedInfo) {
|
||||||
const info = toReceiverInfo(hierarchy, addedUser)
|
const info = toReceiverInfo(hierarchy, addedUser)
|
||||||
if (info === undefined) continue
|
if (info === undefined) continue
|
||||||
const context = contexts.find(({ user }) => user === info._id)
|
const context = getDocNotifyContext(control, contexts, objectId, info._id)
|
||||||
if (context !== undefined) continue
|
if (context !== undefined) continue
|
||||||
await createNotifyContext(control, objectId, objectClass, objectSpace, info)
|
await createNotifyContext(control, objectId, objectClass, objectSpace, info)
|
||||||
}
|
}
|
||||||
@ -1701,6 +1698,31 @@ export async function getCollaborators (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDocNotifyContext (
|
||||||
|
control: TriggerControl,
|
||||||
|
contexts: DocNotifyContext[],
|
||||||
|
objectId: Ref<Doc>,
|
||||||
|
user: Ref<Account>
|
||||||
|
): DocNotifyContext | undefined {
|
||||||
|
const context = contexts.find((it) => it.objectId === objectId && it.user === user)
|
||||||
|
|
||||||
|
if (context !== undefined) {
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
const txes = [...control.txes.apply, ...control.txes.result, ...control.operationContext.derived.txes] as TxCUD<Doc>[]
|
||||||
|
|
||||||
|
for (const tx of txes) {
|
||||||
|
if (tx._class === core.class.TxCreateDoc && tx.objectClass === notification.class.DocNotifyContext) {
|
||||||
|
const doc = TxProcessor.createDoc2Doc(tx as TxCreateDoc<DocNotifyContext>)
|
||||||
|
if (doc.objectId === objectId && doc.user === user) {
|
||||||
|
return doc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
async function OnActivityMessageRemove (message: ActivityMessage, control: TriggerControl): Promise<Tx[]> {
|
async function OnActivityMessageRemove (message: ActivityMessage, control: TriggerControl): Promise<Tx[]> {
|
||||||
if (control.removedMap.has(message.attachedTo)) {
|
if (control.removedMap.has(message.attachedTo)) {
|
||||||
return []
|
return []
|
||||||
|
Loading…
Reference in New Issue
Block a user