UBER-220 TG/GMAIL new message inbox notifications (#3246)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-05-24 13:09:11 +06:00 committed by GitHub
parent 30a0413dc3
commit d8e69eb6bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 153 additions and 15 deletions

View File

@ -36,6 +36,8 @@
"@hcengineering/gmail-resources": "^0.6.0",
"@hcengineering/model-attachment": "^0.6.0",
"@hcengineering/model-view": "^0.6.0",
"@hcengineering/notification": "^0.6.12",
"@hcengineering/model-notification": "^0.6.0",
"@hcengineering/view": "^0.6.6",
"@hcengineering/setting": "^0.6.7",
"@hcengineering/ui": "^0.6.8"

View File

@ -31,6 +31,7 @@ import {
import attachment from '@hcengineering/model-attachment'
import contact from '@hcengineering/model-contact'
import core, { TAttachedDoc, TDoc } from '@hcengineering/model-core'
import notification from '@hcengineering/model-notification'
import view, { createAction } from '@hcengineering/model-view'
import setting from '@hcengineering/setting'
import gmail from './plugin'
@ -213,6 +214,34 @@ export function createModel (builder: Builder): void {
gmail.action.WriteEmail
)
builder.createDoc(
notification.class.NotificationGroup,
core.space.Model,
{
label: gmail.string.Email,
icon: contact.icon.Email
},
gmail.ids.EmailNotificationGroup
)
builder.createDoc(
notification.class.NotificationType,
core.space.Model,
{
label: gmail.string.NewMessage,
generated: false,
hidden: false,
txClasses: [core.class.TxCreateDoc],
objectClass: gmail.class.Message,
group: gmail.ids.EmailNotificationGroup,
allowedForAuthor: true,
providers: {
[notification.providers.PlatformNotification]: true
}
},
gmail.ids.EmailNotification
)
builder.mixin(gmail.class.Message, core.class.Class, core.mixin.FullTextSearchContext, {
parentPropagate: false
})

View File

@ -21,6 +21,7 @@ import gmail from '@hcengineering/gmail-resources/src/plugin'
import type { AnyComponent } from '@hcengineering/ui'
import type { TxViewlet } from '@hcengineering/activity'
import { Action } from '@hcengineering/view'
import { NotificationGroup } from '@hcengineering/notification'
export default mergeIds(gmailId, gmail, {
action: {
@ -42,7 +43,8 @@ export default mergeIds(gmailId, gmail, {
ConfigDescription: '' as IntlString
},
ids: {
TxSharedCreate: '' as Ref<TxViewlet>
TxSharedCreate: '' as Ref<TxViewlet>,
EmailNotificationGroup: '' as Ref<NotificationGroup>
},
activity: {
TxSharedCreate: '' as AnyComponent,

View File

@ -46,7 +46,7 @@ export function createModel (builder: Builder): void {
})
builder.mixin(chunter.ids.DMNotification, notification.class.NotificationType, serverNotification.mixin.TypeMatch, {
func: serverChunter.function.IsDirectMessagee
func: serverChunter.function.IsDirectMessage
})
builder.mixin(
@ -54,7 +54,7 @@ export function createModel (builder: Builder): void {
notification.class.NotificationType,
serverNotification.mixin.TypeMatch,
{
func: serverChunter.function.IsChannelMessagee
func: serverChunter.function.IsChannelMessage
}
)
}

View File

@ -31,6 +31,8 @@
"@hcengineering/contact": "^0.6.16",
"@hcengineering/platform": "^0.6.9",
"@hcengineering/server-gmail": "^0.6.0",
"@hcengineering/server-core": "^0.6.1"
"@hcengineering/server-core": "^0.6.1",
"@hcengineering/notification": "^0.6.12",
"@hcengineering/server-notification": "^0.6.0"
}
}

View File

@ -18,8 +18,10 @@ import { Builder } from '@hcengineering/model'
import contact from '@hcengineering/contact'
import core, { Class, Doc } from '@hcengineering/core'
import gmail from '@hcengineering/gmail'
import notification from '@hcengineering/notification'
import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core'
import serverGmail from '@hcengineering/server-gmail'
import serverNotification from '@hcengineering/server-notification'
export { serverGmailId } from '@hcengineering/server-gmail'
export function createModel (builder: Builder): void {
@ -40,4 +42,8 @@ export function createModel (builder: Builder): void {
'tx._class': core.class.TxCreateDoc
}
})
builder.mixin(gmail.ids.EmailNotification, notification.class.NotificationType, serverNotification.mixin.TypeMatch, {
func: serverGmail.function.IsIncomingMessage
})
}

View File

@ -31,6 +31,8 @@
"@hcengineering/platform": "^0.6.9",
"@hcengineering/server-telegram": "^0.6.0",
"@hcengineering/server-core": "^0.6.1",
"@hcengineering/telegram": "^0.6.9"
"@hcengineering/telegram": "^0.6.9",
"@hcengineering/notification": "^0.6.12",
"@hcengineering/server-notification": "^0.6.0"
}
}

