From 58bb09a39d3cb7f3b0857b02b1f5f5b7871bf29f Mon Sep 17 00:00:00 2001 From: Huan LI Date: Wed, 1 Aug 2018 02:07:02 +0800 Subject: [PATCH] refresh payload for updating #1517 --- src/user/contact.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/user/contact.ts b/src/user/contact.ts index c59e08519..44ae29919 100644 --- a/src/user/contact.ts +++ b/src/user/contact.ts @@ -416,16 +416,21 @@ export class Contact extends Accessory implements Sayable { : newAlias, ) + if (!this.payload) { + throw new Error('no payload') + } + if (typeof newAlias === 'undefined') { - if (!this.payload) { - throw new Error('no payload') - } return this.payload.alias || null } try { await this.puppet.contactAlias(this.id, newAlias) - this.payload!.alias = newAlias || undefined + await this.puppet.contactPayloadDirty(this.id) + this.payload = await this.puppet.contactPayload(this.id) + if (newAlias && newAlias !== this.payload.alias) { + log.warn('Contact', 'alias(%s) data got is not same as set', newAlias) + } } catch (e) { log.error('Contact', 'alias(%s) rejected: %s', newAlias, e.message) Raven.captureException(e)