2021-11-25 11:05:00 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
2023-04-14 05:43:36 +00:00
|
|
|
import { ChannelItem } from '@hcengineering/contact'
|
|
|
|
import type { AttachedDoc, Class, Doc, Ref, Space, Timestamp } from '@hcengineering/core'
|
2023-05-24 07:09:11 +00:00
|
|
|
import { NotificationType } from '@hcengineering/notification'
|
2022-09-21 08:08:25 +00:00
|
|
|
import type { Plugin } from '@hcengineering/platform'
|
2023-04-14 05:43:36 +00:00
|
|
|
import { Metadata, plugin } from '@hcengineering/platform'
|
|
|
|
import type { Handler, IntegrationType } from '@hcengineering/setting'
|
2023-04-11 10:17:47 +00:00
|
|
|
import { TemplateField } from '@hcengineering/templates'
|
2023-04-14 05:43:36 +00:00
|
|
|
import type { AnyComponent } from '@hcengineering/ui'
|
2021-11-25 11:05:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-03-11 09:05:44 +00:00
|
|
|
export interface BaseTelegramMessage extends Doc {
|
2021-11-25 11:05:00 +00:00
|
|
|
content: string
|
2022-03-11 09:05:44 +00:00
|
|
|
attachments?: number
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2023-04-14 05:43:36 +00:00
|
|
|
export interface TelegramMessage extends BaseTelegramMessage, ChannelItem {}
|
2021-11-25 11:05:00 +00:00
|
|
|
|
2021-12-09 09:05:21 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-03-11 09:05:44 +00:00
|
|
|
export interface NewTelegramMessage extends BaseTelegramMessage, AttachedDoc {
|
|
|
|
status: 'new' | 'sent'
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SharedTelegramMessage extends BaseTelegramMessage {
|
2021-12-09 09:05:21 +00:00
|
|
|
incoming: boolean
|
|
|
|
sender: string
|
2022-04-29 16:37:58 +00:00
|
|
|
sendOn: Timestamp
|
2021-12-09 09:05:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SharedTelegramMessages extends AttachedDoc {
|
|
|
|
messages: SharedTelegramMessage[]
|
|
|
|
}
|
|
|
|
|
2021-11-25 11:05:00 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export const telegramId = 'telegram' as Plugin
|
|
|
|
|
|
|
|
export default plugin(telegramId, {
|
|
|
|
component: {
|
|
|
|
Chat: '' as AnyComponent,
|
|
|
|
Connect: '' as AnyComponent,
|
2022-03-16 09:02:57 +00:00
|
|
|
Reconnect: '' as AnyComponent,
|
2021-11-25 11:05:00 +00:00
|
|
|
IconTelegram: '' as AnyComponent
|
|
|
|
},
|
|
|
|
integrationType: {
|
|
|
|
Telegram: '' as Ref<IntegrationType>
|
|
|
|
},
|
2021-12-01 11:04:52 +00:00
|
|
|
handler: {
|
|
|
|
DisconnectHandler: '' as Handler
|
|
|
|
},
|
2023-05-24 07:09:11 +00:00
|
|
|
ids: {
|
|
|
|
NewMessageNotification: '' as Ref<NotificationType>
|
|
|
|
},
|
2021-11-25 11:05:00 +00:00
|
|
|
class: {
|
2021-12-09 09:05:21 +00:00
|
|
|
Message: '' as Ref<Class<TelegramMessage>>,
|
2022-03-11 09:05:44 +00:00
|
|
|
NewMessage: '' as Ref<Class<NewTelegramMessage>>,
|
2021-12-09 09:05:21 +00:00
|
|
|
SharedMessage: '' as Ref<Class<SharedTelegramMessage>>,
|
|
|
|
SharedMessages: '' as Ref<Class<SharedTelegramMessages>>
|
2021-11-26 11:09:46 +00:00
|
|
|
},
|
|
|
|
space: {
|
|
|
|
Telegram: '' as Ref<Space>
|
2023-03-22 02:48:57 +00:00
|
|
|
},
|
2023-04-11 10:17:47 +00:00
|
|
|
templateField: {
|
|
|
|
CurrentEmployeeTelegram: '' as Ref<TemplateField>,
|
|
|
|
IntegrationOwnerTG: '' as Ref<TemplateField>
|
|
|
|
},
|
2023-03-22 02:48:57 +00:00
|
|
|
metadata: {
|
|
|
|
TelegramURL: '' as Metadata<string>
|
2021-11-25 11:05:00 +00:00
|
|
|
}
|
|
|
|
})
|