mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-25 01:04:55 +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, {
|
||||
fields: []
|
||||
fields: ['modifiedBy']
|
||||
})
|
||||
|
||||
builder.mixin(contact.class.Channel, core.class.Class, notification.mixin.NotificationObjectPresenter, {
|
||||
|
@ -354,7 +354,7 @@ export abstract class TxProcessor implements WithTx {
|
||||
modifiedBy: tx.modifiedBy,
|
||||
modifiedOn: tx.modifiedOn,
|
||||
createdBy: tx.createdBy ?? tx.modifiedBy,
|
||||
createOn: tx.createOn ?? tx.modifiedBy
|
||||
createOn: tx.createOn ?? tx.modifiedOn
|
||||
} as T
|
||||
}
|
||||
|
||||
|
@ -126,8 +126,8 @@ export async function IsIncomingMessage (
|
||||
type: NotificationType,
|
||||
control: TriggerControl
|
||||
): Promise<boolean> {
|
||||
const message = doc as Message
|
||||
return message.incoming
|
||||
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<Message>)
|
||||
return message.incoming && message.sendOn > (doc.createOn ?? doc.modifiedOn)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
|
@ -495,6 +495,7 @@ async function createCollabDocInfo (
|
||||
isSpace: boolean = false
|
||||
): Promise<Tx[]> {
|
||||
let res: Tx[] = []
|
||||
if (originTx.space === core.space.DerivedTx) return res
|
||||
const targets = new Set(collaborators)
|
||||
const docUpdates = await control.findAll(notification.class.DocUpdates, { attachedTo: object._id })
|
||||
for (const target of targets) {
|
||||
@ -578,11 +579,9 @@ export async function collaboratorDocHandler (
|
||||
): Promise<Tx[]> {
|
||||
switch (tx._class) {
|
||||
case core.class.TxCreateDoc:
|
||||
if (tx.space === core.space.DerivedTx) return []
|
||||
return await createCollaboratorDoc(tx as TxCreateDoc<Doc>, control, originTx ?? tx)
|
||||
case core.class.TxUpdateDoc:
|
||||
case core.class.TxMixin: {
|
||||
if (tx.space === core.space.DerivedTx) return []
|
||||
let res = await updateCollaboratorDoc(tx as TxUpdateDoc<Doc>, control, originTx ?? tx)
|
||||
res = res.concat(await updateCollaboratorsMixin(tx as TxMixin<Doc, Collaborators>, control, originTx ?? tx))
|
||||
return res
|
||||
|
@ -124,8 +124,8 @@ export async function IsIncomingMessage (
|
||||
type: NotificationType,
|
||||
control: TriggerControl
|
||||
): Promise<boolean> {
|
||||
const message = doc as TelegramMessage
|
||||
return message.incoming
|
||||
const message = TxProcessor.createDoc2Doc(TxProcessor.extractTx(tx) as TxCreateDoc<TelegramMessage>)
|
||||
return message.incoming && message.sendOn > (doc.createOn ?? doc.modifiedOn)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
|
Loading…
Reference in New Issue
Block a user