Verified Contacts Notifications
Right now we have Users::saveContactsFromLinks as well as hooks Users_after_Users_setMobileNumber and Users_after_Users_setEmailAddress, we are going to use the Streams plugin in addition to the Users plugin to do it the "distributed" way.
When a futureUser is created, create a stream published by the $app user with the type "Streams/identify" and name "Streams/identify/$hash", where $hash is the Q_Utils::hash($identifier), $identifier is "$type:$normalized"and $type is one of "email", "mobile", "facebook", "twitter".
When inviting a futureUser or importing links using Users::addLink, the app will create this stream (if it doesn't already exist) from the identifier type and value. And the logged-in user will be subscribed to the stream. We don't need our install scripts to save any streams_subscription or streams_rule templates for "Streams/identify/" because the subscriptions and rules for this stream will be added in the generic way when the user subscribes.
Now, create an event called "Users/verified" and call it from Users::setMobileNumber, Users::setEmailAddress and Users::authenticate when the user's state has been set to "verified" and the user row was saved. Pass the $type and $value to this event. In the Streams plugin, make a default handler for this event, which will post a message to the "Streams/identify/$hash"stream published by the $app user. The type of the message will be "Streams/identify/verified" and its content and instructions can be empty.
Implement a handler in Streams.js for the "Streams/identity/verified" message if it's sent by socket.io, that will add a Q.Notice (https://github.com/EGreg/Q/issues/11) with the appropriate message and a link.
Implement a handler for the notification about "Streams/identity/verified", which would run before the notification is delivered to mobile or email destinations. This handler, which should be in Node.js, will delete the users_link and insert a users_contact. The "nickname" in the contact is set from the "firstName" and "lastName" in the link.
After this, implement the Contacts Front End API https://github.com/EGreg/Q/issues/10