We're running DrupalChat 7-beta10 on Drupal 7.15 with NodeJS RC1 and Flag Friend alpha 9.

The user list from the 'flag friend' relationship works great when DrupalChat is set to Ajax but when we switch to NodeJS (which is a really nice treat) it displays all users logged into the system instead of just the user's friends.

Any ideas or suggestions on where to look to debug?

Thanks!
Daniel

CommentFileSizeAuthor
#5 drupalchat-flag-friend.patch7.41 KBRolf van de Krol
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DanielWashbrook’s picture

I took a look in the nodejs.server.extension.js and it looks like when a user authenticates, NodeJS sends them user data for EVERY user that's already authenticated. Passed to the drupalchatNodejsMessageHandler callback, this in turn adds each user to the newly authenticated user's DrupalChat list.

So would a solution be to diff that list of every user with the user's buddy list?

It looks like the function _drupalchat_buddylist($uid) returns a list of the user's buddys.

I guess I'm stuck trying to figure out how to get the buddylist from the module into drupalchat_nodejs.js - Any thoughts?

Thanks!

darklrd’s picture

The buddylist should not be passed via JS (drupalchat_node.js) to node.js server, otherwise user may tamper with it. It should be directly sent via module to node.js server. Thanks.

heshanlk’s picture

Is there any hook that we can alter the online users, that way we can show only the online users not the everyone online. any thoughts?

plessas’s picture

I am trying to work on this, however i am having big trouble. As i understand the most important processing is done in the drupalchat_nodejs.server.extension.js file that is loaded from the nodejs server.
I can see there the messages that are logged for the nodejs server. It seems that when a page is loaded an authentication takes place and a message is sent to all online users that the user is online. I believe that if i could pass the friend list of the user when authenticating i would be able to send the message only to friends.

In line 16 of this file there is a function:

process.on('client-authenticated', function (sessionId, authData) {

This function takes as arguments the session id and the user id. However i don't know where it is called in the code with these arguments.

I was able to pass the friend list for the case:

.on('message-published', function (message, i) {

since i found in the drupalchat.module where this function is called and i was able to add the list in the $message variable. However i believe i haven't understood something correctly since now users can only chat with friends but when a user logs out, friends aren't notified and the list shows him/her online.

Rolf van de Krol’s picture

For Cordaan, we wrote the attached patch. This makes Drupalchat with NodeJS work with Flag Friend.

Warning: this is not a generic patch. Do not apply this patch if you do not want to use Drupalchat with NodeJS together with Flag Friend!

How does it work:

  • When Drupal and NodeJS communicate about the name of the user, we also send the buddylist.
  • The NodeJS extension is changed so it keeps those buddylists and only send online/offline notifications to buddies
  • When a new friend is approved or a friend is removed, we send a trigger to NodeJS. The NodeJS extension then updates the internal buddylists and sends online/offline notifications if needed.
Rolf van de Krol’s picture

Issue summary: View changes

Clarifying issue a bit.