Skip to content

Commit

Permalink
rollback to weixin from handle before v2.0 (wechaty/grpc#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Mar 29, 2022
1 parent 2ece47d commit baa98b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"semver": "^7.3.5",
"stronger-typed-streams": "^0.2.0",
"uuid": "^8.3.2",
"wechaty-grpc": "^1.3.0",
"wechaty-grpc": "^1.5.2",
"wechaty-redux": "^1.19.7",
"wechaty-token": "^1.0.6"
},
Expand Down
14 changes: 11 additions & 3 deletions src/client/puppet-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,11 @@ class PuppetService extends PUPPET.Puppet {
description : response.getDescription(),
friend : response.getFriend(),
gender : response.getGender() as number,
handle : response.getHandle(),
/**
* Huan(202203): rename `getWeixin()` to `getHandle()` in v2.0.0
* @link https://github.com/wechaty/grpc/issues/174
*/
handle : response.getWeixin(),
id : response.getId(),
name : response.getName(),
phone : response.getPhonesList(),
Expand All @@ -680,7 +684,7 @@ class PuppetService extends PUPPET.Puppet {
* `weixin` is deprecated, will be removed after Dec 31, 2022
* use `handle` instead.
*/
weixin : response.getHandle(),
weixin : response.getWeixin(),
}

await this._payloadStore.contact?.set(id, payload)
Expand Down Expand Up @@ -1697,7 +1701,11 @@ class PuppetService extends PUPPET.Puppet {
log.verbose('PuppetService', 'friendshipSearchHandle(%s)', handle)

const request = new grpcPuppet.FriendshipSearchHandleRequest()
request.setHandle(handle)
/**
* TODO: use `setHandle()` in v2.0.0
* @link https://github.com/wechaty/grpc/issues/174
*/
request.setWeixin(handle)

const response = await util.promisify(
this.grpcManager.client.friendshipSearchHandle
Expand Down
11 changes: 8 additions & 3 deletions src/server/puppet-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ function puppetImplementation (
response.setType(payload.type)
/**
* @deprecated `payload.weixin` will be removed in v2.0
* @link https://github.com/wechaty/grpc/issues/174
*/
response.setHandle(payload.handle || payload.weixin || '')
response.setWeixin(payload.handle || payload.weixin || '')
response.setPhonesList(payload.phone)
response.setCoworker(payload.coworker || false)
response.setCorporation(payload.corporation || '')
Expand Down Expand Up @@ -474,8 +475,12 @@ function puppetImplementation (
log.verbose('PuppetServiceImpl', 'friendshipSearchHandle()')

try {
const weixin = call.request.getHandle()
const contactId = await puppet.friendshipSearchHandle(weixin)
/**
* Huan(202203): rename `getWeixin()` to `getHandle()` in v2.0.0
* @link https://github.com/wechaty/grpc/issues/174
*/
const handle = call.request.getWeixin()
const contactId = await puppet.friendshipSearchHandle(handle)

const response = new grpcPuppet.FriendshipSearchHandleResponse()

Expand Down

0 comments on commit baa98b7

Please sign in to comment.