Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contact name not sync after call sync() or restart docker (RPC) #1531

Closed
kis87988 opened this issue Aug 7, 2018 · 5 comments
Closed

contact name not sync after call sync() or restart docker (RPC) #1531

kis87988 opened this issue Aug 7, 2018 · 5 comments

Comments

@kis87988
Copy link
Contributor

kis87988 commented Aug 7, 2018

Provide Your Network Information

  1. Where is the location of your server? U.S.
  2. Which cloud platform(AliYun/Qcloud/DigitalOcean/etc) are you using?
    own server

Run npm run doctor or wechaty run doctor(for docker user), paste output here

docker run in container
Version : 0.19.123

Expected behavior

const contact = bot.Contact.load("12345")
console.log(contact.name())
// now the contact change name 
contact.sync()
console.log(contact.name()) // name not change, it still is old name.

OR

const contact = bot.Contact.load("12345")
console.log(contact.name())
// now the contact change name
// now docker restart
//after bot complete ready with ready event
await bot.ready()
const contact = bot.Contact.load("12345")
console.log(contact.name()) // name not change, it still is old name.

Actual behavior

contact not sync after restart the docker or force sync().

Steps to reproduce the behavior (and fixes, if any)

The issue I have now is a advertising contact/people send a advertising message in a room.
and then they change name right the way.
if I use await room.member(name), the contact won't be found because the name in the cache not sync with new name.
so I would like to force sync the new name with sync().
not only that, even I restart the docker, the contact name still is the old name.
I am not sure this is wechaty, padchat or wechat app limit(because sometime in the phone if a person change name or profile picture, we have to click on the phone to reload these information)

Hope we can have force sync contact function if we really have to get the new name

NOTE: I actually found this issue by look up whole log, and usually if want want to remove a contact via bot we have to give the correct name to find the actually contact then call room.del(contact).

If you know c9 IDE, please goto https://ide.c9.io/zixia/wechaty-bug-reproducer to apply a write access for the workspace so that you can put your reproduceable code over there. If you did that, your issue will be classified with HIGH priority and we will deal with the high priority issues first.

Full Output Logs

$ docker create -t -i --name=$docker_name \
--mount type=bind,source="${dir}",target=/bot \
-e WECHATY_LOG=silly \
-e TZ="America/Los_Angeles" \
zixia/wechaty:latest mybot.ts
$ docker start -a $docker_name 
Show Logs

Paste the full output logs here with WECHATY_LOG=silly set

# PASTE FULL LOG OUTPUT AT HERE:
N/A for now

@huan
Copy link
Member

huan commented Aug 7, 2018

When you call contact.sync(), the Wechaty will delete the cache for this contact by callingPuppet.contactPayloadDirty().

What did the contactPayloadDirty() do will be depended on the implementation of the specific puppet, in your case is PuppetPadchat.

So I believe it's a padchat related issue.

I had also looked into the source code of padchat, it will delete both memory cache and file cache, which I believe it will reload the payload from the protocol again.

If that not reload the contact payload, then I'll guess it's related to the Wechat Protocol.

I'm not sure, just FYI.

At last, if someone says something in the room, I believe you can easy to find them out by just use msg.from(). Will that work for you or not?

@kis87988
Copy link
Contributor Author

kis87988 commented Aug 7, 2018

Yea. However, when I did msg.from() the message has already pass message, so the contact can not track unless really create bot message logger.

Another thing is,. when I @old_name that work, and the new name will come out.
such as
@bot please remove @old_name from this room.
and the bot say new_name has been remove from this room.

still not sure what part is issue.

@huan
Copy link
Member

huan commented Aug 8, 2018

Can you try to call room.sync() to see if it helps?

@kis87988
Copy link
Contributor Author

kis87988 commented Aug 8, 2018

Yes, I did it before I search member.
And it still old name.

@kis87988
Copy link
Contributor Author

Now, we can using find to solve this issue by looking for previous message history.
Refer #1534
Problem solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants