EGreg / Platform-history

The Qbix Platform for powering Social Applications
http://qbix.com/platform
GNU Affero General Public License v3.0
21 stars 5 forks source link

Refactor invites #6

Open EGreg opened 10 years ago

EGreg commented 10 years ago

Right now, displayName in invites refers to the display name of the inviting user. Let's change this and improve invites.

First of all, have scripts/Streams/0.8.1-Users.mysql insert a users_label called "Streams/invited", with the title "Invited". Also whenever the "Streams/user/firstName" and "Streams/user/lastName" streams are created, create streams_access rows for them to grant read access to all contacts with label "Streams/invited". This will replace displayName as the way that the inviting user's name will be displayed to users who were invited.

When sending a POST request to Streams/invite, add contacts with "Streams/invited" label for all the invited users, including the futureUsers. Check for streams_access rows with label "Streams/invited" for "firstName" and "lastName" and use those to calculate the displayName for each user being invited. (Later, we might make the label customizable in the options to Streams::invite.) This displayName will be sent to Node as it currently is being sent. Make sure that the Node code uses this and not displayName from any database fields.

Also while handling the above POST, insert a label with name "Streams/invited\t$streamType" for the inviting user, and title = "Invited to $Title" (where $Title is obtained from the stream's template, if any, or is otherwise Foo where streamType is "$Module/$foo"). Add contacts with this label for all the invited users, including the futureUsers.

Now, update the version of the Streams plugin to 0.8.1 . Have the scripts/Streams/0.8.1-Streams.mysql ALTER TABLE to rename streams_invite.displayName to streams_invite.fullName. This field will not be used anymore to record the displayName for invites. Instead, it will be used for zero-step invites, i.e. when the fullName of the invited user has already been set by the inviting user. Here is how:

When a user accepts an invite that has a fullName set, and the user's displayName is empty, then that fullName will be set similar to how Streams_basic_post does it, in the app. (In the future, the app may choose some external Personal Server app, such as Invites, for handling sending the invites and managing the invited user's account. It will use OAuth to get a user xid from that server and use that.)

The Streams_after_Q_objects hook will now see followedInvite but won't ask to show a dialog because the user's displayName would have already been set. Which implements the zero-step invites.

EGreg commented 10 years ago

Also have scripts/Streams/0.8.1-Users.mysql insert another users_label named "Streams/invitedBy", with the title "Invited By".

When accepting an invitation from a user, the Streams plugin will add this user as contact under this label. Also insert a label with name "Streams/invited\t$streamType" for the invited user, and title = "Invited to $Title" (where $Title is obtained from the stream's template, if any, or is otherwise Foo where streamType is "$Module/$foo"). Add a contact under this label for the inviting user.