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 alias not sync after call contact.alias(string) to set alias #1517

Closed
kis87988 opened this issue Jul 31, 2018 · 9 comments
Closed

contact alias not sync after call contact.alias(string) to set alias #1517

kis87988 opened this issue Jul 31, 2018 · 9 comments
Labels

Comments

@kis87988
Copy link
Contributor

Provide Your Network Information

  1. Where is the location of your server? (i.e. City, or In/Out China)
    U.S.
  2. Which cloud platform(AliYun/Qcloud/DigitalOcean/etc) are you using?
    own machine

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

//docker run in container

const old_alias = await contact.alias()
const new_alias= "new_alias"
console.log(old_alias) // old_alias
await contact.alias(new_alias)
await contact.sync()
await delay(getRandomIntInclusive(3000, 5000)) // delay 3~5 secs
const new_set_alias = await contact.alias()
console.log(contact.name() + ' Alias:' + new_set_alias ) //contact name Alias: old_alias

Expected behavior

The contact alias should be set to new_alias in the wechaty after call alias()

Actual behavior

The contact alias not be set to new_alias in the Wechaty after call alias()
It still keep the old alias().
NOTE: this also happen when new friend being added, and it only be correct alias after Wechaty docker restart

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

None for now.
It may be sync issue with cache.

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:
10:26:26 VERB Puppet selfId()
10:26:26 VERB Contact friend()
10:26:26 SILL Contact alias()
old_alias
10:26:26 SILL Contact alias(new_alias))
10:26:26 VERB PuppetPadchat contactAlias(wxid_, new_alias)
10:26:26 SILL PadchatRpc rpcCall(WXSetUserRemark, ["wxid_","new_alias"])
10:26:26 SILL PadchatRpc WXSetUserRemark result: {"message":"","status":0}
10:26:26 SILL Contact ready() @ Puppet#0<PuppetPadchat>(Ponyo)/PuppetPadchat#0
10:26:26 SILL Contact ready() isReady() true
10:26:29 SILL PadchatRpc onSocketTencent() discard empty message msg_id payoad: {"continue":0,"msg_type":32768,"status":1,"uin":488036821}
10:26:29 SILL PadchatRpc initHeartbeat() throttleQueue.subscribe(ws.on(message))
10:26:29 SILL PuppetPadchat startWatchdog() padchatManager.on(heartbeat)
10:26:29 SILL Wechaty memoryCheck() free: 151 MB, require: 4 MB
10:26:31 SILL Contact alias()
contact name Alias: old_alias
10:26:33 SILL Wechaty start() setInterval() this timer is to keep Wechaty running...
10:26:49 SILL PadchatRpc initHeartbeat() debounceQueue.subscribe(ws.on(message))
10:26:49 SILL PadchatRpc rpcCall(WXHeartBeat, [])
10:26:50 SILL PadchatRpc initHeartbeat() throttleQueue.subscribe(ws.on(message))
10:26:50 SILL PuppetPadchat startWatchdog() padchatManager.on(heartbeat)
10:26:50 SILL Wechaty memoryCheck() free: 152 MB, require: 4 MB
10:26:50 SILL PadchatRpc WXHeartBeat result: {"status":0,"message":"ok"}
10:26:50 SILL PadchatRpc initWebSocket() ws.on(pong)
10:26:51 SILL PadchatRpc onSocketTencent() discard empty message msg_id payoad: {"continue":0,"msg_type":32768,"status":1,"uin":488036821}

@kis87988 kis87988 changed the title contact not sync after call contact.alias(string) contact alias not sync after call contact.alias(string) to set alias Jul 31, 2018
huan added a commit that referenced this issue Jul 31, 2018
huan added a commit that referenced this issue Jul 31, 2018
@huan
Copy link
Member

huan commented Jul 31, 2018

Good catch.

Please try v0.19.119 or above, it should be solved.

@huan huan added the bug label Jul 31, 2018
@kis87988
Copy link
Contributor Author

kis87988 commented Aug 1, 2018

Another might be slimier issue/bug is if a new friends just being add.

bot.on('friendship', async friendship =>
{
    let logMsg
    try
    {
        logMsg = 'received `friend` event from ' + friendship.contact().name()
        console.log(logMsg)
        switch (friendship.type())
        {
            case Friendship.Type.Receive:
                logMsg = 'accepted automatically'
                await delay(10000)
                await friendship.accept()      
                break
            case Friendship.Type.Confirm:
                logMsg = 'friend ship confirmed with ' + friendship.contact().name()
                await delay(10000)
                await friendship.contact().sync()
                let fs = await friendship.contact().friend()
                console.log(fs) //////////////// false, but it should be true
                break
        }
    } catch (e)
    {
      logMsg = e.message
    }
    console.log(logMsg)
})

After 10s, it should force refrash contact for new add friends as well.
Do I need to create another issue for this or keep it in this issue as well?

@huan
Copy link
Member

huan commented Aug 2, 2018

It's great that you pointed this out.

I suggest we should create another issue for this, and would you like to send a PR to fix this? because you already had the code above.

@huan
Copy link
Member

huan commented Aug 2, 2018

Please close this issue after it's done, thanks.

@kis87988
Copy link
Contributor Author

kis87988 commented Aug 2, 2018

Yes, I just confirmed this issue has been fix.
Just also put a note
If bot's friends(some people) change alias(correction: name) name during the bot is running, the bot's cache can not detect the contact change alias(correction: name), but it will be detect when next restart wehchaty

@huan
Copy link
Member

huan commented Aug 2, 2018

What did you mean bot's friend change alias during the bot is running?

I do not think the alias can be changed other than the bot itself.

@kis87988
Copy link
Contributor Author

kis87988 commented Aug 2, 2018

I am sorry for mistypo, what I mean is bot's friends change name

@huan
Copy link
Member

huan commented Aug 2, 2018

Yes, currently we are leaking of the events that notice the bot of those changes.

Hope this situation can be changed in the future.

@kis87988
Copy link
Contributor Author

kis87988 commented Aug 2, 2018

Nice. This bug has been fix

@kis87988 kis87988 closed this as completed Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants