Skip to content

Commit

Permalink
refresh payload for updating #1517
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Jul 31, 2018
1 parent b7ed214 commit 58bb09a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/user/contact.ts
Expand Up @@ -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)
Expand Down

0 comments on commit 58bb09a

Please sign in to comment.