Adjust telegram service expected error shape (#484)

Signed-off-by: Ilya Sumbatyants <ilya.sumb@gmail.com>
This commit is contained in:
Ilya Sumbatyants 2021-12-02 16:03:16 +07:00 committed by GitHub
parent c60388224b
commit fa6b390c01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 17 deletions

View File

@ -34,7 +34,6 @@
"@anticrm/core": "~0.6.11",
"svelte": "^3.37.0",
"@anticrm/setting": "~0.6.0",
"@anticrm/login": "~0.6.1",
"@anticrm/ui": "~0.6.0",
"@anticrm/presentation": "~0.6.2"
}

View File

@ -13,15 +13,13 @@
// limitations under the License.
-->
<script lang="ts">
import type { Ref, Space } from '@anticrm/core';
import { getMetadata } from '@anticrm/platform';
import login from '@anticrm/login'
import { getCurrentAccount, Ref, Space } from '@anticrm/core';
import { createQuery } from '@anticrm/presentation'
import setting from '@anticrm/setting'
import type { Integration, IntegrationType } from '@anticrm/setting'
import PluginCard from './PluginCard.svelte'
const accountId = getMetadata(login.metadata.LoginEmail)
const accountId = getCurrentAccount()._id
const typeQuery = createQuery()
const integrationQuery = createQuery()
@ -29,7 +27,7 @@
let integrationTypes: IntegrationType[] = []
typeQuery.query(setting.class.IntegrationType, {}, (res) => (integrationTypes = res))
integrationQuery.query(setting.class.Integration, { space: accountId as Ref<Space> }, (res) => (integrations = res))
integrationQuery.query(setting.class.Integration, { space: accountId as string as Ref<Space> }, (res) => (integrations = res))
</script>
<div class="cards-container">

View File

@ -14,23 +14,22 @@
-->
<script lang="ts">
import { Button, Component, Label, Link } from '@anticrm/ui'
import { getMetadata, getResource } from '@anticrm/platform'
import { getResource } from '@anticrm/platform'
import { showPopup } from '@anticrm/ui'
import type { Integration, IntegrationType } from '@anticrm/setting'
import setting from '@anticrm/setting'
import { getClient } from '@anticrm/presentation'
import type { Ref, Space } from '@anticrm/core'
import login from '@anticrm/login'
import { getCurrentAccount, Ref, Space } from '@anticrm/core'
export let integrationType: IntegrationType
export let integration: Integration | undefined
const accountId = getMetadata(login.metadata.LoginEmail)
const accountId = getCurrentAccount()._id
const client = getClient()
const onDisconnectP = getResource(integrationType.onDisconnect)
async function close(res: any): Promise<void> {
if (res.value) {
await client.createDoc(setting.class.Integration, accountId as Ref<Space>, {
if (res?.value) {
await client.createDoc(setting.class.Integration, accountId as string as Ref<Space>, {
type: integrationType._id,
value: res.value
})

View File

@ -65,11 +65,13 @@
})
const res = await response.json()
connecting = false
if (res.tg_code === 'PHONE_CODE_INVALID') {
error = 'Invalid code'
}
if (res.err != null) {
throw new Error(res.err)
if (Math.trunc(response.status / 100) !== 2) {
if (res.code === 'PHONE_CODE_INVALID') {
error = 'Invalid code'
}
throw new Error(res.message)
}
return res