Skip to content

Commit

Permalink
UBERF-7604: Preparation for telegram notifications (#6123)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <[email protected]>
  • Loading branch information
kristina-fefelova authored Aug 6, 2024
1 parent d2b2cbf commit b997b0c
Show file tree
Hide file tree
Showing 49 changed files with 1,160 additions and 162 deletions.
12 changes: 10 additions & 2 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop-package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "desktop",
"version": "0.6.271",
"version": "0.6.266",
"main": "dist/main/electron.js",
"author": "Hardcore Engineering <[email protected]>",
"template": "@hcengineering/default-package",
Expand Down
2 changes: 1 addition & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hcengineering/desktop",
"version": "0.6.271",
"version": "0.6.266",
"main": "dist/main/electron.js",
"template": "@hcengineering/webpack-package",
"scripts": {
Expand Down
10 changes: 6 additions & 4 deletions dev/prod/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ export interface Config {
GITHUB_URL: string
SENTRY_DSN?: string
LOVE_ENDPOINT?: string
LIVEKIT_WS?: string,
SIGN_URL?: string,
PRINT_URL?: string,
POSTHOG_API_KEY?: string,
LIVEKIT_WS?: string
SIGN_URL?: string
PRINT_URL?: string
POSTHOG_API_KEY?: string
POSTHOG_HOST?: string
ANALYTICS_COLLECTOR_URL?:string
BRANDING_URL?: string
TELEGRAM_BOT_URL?: string

// Could be defined for dev environment
FRONT_URL?: string
Expand Down Expand Up @@ -301,6 +302,7 @@ export async function configurePlatform() {
setMetadata(presentation.metadata.FrontVersion, config.VERSION)
}
setMetadata(telegram.metadata.TelegramURL, config.TELEGRAM_URL ?? 'http://localhost:8086')
setMetadata(telegram.metadata.BotUrl, config.TELEGRAM_BOT_URL)
setMetadata(gmail.metadata.GmailURL, config.GMAIL_URL ?? 'http://localhost:8087')
setMetadata(calendar.metadata.CalendarServiceURL, config.CALENDAR_URL ?? 'http://localhost:8095')
setMetadata(notification.metadata.PushPublicKey, config.PUSH_PUBLIC_KEY)
Expand Down
2 changes: 1 addition & 1 deletion models/gmail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export function createModel (builder: Builder): void {
defaultEnabled: true,
canDisable: true,
depends: notification.providers.InboxNotificationProvider,
order: 30
order: 300
},
gmail.providers.EmailNotificationProvider
)
Expand Down
10 changes: 6 additions & 4 deletions models/notification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import {
type PushSubscription,
type PushSubscriptionKeys
} from '@hcengineering/notification'
import { type Asset, type IntlString } from '@hcengineering/platform'
import { type Asset, type IntlString, type Resource } from '@hcengineering/platform'
import setting from '@hcengineering/setting'
import { type AnyComponent, type Location } from '@hcengineering/ui/src/types'

Expand Down Expand Up @@ -295,6 +295,8 @@ export class TNotificationProvider extends TDoc implements NotificationProvider
depends?: Ref<NotificationProvider>
ignoreAll?: boolean
canDisable!: boolean
presenter?: AnyComponent
isAvailableFn?: Resource<() => boolean>
}

@Model(notification.class.NotificationProviderDefaults, core.class.Doc)
Expand Down Expand Up @@ -723,7 +725,7 @@ export function createModel (builder: Builder): void {
description: notification.string.InboxNotificationsDescription,
defaultEnabled: true,
canDisable: false,
order: 10
order: 100
},
notification.providers.InboxNotificationProvider
)
Expand All @@ -738,7 +740,7 @@ export function createModel (builder: Builder): void {
depends: notification.providers.InboxNotificationProvider,
defaultEnabled: true,
canDisable: true,
order: 20
order: 200
},
notification.providers.PushNotificationProvider
)
Expand All @@ -754,7 +756,7 @@ export function createModel (builder: Builder): void {
defaultEnabled: true,
canDisable: true,
ignoreAll: true,
order: 25
order: 250
},
notification.providers.SoundNotificationProvider
)
Expand Down
4 changes: 4 additions & 0 deletions models/server-activity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export function createModel (builder: Builder): void {
presenter: serverActivity.function.ReactionNotificationContentProvider
})

