diff --git a/plugins/client-resources/src/connection.ts b/plugins/client-resources/src/connection.ts index 5c6c4c3ed4..4714de8671 100644 --- a/plugins/client-resources/src/connection.ts +++ b/plugins/client-resources/src/connection.ts @@ -16,7 +16,7 @@ import client, { ClientSocket } from '@anticrm/client' import type { Class, ClientConnection, Doc, DocumentQuery, FindOptions, FindResult, Ref, Tx, TxHander, TxResult } from '@anticrm/core' -import { getMetadata, readResponse, ReqId, serialize } from '@anticrm/platform' +import { getMetadata, PlatformError, readResponse, ReqId, serialize } from '@anticrm/platform' class DeferredPromise { readonly promise: Promise @@ -61,7 +61,7 @@ class Connection implements ClientConnection { if (promise === undefined) { throw new Error(`unknown response id: ${resp.id}`) } this.requests.delete(resp.id) if (resp.error !== undefined) { - promise.reject(resp.error) + promise.reject(new PlatformError(resp.error)) } else { promise.resolve(resp.result) } diff --git a/plugins/contact-resources/src/components/CreatePerson.svelte b/plugins/contact-resources/src/components/CreatePerson.svelte index adcc808b08..bc11925a1e 100644 --- a/plugins/contact-resources/src/components/CreatePerson.svelte +++ b/plugins/contact-resources/src/components/CreatePerson.svelte @@ -49,16 +49,15 @@ async function createPerson () { const uploadFile = await getResource(attachment.helper.UploadFile) - const avatarUUID = avatar !== undefined - ? await uploadFile(avatar) - : undefined + const avatarProp = avatar !== undefined + ? { avatar: await uploadFile(avatar) } + : {} - console.warn('avatar', avatar, avatarUUID) const person: Data = { name: combineName(firstName, lastName), city: object.city, - avatar: avatarUUID, - channels: object.channels + channels: object.channels, + ...avatarProp } await client.createDoc(contact.class.Person, contact.space.Contacts, person) diff --git a/plugins/recruit-resources/src/components/CreateCandidate.svelte b/plugins/recruit-resources/src/components/CreateCandidate.svelte index 3dac469a8a..c6b17cfcc8 100644 --- a/plugins/recruit-resources/src/components/CreateCandidate.svelte +++ b/plugins/recruit-resources/src/components/CreateCandidate.svelte @@ -50,14 +50,14 @@ async function createCandidate () { const uploadFile = await getResource(attachment.helper.UploadFile) - const avatarUUID = avatar !== undefined - ? await uploadFile(avatar) - : undefined + const avatarProp = avatar !== undefined + ? { avatar: await uploadFile(avatar) } + : {} const candidate: Data = { name: combineName(firstName, lastName), city: object.city, channels: object.channels, - avatar: avatarUUID + ...avatarProp } const candidateData: MixinData = { title: object.title, @@ -92,7 +92,7 @@ try { const uploadFile = await getResource(attachment.helper.UploadFile) - resume.uuid = await uploadFile(file, space, candidateId) + resume.uuid = await uploadFile(file, contact.space.Contacts, candidateId) resume.name = file.name resume.size = file.size resume.type = file.type diff --git a/plugins/telegram-resources/src/components/Chat.svelte b/plugins/telegram-resources/src/components/Chat.svelte index 9f15e3d570..066bb1c502 100644 --- a/plugins/telegram-resources/src/components/Chat.svelte +++ b/plugins/telegram-resources/src/components/Chat.svelte @@ -153,6 +153,15 @@ } }) } + + async function onConnectClose (res: any): Promise { + if (res?.value) { + await client.createDoc(setting.class.Integration, accountId as string as Ref, { + type: telegram.integrationType.Telegram, + value: res.value + }) + } + }
@@ -200,7 +209,7 @@ label={'Connect'} primary on:click={(e) => { - showPopup(Connect, {}, e.target) + showPopup(Connect, {}, e.target, onConnectClose) }} />
diff --git a/server/elastic/src/adapter.ts b/server/elastic/src/adapter.ts index 1aa491b4a4..e288cb7776 100644 --- a/server/elastic/src/adapter.ts +++ b/server/elastic/src/adapter.ts @@ -17,8 +17,7 @@ import type { Class, Doc, DocumentQuery, Ref, TxResult } from '@anticrm/core' import type { FullTextAdapter, IndexedDoc } from '@anticrm/server-core' -import { Client } from '@elastic/elasticsearch' - +import { Client, errors as esErr } from '@elastic/elasticsearch' class ElasticAdapter implements FullTextAdapter { constructor (private readonly client: Client, private readonly db: string) {} @@ -113,10 +112,18 @@ class ElasticAdapter implements FullTextAdapter { } async remove (id: Ref): Promise { - await this.client.delete({ - index: this.db, - id - }) + try { + await this.client.delete({ + index: this.db, + id + }) + } catch (e: any) { + if (e instanceof esErr.ResponseError && e.meta.statusCode === 404) { + return + } + + throw e + } } }