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.
|
|
|
|
//
|
|
|
|
|
|
|
|
import { plugin } from '@anticrm/platform'
|
|
|
|
import type { Plugin } from '@anticrm/platform'
|
2021-12-09 09:05:21 +00:00
|
|
|
import type { Doc, Ref, Class, Space, AttachedDoc } from '@anticrm/core'
|
2021-11-25 11:05:00 +00:00
|
|
|
import type { AnyComponent } from '@anticrm/ui'
|
2021-12-01 11:04:52 +00:00
|
|
|
import type { IntegrationType, Handler } from '@anticrm/setting'
|
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
|
|
|
|
*/
|
|
|
|
export interface TelegramMessage extends BaseTelegramMessage, AttachedDoc {
|
2021-11-25 11:05:00 +00:00
|
|
|
incoming: boolean
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
},
|
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>
|
2021-11-25 11:05:00 +00:00
|
|
|
}
|
|
|
|
})
|