View File

@ -20,6 +20,8 @@ import core, { Class, Doc } from '@hcengineering/core'
import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core'
import serverTelegram from '@hcengineering/server-telegram'
import telegram from '@hcengineering/telegram'
import notification from '@hcengineering/notification'
import serverNotification from '@hcengineering/server-notification'
export { serverTelegramId } from '@hcengineering/server-telegram'
@ -41,4 +43,13 @@ export function createModel (builder: Builder): void {
'tx._class': core.class.TxCreateDoc
}
})
builder.mixin(
telegram.ids.NewMessageNotification,
notification.class.NotificationType,
serverNotification.mixin.TypeMatch,
{
func: serverTelegram.function.IsIncomingMessage
}
)
}

View File

@ -31,6 +31,8 @@
"@hcengineering/platform": "^0.6.9",
"@hcengineering/model-core": "^0.6.0",
"@hcengineering/model-attachment": "^0.6.0",
"@hcengineering/model-notification": "^0.6.0",
"@hcengineering/notification": "^0.6.12",
"@hcengineering/model-contact": "^0.6.1",
"@hcengineering/view": "^0.6.6",
"@hcengineering/contact": "^0.6.16",

View File

@ -41,6 +41,7 @@ import type {
import templates from '@hcengineering/templates'
import view from '@hcengineering/view'
import telegram from './plugin'
import notification from '@hcengineering/model-notification'
export { telegramId } from '@hcengineering/telegram'
export { telegramOperation } from './migration'
@ -175,6 +176,34 @@ export function createModel (builder: Builder): void {
telegram.ids.TxSharedCreate
)
builder.createDoc(
notification.class.NotificationGroup,
core.space.Model,
{
label: telegram.string.Telegram,
icon: contact.icon.Telegram
},
telegram.ids.NotificationGroup
)
builder.createDoc(
notification.class.NotificationType,
core.space.Model,
{
label: telegram.string.NewMessage,
generated: false,
allowedForAuthor: true,
hidden: false,
txClasses: [core.class.TxCreateDoc],
objectClass: telegram.class.Message,
group: telegram.ids.NotificationGroup,
providers: {
[notification.providers.PlatformNotification]: true
}
},
telegram.ids.NewMessageNotification
)
builder.mixin(telegram.class.Message, core.class.Class, core.mixin.FullTextSearchContext, {
parentPropagate: false
})

View File

@ -21,6 +21,7 @@ import telegram from '@hcengineering/telegram-resources/src/plugin'
import type { AnyComponent } from '@hcengineering/ui'
import type { TxViewlet } from '@hcengineering/activity'
import { TemplateFieldFunc } from '@hcengineering/templates'
import { NotificationGroup } from '@hcengineering/notification'
export default mergeIds(telegramId, telegram, {
string: {
@ -33,11 +34,13 @@ export default mergeIds(telegramId, telegram, {
TelegramIntegrationDesc: '' as IntlString,
Status: '' as IntlString,
ConfigLabel: '' as IntlString,
ConfigDescription: '' as IntlString
ConfigDescription: '' as IntlString,
NewMessage: '' as IntlString
},
ids: {
TxMessage: '' as Ref<TxViewlet>,
TxSharedCreate: '' as Ref<TxViewlet>
TxSharedCreate: '' as Ref<TxViewlet>,
NotificationGroup: '' as Ref<NotificationGroup>
},
function: {
GetCurrentEmployeeTG: '' as Resource<TemplateFieldFunc>,

View File

@ -30,6 +30,7 @@
"@hcengineering/core": "^0.6.25",
"@hcengineering/ui": "^0.6.8",
"@hcengineering/contact": "^0.6.16",
"@hcengineering/notification": "^0.6.12",
"@hcengineering/setting": "^0.6.7"
},
"repository": "https://github.com/hcengineering/anticrm",

View File

@ -17,6 +17,7 @@ import { ChannelItem } from '@hcengineering/contact'
import type { Account, AttachedDoc, Class, Doc, Ref, Space, Timestamp } from '@hcengineering/core'
import type { Plugin } from '@hcengineering/platform'
import { Metadata, plugin } from '@hcengineering/platform'
import { NotificationType } from '@hcengineering/notification'
import type { Handler, IntegrationType } from '@hcengineering/setting'
import type { AnyComponent } from '@hcengineering/ui'
@ -99,6 +100,9 @@ export default plugin(gmailId, {
SharedMessages: '' as Ref<Class<SharedMessages>>,
SharedMessage: '' as Ref<Class<SharedMessage>>
},
ids: {
EmailNotification: '' as Ref<NotificationType>
},
space: {
Gmail: '' as Ref<Space>
},

View File

@ -19,6 +19,7 @@
"Content": "Content",
"Incoming": "Incoming",
"Messages": "Messages",
"NewMessage": "New message",
"Telegram": "Telegram",
"TelegramIntegrationDesc": "Use telegram integration",
"Status": "Status",

View File

@ -19,6 +19,7 @@
"Content": "Содержимое",
"Incoming": "Входящее",
"Messages": "Сообщения",
"NewMessage": "Новое сообщение",
"Telegram": "Telegram",
"TelegramIntegrationDesc": "Подключить Telegram",
"Status": "Статус",

View File

@ -30,6 +30,7 @@
"@hcengineering/core": "^0.6.25",
"@hcengineering/ui": "^0.6.8",
"@hcengineering/contact": "^0.6.16",
"@hcengineering/notification": "^0.6.12",
"@hcengineering/templates": "^0.6.4",
"@hcengineering/setting": "^0.6.7"
},

View File

@ -15,6 +15,7 @@
import { ChannelItem } from '@hcengineering/contact'
import type { AttachedDoc, Class, Doc, Ref, Space, Timestamp } from '@hcengineering/core'
import { NotificationType } from '@hcengineering/notification'
import type { Plugin } from '@hcengineering/platform'
import { Metadata, plugin } from '@hcengineering/platform'
import type { Handler, IntegrationType } from '@hcengineering/setting'
@ -75,6 +76,9 @@ export default plugin(telegramId, {
handler: {
DisconnectHandler: '' as Handler
},
ids: {
NewMessageNotification: '' as Ref<NotificationType>
},
class: {
Message: '' as Ref<Class<TelegramMessage>>,
NewMessage: '' as Ref<Class<NewTelegramMessage>>,

View File

@ -207,7 +207,7 @@ export async function ChunterTrigger (tx: Tx, control: TriggerControl): Promise<
/**
* @public
*/
export async function IsDirectMessagee (
export async function IsDirectMessage (
tx: Tx,
doc: Doc,
user: Ref<Account>,
@ -221,7 +221,7 @@ export async function IsDirectMessagee (
/**
* @public
*/
export async function IsChannelMessagee (
export async function IsChannelMessage (
tx: Tx,
doc: Doc,
user: Ref<Account>,
@ -241,7 +241,7 @@ export default async () => ({
CommentRemove,
ChannelHTMLPresenter: channelHTMLPresenter,
ChannelTextPresenter: channelTextPresenter,
IsDirectMessagee,
IsChannelMessagee
IsDirectMessage,
IsChannelMessage
}
})

View File

@ -45,7 +45,7 @@ export default plugin(serverChunterId, {
>,
ChannelHTMLPresenter: '' as Resource<Presenter>,
ChannelTextPresenter: '' as Resource<Presenter>,
IsDirectMessagee: '' as TypeMatchFunc,
IsChannelMessagee: '' as TypeMatchFunc
IsDirectMessage: '' as TypeMatchFunc,
IsChannelMessage: '' as TypeMatchFunc
}
})

View File

@ -15,6 +15,7 @@
import contact, { Channel } from '@hcengineering/contact'
import {
Account,
Class,
Doc,
DocumentQuery,
@ -29,7 +30,7 @@ import {
} from '@hcengineering/core'
import gmail, { Message } from '@hcengineering/gmail'
import { TriggerControl } from '@hcengineering/server-core'
import notification from '@hcengineering/notification'
import notification, { NotificationType } from '@hcengineering/notification'
/**
* @public
@ -115,9 +116,24 @@ export async function OnMessageCreate (tx: Tx, control: TriggerControl): Promise
return res
}
/**
* @public
*/
export async function IsIncomingMessage (
tx: Tx,
doc: Doc,
user: Ref<Account>,
type: NotificationType,
control: TriggerControl
): Promise<boolean> {
const message = doc as Message
return message.incoming
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default async () => ({
trigger: {
IsIncomingMessage,
OnMessageCreate
},
function: {

View File

@ -29,6 +29,7 @@
"dependencies": {
"@hcengineering/core": "^0.6.25",
"@hcengineering/platform": "^0.6.9",
"@hcengineering/server-notification": "^0.6.0",
"@hcengineering/server-core": "^0.6.1"
}
}

View File

@ -17,6 +17,7 @@
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
import type { Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform'
import { TypeMatchFunc } from '@hcengineering/server-notification'
import { TriggerFunc } from '@hcengineering/server-core'
/**
@ -32,6 +33,7 @@ export default plugin(serverGmailId, {
OnMessageCreate: '' as Resource<TriggerFunc>
},
function: {
IsIncomingMessage: '' as TypeMatchFunc,
FindMessages: '' as Resource<
(
doc: Doc,

View File

@ -15,6 +15,7 @@
import contact, { Channel } from '@hcengineering/contact'
import {
Account,
Class,
Doc,
DocumentQuery,
@ -29,7 +30,7 @@ import {
} from '@hcengineering/core'
import { TriggerControl } from '@hcengineering/server-core'
import telegram, { TelegramMessage } from '@hcengineering/telegram'
import notification from '@hcengineering/notification'
import notification, { NotificationType } from '@hcengineering/notification'
/**
* @public
@ -113,12 +114,27 @@ export async function OnMessageCreate (tx: Tx, control: TriggerControl): Promise
return res
}
/**
* @public
*/
export async function IsIncomingMessage (
tx: Tx,
doc: Doc,
user: Ref<Account>,
type: NotificationType,
control: TriggerControl
): Promise<boolean> {
const message = doc as TelegramMessage
return message.incoming
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default async () => ({
trigger: {
OnMessageCreate
},
function: {
IsIncomingMessage,
FindMessages
}
})

View File

@ -29,6 +29,7 @@
"dependencies": {
"@hcengineering/core": "^0.6.25",
"@hcengineering/platform": "^0.6.9",
"@hcengineering/server-notification": "^0.6.0",
"@hcengineering/server-core": "^0.6.1"
}
}

View File

@ -17,6 +17,7 @@
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
import type { Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform'
import { TypeMatchFunc } from '@hcengineering/server-notification'
import { TriggerFunc } from '@hcengineering/server-core'
/**
@ -32,6 +33,7 @@ export default plugin(serverTelegramId, {
OnMessageCreate: '' as Resource<TriggerFunc>
},
function: {
IsIncomingMessage: '' as TypeMatchFunc,
FindMessages: '' as Resource<
(
doc: Doc,