diff --git a/models/setting/src/index.ts b/models/setting/src/index.ts
index 628a4e066b..41c3d3ea16 100644
--- a/models/setting/src/index.ts
+++ b/models/setting/src/index.ts
@@ -17,7 +17,7 @@ import { Builder, Model } from '@anticrm/model'
import { Ref, Domain, DOMAIN_MODEL } from '@anticrm/core'
import core, { TDoc } from '@anticrm/model-core'
import setting from '@anticrm/setting'
-import type { Integration, IntegrationType } from '@anticrm/setting'
+import type { Integration, IntegrationType, Handler } from '@anticrm/setting'
import type { IntlString } from '@anticrm/platform'
import workbench from '@anticrm/model-workbench'
@@ -37,6 +37,7 @@ export class TIntegrationType extends TDoc implements IntegrationType {
description!: IntlString
icon!: AnyComponent
createComponent!: AnyComponent
+ onDisconnect!: Handler
}
export function createModel (builder: Builder): void {
@@ -87,6 +88,7 @@ export function createModel (builder: Builder): void {
label: 'Email',
description: 'Use email integration' as IntlString,
icon: setting.component.IconGmail,
- createComponent: setting.component.ConnectEmail
+ createComponent: setting.component.ConnectEmail,
+ onDisconnect: setting.handler.EmailDisconnectHandler
})
}
diff --git a/models/telegram/src/index.ts b/models/telegram/src/index.ts
index f7438cb24d..affe33c16a 100644
--- a/models/telegram/src/index.ts
+++ b/models/telegram/src/index.ts
@@ -53,7 +53,8 @@ export function createModel (builder: Builder): void {
label: 'Telegram',
description: 'Use telegram integration' as IntlString,
icon: telegram.component.IconTelegram,
- createComponent: telegram.component.Connect
+ createComponent: telegram.component.Connect,
+ onDisconnect: telegram.handler.DisconnectHandler
}, telegram.integrationType.Telegram)
builder.createDoc(core.class.Space, core.space.Model, {
diff --git a/plugins/setting-resources/src/components/PluginCard.svelte b/plugins/setting-resources/src/components/PluginCard.svelte
index fa73a023ee..2882404dd5 100644
--- a/plugins/setting-resources/src/components/PluginCard.svelte
+++ b/plugins/setting-resources/src/components/PluginCard.svelte
@@ -14,7 +14,7 @@
-->
diff --git a/plugins/setting-resources/src/index.ts b/plugins/setting-resources/src/index.ts
index 5bdc0a15fe..4d7084653d 100644
--- a/plugins/setting-resources/src/index.ts
+++ b/plugins/setting-resources/src/index.ts
@@ -22,5 +22,8 @@ export default async () => ({
Integrations,
ConnectEmail,
IconGmail
+ },
+ handler: {
+ EmailDisconnectHandler: async () => {}
}
})
diff --git a/plugins/setting/src/index.ts b/plugins/setting/src/index.ts
index 2a74766de4..8982989a1e 100644
--- a/plugins/setting/src/index.ts
+++ b/plugins/setting/src/index.ts
@@ -13,11 +13,16 @@
// limitations under the License.
//
-import { Asset, IntlString, plugin } from '@anticrm/platform'
+import { Asset, IntlString, plugin, Resource } from '@anticrm/platform'
import type { Plugin } from '@anticrm/platform'
import { AnyComponent } from '@anticrm/ui'
import type { Class, Doc, Ref } from '@anticrm/core'
+/**
+ * @public
+ */
+export type Handler = Resource<() => Promise>
+
/**
* @public
*/
@@ -26,6 +31,7 @@ export interface IntegrationType extends Doc {
description: IntlString
icon: AnyComponent
createComponent: AnyComponent
+ onDisconnect: Handler
}
/**
@@ -58,6 +64,9 @@ export default plugin(settingId, {
ConnectEmail: '' as AnyComponent,
IconGmail: '' as AnyComponent
},
+ handler: {
+ EmailDisconnectHandler: '' as Handler
+ },
string: {
Setting: '' as IntlString,
Integrations: '' as IntlString,
diff --git a/plugins/telegram-resources/src/index.ts b/plugins/telegram-resources/src/index.ts
index f9d8c6c9d3..08f333f722 100644
--- a/plugins/telegram-resources/src/index.ts
+++ b/plugins/telegram-resources/src/index.ts
@@ -14,7 +14,8 @@
// limitations under the License.
//
-import { Resources } from '@anticrm/platform'
+import { getMetadata, Resources } from '@anticrm/platform'
+import login from '@anticrm/login'
import Chat from './components/Chat.svelte'
import Connect from './components/Connect.svelte'
import IconTelegram from './components/icons/TelegramColor.svelte'
@@ -24,5 +25,17 @@ export default async (): Promise => ({
Chat,
Connect,
IconTelegram
+ },
+ handler: {
+ DisconnectHandler: async () => {
+ const url = getMetadata(login.metadata.TelegramUrl) ?? ''
+ await fetch(url + '/signout', {
+ method: 'POST',
+ headers: {
+ Authorization: 'Bearer ' + (getMetadata(login.metadata.LoginToken) ?? ''),
+ 'Content-Type': 'application/json'
+ }
+ })
+ }
}
})
diff --git a/plugins/telegram/src/index.ts b/plugins/telegram/src/index.ts
index a3728bd166..e45ad5fbe9 100644
--- a/plugins/telegram/src/index.ts
+++ b/plugins/telegram/src/index.ts
@@ -17,7 +17,7 @@ import { plugin } from '@anticrm/platform'
import type { Plugin } from '@anticrm/platform'
import type { Doc, Ref, Class, Space } from '@anticrm/core'
import type { AnyComponent } from '@anticrm/ui'
-import type { IntegrationType } from '@anticrm/setting'
+import type { IntegrationType, Handler } from '@anticrm/setting'
/**
* @public
@@ -43,6 +43,9 @@ export default plugin(telegramId, {
integrationType: {
Telegram: '' as Ref
},
+ handler: {
+ DisconnectHandler: '' as Handler
+ },
class: {
Message: '' as Ref>
},