Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions models/gmail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 29 additions & 0 deletions models/gmail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
})
Expand Down
4 changes: 3 additions & 1 deletion models/gmail/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions models/server-chunter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ 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(
chunter.ids.ChannelNotification,
notification.class.NotificationType,
serverNotification.mixin.TypeMatch,
{
func: serverChunter.function.IsChannelMessagee
func: serverChunter.function.IsChannelMessage
}
)
}
4 changes: 3 additions & 1 deletion models/server-gmail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 6 additions & 0 deletions models/server-gmail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
})
}
4 changes: 3 additions & 1 deletion models/server-telegram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
11 changes: 11 additions & 0 deletions models/server-telegram/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
}
)
}
2 changes: 2 additions & 0 deletions models/telegram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 29 additions & 0 deletions models/telegram/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
})
Expand Down
7 changes: 5 additions & 2 deletions models/telegram/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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>,
Expand Down
1 change: 1 addition & 0 deletions plugins/gmail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions plugins/gmail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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>
},
Expand Down
1 change: 1 addition & 0 deletions plugins/telegram-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"Content": "Content",
"Incoming": "Incoming",
"Messages": "Messages",
"NewMessage": "New message",
"Telegram": "Telegram",
"TelegramIntegrationDesc": "Use telegram integration",
"Status": "Status",
Expand Down
1 change: 1 addition & 0 deletions plugins/telegram-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"Content": "Содержимое",
"Incoming": "Входящее",
"Messages": "Сообщения",
"NewMessage": "Новое сообщение",
"Telegram": "Telegram",
"TelegramIntegrationDesc": "Подключить Telegram",
"Status": "Статус",
Expand Down
1 change: 1 addition & 0 deletions plugins/telegram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 4 additions & 0 deletions plugins/telegram/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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>>,
Expand Down
8 changes: 4 additions & 4 deletions server-plugins/chunter-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -221,7 +221,7 @@ export async function IsDirectMessagee (
/**
* @public
*/
export async function IsChannelMessagee (
export async function IsChannelMessage (
tx: Tx,
doc: Doc,
user: Ref<Account>,
Expand All @@ -241,7 +241,7 @@ export default async () => ({
CommentRemove,
ChannelHTMLPresenter: channelHTMLPresenter,
ChannelTextPresenter: channelTextPresenter,
IsDirectMessagee,
IsChannelMessagee
IsDirectMessage,
IsChannelMessage
}
})
4 changes: 2 additions & 2 deletions server-plugins/chunter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
18 changes: 17 additions & 1 deletion server-plugins/gmail-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import contact, { Channel } from '@hcengineering/contact'
import {
Account,
Class,
Doc,
DocumentQuery,
Expand All @@ -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
Expand Down Expand Up @@ -110,9 +111,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: {
Expand Down
1 change: 1 addition & 0 deletions server-plugins/gmail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 2 additions & 0 deletions server-plugins/gmail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

/**
Expand All @@ -32,6 +33,7 @@ export default plugin(serverGmailId, {
OnMessageCreate: '' as Resource<TriggerFunc>
},
function: {
IsIncomingMessage: '' as TypeMatchFunc,
FindMessages: '' as Resource<
(
doc: Doc,
Expand Down