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

The Research about roomMemberPayloadDirty #12

Open
hcfw007 opened this issue Jul 13, 2022 · 0 comments
Open

The Research about roomMemberPayloadDirty #12

hcfw007 opened this issue Jul 13, 2022 · 0 comments

Comments

@hcfw007
Copy link
Member

hcfw007 commented Jul 13, 2022

When we uprade to wechaty 1.x, we found that there are many errors in server-side like this:

01:20:04 ERR PuppetServiceImpl grpcError() contactPayload() rejection: ERR_INVALID_CONTACT_ID all ids should be number, R:10904522578147112 is not a number.
Error: ERR_INVALID_CONTACT_ID all ids should be number, R:10904522578147112 is not a number.

ref: https://github.com/juzibot/wechaty-puppet-wxwork/issues/720

That is cuased by these code:
https://github.com/wechaty/wechaty/blob/fd31dffaf2af0cce2d3ad7e57ae47a50e1b41aa1/src/wechaty-mixins/puppet-mixin.ts#L436-L449

We can see that when receiving a roomMemberDirty event, the payload will be handled as a contact id, and we try to load the contact with that id.
However when reading this code:
https://github.com/wechaty/wechaty/blob/fd31dffaf2af0cce2d3ad7e57ae47a50e1b41aa1/src/wechaty-mixins/puppet-mixin.ts#L388-L391

https://github.com/wechaty/wechaty/blob/fd31dffaf2af0cce2d3ad7e57ae47a50e1b41aa1/src/user-modules/room.ts#L300-L304

We can see that roomMemberPayloadDirty uses a room id as parameter.

This is very confusing. After a discussion with @su-chang , we decided to use contact id. Because roomMember is a contact. So we came up with this PR:
#6

It will dirty all room members when room syncs and that solves the problem of ERR_INVALID_CONTACT_ID. However this causes abundant dirty calls so we addpatch for that in #10.

However when we read the code in wechaty-puppet-wxwork, https://github.com/juzibot/wechaty-puppet-wxwork/blob/6b9b737f823104e7809a131baceb27e798a75ae3/src/puppet-work.ts#L801-L803, we noticed that roomMemberPayload should accept a room id at the very begining. And this will natually solves the problem of abundant dirty calls. So the thing we are gonna do is:

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

1 participant