builder.mixin(activity.class.DocUpdateMessage, core.class.Class, serverNotification.mixin.TextPresenter, {
presenter: serverActivity.function.DocUpdateMessageTextPresenter
})

builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverActivity.trigger.OnReactionChanged,
txMatch: {
Expand Down
5 changes: 5 additions & 0 deletions models/server-telegram/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export function createModel (builder: Builder): void {
}
)

builder.createDoc(serverNotification.class.NotificationProviderResources, core.space.Model, {
provider: telegram.providers.TelegramNotificationProvider,
fn: serverTelegram.function.SendTelegramNotifications
})

builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverTelegram.trigger.OnMessageCreate,
txMatch: {
Expand Down
37 changes: 4 additions & 33 deletions models/telegram/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ import type {
} from '@hcengineering/telegram'
import templates from '@hcengineering/templates'
import view from '@hcengineering/view'

import telegram from './plugin'
import notification from '@hcengineering/model-notification'
import { defineNotifications } from './notification'

export { telegramId } from '@hcengineering/telegram'
export { telegramOperation } from './migration'
Expand Down Expand Up @@ -178,38 +179,6 @@ export function createModel (builder: Builder): void {
telegram.ids.TelegramMessageSharedActivityViewlet
)

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,
defaultEnabled: false
},
telegram.ids.NewMessageNotification
)

builder.createDoc(notification.class.NotificationProviderDefaults, core.space.Model, {
provider: notification.providers.InboxNotificationProvider,
ignoredTypes: [],
enabledTypes: [telegram.ids.NewMessageNotification]
})

builder.mixin(telegram.class.Message, core.class.Class, core.mixin.FullTextSearchContext, {
parentPropagate: false,
childProcessingAllowed: true
Expand All @@ -227,4 +196,6 @@ export function createModel (builder: Builder): void {
{ createdOn: -1 }
]
})

defineNotifications(builder)
}
72 changes: 72 additions & 0 deletions models/telegram/src/notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// Copyright © 2024 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//

import { type Builder } from '@hcengineering/model'
import notification from '@hcengineering/model-notification'
import core from '@hcengineering/model-core'
import contact from '@hcengineering/model-contact'

import telegram from './plugin'

export function defineNotifications (builder: Builder): void {
builder.createDoc(
notification.class.NotificationGroup,
core.space.Model,
{
label: telegram.string.Telegram,
icon: contact.icon.Telegram
},
telegram.ids.NotificationGroup
)

builder.createDoc(
notification.class.NotificationProvider,
core.space.Model,
{
label: telegram.string.Telegram,
icon: contact.icon.Telegram,
depends: notification.providers.InboxNotificationProvider,
defaultEnabled: false,
canDisable: true,
description: telegram.string.TelegramNotificationDescription,
presenter: telegram.component.NotificationProviderPresenter,
order: 400,
isAvailableFn: telegram.function.IsTelegramNotificationsAvailable
},
telegram.providers.TelegramNotificationProvider
)

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,
defaultEnabled: false
},
telegram.ids.NewMessageNotification
)

builder.createDoc(notification.class.NotificationProviderDefaults, core.space.Model, {
provider: notification.providers.InboxNotificationProvider,
ignoredTypes: [notification.ids.CollaboratoAddNotification],
enabledTypes: [telegram.ids.NewMessageNotification]
})
}
9 changes: 7 additions & 2 deletions models/telegram/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default mergeIds(telegramId, telegram, {
ConfigLabel: '' as IntlString,
ConfigDescription: '' as IntlString,
NewMessage: '' as IntlString,
NewIncomingMessage: '' as IntlString
NewIncomingMessage: '' as IntlString,
TelegramNotificationDescription: '' as IntlString
},
ids: {
NotificationGroup: '' as Ref<NotificationGroup>,
Expand All @@ -45,9 +46,13 @@ export default mergeIds(telegramId, telegram, {
},
function: {
GetCurrentEmployeeTG: '' as Resource<TemplateFieldFunc>,
GetIntegrationOwnerTG: '' as Resource<TemplateFieldFunc>
GetIntegrationOwnerTG: '' as Resource<TemplateFieldFunc>,
IsTelegramNotificationsAvailable: '' as Resource<() => boolean>
},
activity: {
TelegramMessageCreated: '' as AnyComponent
},
component: {
NotificationProviderPresenter: '' as AnyComponent
}
})
Loading

0 comments on commit b997b0c

Please sign in to comment.