Multiple fixes (#820)

Signed-off-by: Ilya Sumbatyants <ilya.sumb@gmail.com>
This commit is contained in:
Ilya Sumbatyants 2022-01-14 16:05:24 +07:00 committed by GitHub
parent 50a9fc9980
commit e8c26c46a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 20 deletions

View File

@ -16,7 +16,7 @@
import client, { ClientSocket } from '@anticrm/client' import client, { ClientSocket } from '@anticrm/client'
import type { Class, ClientConnection, Doc, DocumentQuery, FindOptions, FindResult, Ref, Tx, TxHander, TxResult } from '@anticrm/core' 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 { class DeferredPromise {
readonly promise: Promise<any> readonly promise: Promise<any>
@ -61,7 +61,7 @@ class Connection implements ClientConnection {
if (promise === undefined) { throw new Error(`unknown response id: ${resp.id}`) } if (promise === undefined) { throw new Error(`unknown response id: ${resp.id}`) }
this.requests.delete(resp.id) this.requests.delete(resp.id)
if (resp.error !== undefined) { if (resp.error !== undefined) {
promise.reject(resp.error) promise.reject(new PlatformError(resp.error))
} else { } else {
promise.resolve(resp.result) promise.resolve(resp.result)
} }

View File

@ -49,16 +49,15 @@
async function createPerson () { async function createPerson () {
const uploadFile = await getResource(attachment.helper.UploadFile) const uploadFile = await getResource(attachment.helper.UploadFile)
const avatarUUID = avatar !== undefined const avatarProp = avatar !== undefined
? await uploadFile(avatar) ? { avatar: await uploadFile(avatar) }
: undefined : {}
console.warn('avatar', avatar, avatarUUID)
const person: Data<Person> = { const person: Data<Person> = {
name: combineName(firstName, lastName), name: combineName(firstName, lastName),
city: object.city, city: object.city,
avatar: avatarUUID, channels: object.channels,
channels: object.channels ...avatarProp
} }
await client.createDoc(contact.class.Person, contact.space.Contacts, person) await client.createDoc(contact.class.Person, contact.space.Contacts, person)

View File

@ -50,14 +50,14 @@
async function createCandidate () { async function createCandidate () {
const uploadFile = await getResource(attachment.helper.UploadFile) const uploadFile = await getResource(attachment.helper.UploadFile)
const avatarUUID = avatar !== undefined const avatarProp = avatar !== undefined
? await uploadFile(avatar) ? { avatar: await uploadFile(avatar) }
: undefined : {}
const candidate: Data<Person> = { const candidate: Data<Person> = {
name: combineName(firstName, lastName), name: combineName(firstName, lastName),
city: object.city, city: object.city,
channels: object.channels, channels: object.channels,
avatar: avatarUUID ...avatarProp
} }
const candidateData: MixinData<Person, Candidate> = { const candidateData: MixinData<Person, Candidate> = {
title: object.title, title: object.title,
@ -92,7 +92,7 @@
try { try {
const uploadFile = await getResource(attachment.helper.UploadFile) 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.name = file.name
resume.size = file.size resume.size = file.size
resume.type = file.type resume.type = file.type

View File

@ -153,6 +153,15 @@
} }
}) })
} }
async function onConnectClose (res: any): Promise<void> {
if (res?.value) {
await client.createDoc(setting.class.Integration, accountId as string as Ref<Space>, {
type: telegram.integrationType.Telegram,
value: res.value
})
}
}
</script> </script>
<div class="flex-between header"> <div class="flex-between header">
@ -200,7 +209,7 @@
label={'Connect'} label={'Connect'}
primary primary
on:click={(e) => { on:click={(e) => {
showPopup(Connect, {}, e.target) showPopup(Connect, {}, e.target, onConnectClose)
}} }}
/> />
</div> </div>

View File

@ -17,8 +17,7 @@
import type { Class, Doc, DocumentQuery, Ref, TxResult } from '@anticrm/core' import type { Class, Doc, DocumentQuery, Ref, TxResult } from '@anticrm/core'
import type { FullTextAdapter, IndexedDoc } from '@anticrm/server-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 { class ElasticAdapter implements FullTextAdapter {
constructor (private readonly client: Client, private readonly db: string) {} constructor (private readonly client: Client, private readonly db: string) {}
@ -113,10 +112,18 @@ class ElasticAdapter implements FullTextAdapter {
} }
async remove (id: Ref<Doc>): Promise<void> { async remove (id: Ref<Doc>): Promise<void> {
await this.client.delete({ try {
index: this.db, await this.client.delete({
id index: this.db,
}) id
})
} catch (e: any) {
if (e instanceof esErr.ResponseError && e.meta.statusCode === 404) {
return
}
throw e
}
} }
} }