diff --git a/src/puppet-web/bridge.ts b/src/puppet-web/bridge.ts index 4295e65e4af7ffc4e6eb0140114f258c72f4dcb3..b799f1a54e4876a641fc6d2c73958173aed680cc 100644 --- a/src/puppet-web/bridge.ts +++ b/src/puppet-web/bridge.ts @@ -222,20 +222,23 @@ export class Bridge { }) } - public verifyUserRequest(contactId, hello): Promise { + public async verifyUserRequest(contactId, hello): Promise { log.verbose('PuppetWebBridge', 'verifyUserRequest(%s, %s)', contactId, hello) if (!contactId) { throw new Error('no valid contactId') } - return this.proxyWechaty('verifyUserRequestAsync', contactId, hello) - .catch(e => { - log.error('PuppetWebBridge', 'verifyUserRequest(%s, %s) exception: %s', contactId, hello, e.message) - throw e - }) + try { + + return await this.proxyWechaty('verifyUserRequestAsync', contactId, hello) + + } catch (e) { + log.error('PuppetWebBridge', 'verifyUserRequest(%s, %s) exception: %s', contactId, hello, e.message) + throw e + } } - public verifyUserOk(contactId, ticket): Promise { + public async verifyUserOk(contactId, ticket): Promise { log.verbose('PuppetWebBridge', 'verifyUserOk(%s, %s)', contactId, ticket) if (!contactId || !ticket) { @@ -248,7 +251,7 @@ export class Bridge { }) } - public send(toUserName: string, content: string): Promise { + public async send(toUserName: string, content: string): Promise { if (!toUserName) { throw new Error('UserName not found') } diff --git a/src/puppet-web/friend-request.ts b/src/puppet-web/friend-request.ts index 411887813f02967f5bdac4d7143247373908aa67..2121596b2ae962ee06d7fdc36406a1efabf2ff4f 100644 --- a/src/puppet-web/friend-request.ts +++ b/src/puppet-web/friend-request.ts @@ -19,7 +19,7 @@ /* tslint:disable:no-var-requires */ const retryPromise = require('retry-promise').default -import Contact from '../contact' +import { Contact } from '../contact' import { Config, RecommendInfo, diff --git a/src/puppet-web/puppet-web.ts b/src/puppet-web/puppet-web.ts index 801bcee42aa1ce3c93976ce6b4625563f862a69e..45bbd75f2bae9d577bbe15fd11f700c03461b4a6 100644 --- a/src/puppet-web/puppet-web.ts +++ b/src/puppet-web/puppet-web.ts @@ -652,7 +652,7 @@ export class PuppetWeb extends Puppet { */ public async friendRequestSend(contact: Contact, hello: string): Promise { if (!this.bridge) { - return Promise.reject(new Error('fail: no bridge(yet)!')) + throw new Error('fail: no bridge(yet)!') } if (!contact) { diff --git a/src/puppet-web/wechaty-bro.js b/src/puppet-web/wechaty-bro.js index c9684bc2cd638788cb94b24f65af25eb96683b98..d4da751c128f0ff2c7079962fb105af875df9637 100644 --- a/src/puppet-web/wechaty-bro.js +++ b/src/puppet-web/wechaty-bro.js @@ -756,8 +756,8 @@ VerifyContent = VerifyContent || ''; - var contactFactory = WechatyBro.glue.contactFactory - var confFactory = WechatyBro.glue.confFactory + var contactFactory = WechatyBro.glue.contactFactory + var confFactory = WechatyBro.glue.confFactory var Ticket = '' // what's this?