TSK-1046 Gmail/telegram messages collaborators TSK-1097 Inbox scroll (#2928)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2023-04-10 15:15:00 +06:00
committed by GitHub
parent d353c0e42d
commit 2c714e33fe
27 changed files with 369 additions and 63 deletions
+52 -1
View File
@@ -15,6 +15,7 @@
//
import contact, {
Channel,
Contact,
contactId,
Employee,
@@ -38,6 +39,7 @@ import core, {
TxUpdateDoc,
updateAttribute
} from '@hcengineering/core'
import notification, { Collaborators } from '@hcengineering/notification'
import { getMetadata } from '@hcengineering/platform'
import serverCore, { AsyncTriggerControl, TriggerControl } from '@hcengineering/server-core'
import { workbenchId } from '@hcengineering/workbench'
@@ -275,6 +277,54 @@ export async function OnEmployeeUpdate (tx: Tx, control: AsyncTriggerControl): P
return result
}
/**
* @public
*/
export async function OnChannelUpdate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
if (tx._class !== core.class.TxUpdateDoc) {
return []
}
const uTx = tx as TxUpdateDoc<Channel>
if (!control.hierarchy.isDerived(uTx.objectClass, contact.class.Channel)) {
return []
}
const result: Tx[] = []
if (uTx.operations.$inc?.items !== undefined) {
const doc = (await control.findAll(uTx.objectClass, { _id: uTx.objectId }, { limit: 1 }))[0]
if (doc !== undefined) {
if (control.hierarchy.hasMixin(doc, notification.mixin.Collaborators)) {
const collab = control.hierarchy.as(doc, notification.mixin.Collaborators) as Doc as Collaborators
if (collab.collaborators.includes(tx.modifiedBy)) {
result.push(
control.txFactory.createTxMixin(doc._id, doc._class, doc.space, notification.mixin.Collaborators, {
$push: {
collaborators: tx.modifiedBy
}
})
)
}
} else {
control.txFactory.createTxMixin<Doc, Collaborators>(
doc._id,
doc._class,
doc.space,
notification.mixin.Collaborators,
{
collaborators: [tx.modifiedBy]
}
)
result.push()
}
}
}
return result
}
/**
* @public
*/
@@ -317,7 +367,8 @@ export function organizationTextPresenter (doc: Doc): string {
export default async () => ({
trigger: {
OnContactDelete,
OnEmployeeUpdate
OnEmployeeUpdate,
OnChannelUpdate
},
function: {
PersonHTMLPresenter: personHTMLPresenter,