Hello,

A simple question : is it possible to get a more large logging display with "Friends of my friends" ??

I use the heartbeat + rules modules to display a facebook-like wall. Now if I create a rule to log "become friends" actions in the wall, I have two possibilities :

1. using uid of requester (a friend of myself) as "message uid" and using uid of the requestee (I'm not friend with) as "message target uid"
2. using uid of the requester as "message uid" and "message target uid" too.

In the first case, the log isn't displayed in my wall because I'm not friend with the new friend of my existing friend.
In the second case, the log is displayed because uid and target_uid are same, my existing friend. But :
- I can't access to the uid of the target user (which is not my friend now, but I would like to add a "become a friend too" link to it)
- If the requester is not my friend, I'll don't see the message, even if the requestee is one of my friends...

I don't want to open the logs to all people, but it would be great if it's possible to manage the access to said : use "uid" OR "target_uid" to matches a relationship (if at least one of those is friend with me, the message will be displayed).

Can you see a way to achieve this without made modifications in heartbeatmessagebuilder.inc ??

Thanks in advance for any suggestion :-)

Comments

Stalski’s picture

1. You can add a new stream and create a query that will cover friends of friends. That's not built in, but should be easy with a custom registered stream.

2. I don't know what your question is exactly for the logging of "user becomes friends". There are example available by default in the friendlist activity module. Please check that or just use it.
Note that this has nothing to do with the stream building. User becomes friends with another user is only a custom message. The fact that requester and requestee exists in your favorite user relations module is the part where you can achieve friends of friends.
I would just add / override the hook_heartbeat_get_related_uids and thus expand it with your logic.

3. You don't need to change the message builder for this. You need custom streams and / or custom altering of the calculation of user lists.

Heartbeat as API is not too easy, but all your requests are possible with custom streams and a bit of overrides.

titouille’s picture

Thanks Stalski for your answers...

I tried lot of solutions but can't get it working correctly. I explain :

First, I use the User-relationships module and it's enabled in heartbeat settings. All my messages are configured to be displayed "only to user and it's relations".

I must have 4 streams :

1. All, (publicheartbeat) must display all messages (medias, network and personal (but no shouts from personal), see above)

2. Medias only (custom stream based on publicheartbeat), must display only specific heartbeat message called "heartbeat_media_add_news". I use a double filter : the first is on the stream to display only "heartbeat_media_add_news" and the second is with hook_heartbeat_messages_alter to find only the news of medias the user has registered.

3. Network only (connectedheartbeat): must display only messages from my network.

4. Personal only (privateheartbeat) : must display only messages from which I'm an actor (my actions, or actions of other users on me, ie : become a friend with me, shoot message to me, etc...)

Now this is the third stream which cause problems... The goal is to have the following messages :

Each actions of people in my network (my friends), and when one of my friend become a friend of another person or become a fan of an entity.
It's here the problem occurs : when "become a friend" between A and B is logged, if I'm only friend with A, the message is filtered and I can't see it.
I can use the requester_uid as uid and target_uid of the message to have the message displayed on my wall, but in this case, I don't know about requestee uid (normally in target_uid).
I can use a hook_heartbeat_related_uid_info to return list of my friends and their friends (fof), but in this case, all actions made by fof are displayed in my wall, and I want to have only "become a friend/fan" actions displayed...

In other words : on my own wall, I'm interested with actions of my friends, not fof. But when one of my friend become friend with a person who isn't my friend, I want to see this log, and retrieve informations about this person (ie to display a link like : become a friend too).

I'm searching a solution to display correct informations. This is really in "network_only" that I have problems to display that I want...

If you can show me a way to do the trick it would be very helpful. Thanks in advance.

titouille’s picture

Maybe I don't understand correctly the way to achieve my goal, but I think the following :

Even if I create my own stream class, I can't change the whoIsActor to call another function to retrieve relationships, because in heartbeatmessagebuilder -> checkAccess, this is the heartbeat_get_related_uids which is called.
The only way I see to change dynamically the content of related uids switch stream is to invoke hook_heartbeat_related_uid_info( &$uids, $uid, $stream ) as parameters to be able to completely override the uid's list switch the displayed stream... But like I said, maybe I completely missing the correct way to filter messages and display streams...

titouille’s picture

How, I had an idea, can you tell me if it's the correct way to do what I want :

1. declare "heartbeat_user_add_friend" as message to all community (privacy setting).
2. create a new stream and change sql query to add something like this :

if message.heartbeat_user_add_friend
AND ( if message.uid is one of my friend or fof
OR if message.target_uid is one of my friend or fof )

With this, I can get only "become a friend" message from my friend and my fof.

Actually, I suspect because of privacy of the "heartbeat_user_add_friend" (only my relationships) I can get all messages but when the builder occurs, messages from my non-friends are automatically removed...

Can you simply tell me if it's correct way to set privacy to all and to modify a custom stream to get all I want with activity messages ?

Thanks

Stalski’s picture

I think that's about right yes.
The module does not provide rules how to built activity streams or news feeds or whatever. You can do what you seem is good.
I don't think there is a problem with the approach you are taking. I cannot say for sure there is an easier way.

Stalski’s picture

Status: Active » Closed (works as designed)

I'll close this, but you can always let me know how it worked out, and maybe provide information to help others.
Even so, if it's a good solution, I might end up committing it as a feature.

titouille’s picture

Hi Stalski,

I finally get it working by create some classes extends Heartbeat access with specific dressUpMessages function for each, to retrieve only requested data.

One thing I don't have understand is about privacy of messages. If I remember, it was difficult to show for example my own status message (with shout) in the "friends-activity" because own activity is only displayed on personal heartbeat, but it's maybe that I don't have set correct parameters... skipActiveUser is on FALSE.

In same case, I encounted problems to show informations between relations, ie :

User 1 is an entity, any user can become fan of it.
User 2 is a friend of mine, and fan of User 1.
User 3 isn't friend of mine, but is also fan of User 1.

Message will not be displayed if the actor isn't one of my friend, even if I'm friend with the entity. Because it's the actor which take priority, not the target.

So I must invert message to said "entity has now a new fan : user xyz" instead of "user xyz is now fan of entity". Because if user is actor and user isn't my friend, message will be blocked...

Maybe I don't have all understand, but it's possible to have a "blank" canvas and setup some sql queries to retrieve all data we want to display, without another permissions to check ( heartbeatmessagebuilder.checkAccess( ... ) ).

At first implementation, I believed that I can simply use the query I want to fill the heartbeat stream, but it's additional permissions checked internally, and with this I can't manipulate data like I want to show only what I want.

If there is a way to achieve stream only by using sql, and disabled additional permissions checks, can you explain it quickly ?

Thanks in advance

aliyayasir’s picture

Please take a look at Suggest a Friend module
http://drupal.org/project/suggest-a-friend

Stalski’s picture

@titouille : You can just implement the hook_register_access_type (D6 this issue is for, in D7 it's heartbeat_register_stream_info or something). In that stream you override the query method(s).