提交 78637ed1 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

fix contact exception

上级 30c075da
......@@ -201,6 +201,8 @@ export class Contact extends Accessory implements Sayable {
const CHUNK_SIZE = 16
let batchIndex = 0
const invalidContactId: string[] = []
while (batchIndex * CHUNK_SIZE < contactList.length) {
const batchContactList = contactList.slice(
CHUNK_SIZE * batchIndex,
......@@ -208,14 +210,20 @@ export class Contact extends Accessory implements Sayable {
)
await Promise.all(
batchContactList.map(
c => c.ready(),
c => {
c.ready()
.catch(e => {
log.error('Contact', 'findAll() ready() exception: %s', e.message)
invalidContactId.push(c.id)
})
},
),
)
batchIndex++
}
return contactList
return contactList.filter(contact => !(contact.id in invalidContactId))
} catch (e) {
log.error('Contact', 'this.puppet.contactFindAll() rejected: %s', e.message)
......@@ -268,11 +276,10 @@ export class Contact extends Accessory implements Sayable {
* @private
*/
public toString(): string {
if (!this.payload) {
return this.constructor.name
}
const identity = this.payload.alias || this.payload.name || this.id
return `Contact<${identity || 'Unknown'}>`
const identity = this.payload
? this.payload.alias || this.payload.name || this.id
: this.id
return `Contact<${identity}>`
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册