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

First version of private-mode, invite-only WeChat #11

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

lucyhe
Copy link
Contributor

@lucyhe lucyhe commented Nov 12, 2015

Invite v1 implementation:

  • users become friends if they both mutually invite each other to be uProxy contacts
    • invites sent and received are tracked by this.invitesSent and this.invitesReceived (these are also saved in local storage)
    • this.invitesSent and this.invitesReceived are maps from WXIDs (a unique, fixed identifier for each contact) to the timestamp of when the invite was created
    • if a contact's WXID exists in a user's this.invitesSent and this.invitesReceived, then that contact is a uProxy friend
  • users choose which of their WeChat contacts to invite via the uProxy UI (UI for WeChat invites UWNetworksLab/uProxy-p2p#2043), which sends invite messages over WeChat
    • the messages are sent with type "51" which should make the messages invisible, although this has been flaky
  • only inviteUser is implemented; acceptUserInvitation should be implemented when we have a concept of "accepting" invites rather than sending reciprocal invites

Invites get tricky because you might send invites to offline friends (WeChat does not yet have presence/a heartbeat). To resolve this, two things were necessary:
(1) On login, resend invites to all users who are in invitesSent but not in invitesReceived
(2) If we receive an invite from someone in invitesSent but not invitesReceived, assume they did not receive your invite, and resend an invite back.

Both invites sent to online users.
A and B are both online.
A sends invite to B.
B receives invite.
B sends invite to A. A is now a friend.
A receives invite. B is now a friend.
(Because of (2) above, A sends another invite back to B, because it is not sure if B received the original invite, but this additional invite effectively does nothing.)

One invite is sent to offline user.
A is online. B is offline.
A sends invite to B.
B comes online.
B sends invite to A.
A receives invite. B is now a friend.
Again, because of (2) above, A sends another invite back to B.
B receives invite. A is now a friend.

Both invites are sent to offline users; they become friends when they are both online together.
A and B are both offline.
A comes online.
A sends invite to B.
A goes offline.
B comes online.
B sends invite to A.
A comes online.
Because of (1), A sends an invite to B.
B receives invite. A is now a friend.
Because of (2), B sends another invite back to A.
A receives invite. B is now a friend.

The reason (2) doesn't cause an infinite loop of invites is that we have two types of invites. INVITE and RETURN_INVITE. Users only respond to INVITE's with RETURN_INVITE's.

Another note: this removes the chatrooms, so would it be better if this is in another branch?
Also: investigate chatroom icon errors?

@willscott
Copy link
Member

Do you have / need a reviewer for this?

@@ -208,41 +191,33 @@ WechatSocialProvider.prototype.initHandlers_ = function() {
var selfContact = this.client.thisUser.UserName;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove: + Object.keys(this.client.chatrooms).length

@lucyhe
Copy link
Contributor Author

lucyhe commented Dec 3, 2015

Oh! It's almost ready (working through a few things with Spencer). Can I ping you? Thank you!!!

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

Successfully merging this pull request may close these issues.

3 participants