mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-25 09:13:07 +03:00
Fix telegram notifications (#3257)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
7233d15ba0
commit
0298ff1c8d
@ -327,7 +327,7 @@ export function createModel (builder: Builder): void {
|
|||||||
})
|
})
|
||||||
|
|
||||||
builder.mixin(contact.class.Channel, core.class.Class, notification.mixin.ClassCollaborators, {
|
builder.mixin(contact.class.Channel, core.class.Class, notification.mixin.ClassCollaborators, {
|
||||||
fields: []
|
fields: ['modifiedBy']
|
||||||
})
|
})
|
||||||
|
|
||||||
builder.mixin(contact.class.Channel, core.class.Class, notification.mixin.NotificationObjectPresenter, {
|
builder.mixin(contact.class.Channel, core.class.Class, notification.mixin.NotificationObjectPresenter, {
|
||||||
|
@ -354,7 +354,7 @@ export abstract class TxProcessor implements WithTx {
|
|||||||
modifiedBy: tx.modifiedBy,
|
modifiedBy: tx.modifiedBy,
|
||||||
modifiedOn: tx.modifiedOn,
|
modifiedOn: tx.modifiedOn,
|
||||||
createdBy: tx.createdBy ?? tx.modifiedBy,
|
createdBy: tx.createdBy ?? tx.modifiedBy,
|
||||||
createOn: tx.createOn ?? tx.modifiedBy
|
createOn: tx.createOn ?? tx.modifiedOn
|
||||||
} as T
|
} as T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +126,8 @@ export async function IsIncomingMessage (
|
|||||||
type: NotificationType,
|
type: NotificationType,
|
||||||
control: TriggerControl
|
control: TriggerControl
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const message = doc as Message
|
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<Message>)
|
||||||
return message.incoming
|
return message.incoming && message.sendOn > (doc.createOn ?? doc.modifiedOn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||||
|
@ -495,6 +495,7 @@ async function createCollabDocInfo (
|
|||||||
isSpace: boolean = false
|
isSpace: boolean = false
|
||||||
): Promise<Tx[]> {
|
): Promise<Tx[]> {
|
||||||
let res: Tx[] = []
|
let res: Tx[] = []
|
||||||
|
if (originTx.space === core.space.DerivedTx) return res
|
||||||
const targets = new Set(collaborators)
|
const targets = new Set(collaborators)
|
||||||
const docUpdates = await control.findAll(notification.class.DocUpdates, { attachedTo: object._id })
|
const docUpdates = await control.findAll(notification.class.DocUpdates, { attachedTo: object._id })
|
||||||
for (const target of targets) {
|
for (const target of targets) {
|
||||||
@ -578,11 +579,9 @@ export async function collaboratorDocHandler (
|
|||||||
): Promise<Tx[]> {
|
): Promise<Tx[]> {
|
||||||
switch (tx._class) {
|
switch (tx._class) {
|
||||||
case core.class.TxCreateDoc:
|
case core.class.TxCreateDoc:
|
||||||
if (tx.space === core.space.DerivedTx) return []
|
|
||||||
return await createCollaboratorDoc(tx as TxCreateDoc<Doc>, control, originTx ?? tx)
|
return await createCollaboratorDoc(tx as TxCreateDoc<Doc>, control, originTx ?? tx)
|
||||||
case core.class.TxUpdateDoc:
|
case core.class.TxUpdateDoc:
|
||||||
case core.class.TxMixin: {
|
case core.class.TxMixin: {
|
||||||
if (tx.space === core.space.DerivedTx) return []
|
|
||||||
let res = await updateCollaboratorDoc(tx as TxUpdateDoc<Doc>, control, originTx ?? tx)
|
let res = await updateCollaboratorDoc(tx as TxUpdateDoc<Doc>, control, originTx ?? tx)
|
||||||
res = res.concat(await updateCollaboratorsMixin(tx as TxMixin<Doc, Collaborators>, control, originTx ?? tx))
|
res = res.concat(await updateCollaboratorsMixin(tx as TxMixin<Doc, Collaborators>, control, originTx ?? tx))
|
||||||
return res
|
return res
|
||||||
|
@ -124,8 +124,8 @@ export async function IsIncomingMessage (
|
|||||||
type: NotificationType,
|
type: NotificationType,
|
||||||
control: TriggerControl
|
control: TriggerControl
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const message = doc as TelegramMessage
|
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<TelegramMessage>)
|
||||||
return message.incoming
|
return message.incoming && message.sendOn > (doc.createOn ?? doc.modifiedOn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||||
|
Loading…
Reference in New Issue
Block a user