hey,

i was logged at facebook atm and a friend commented on a discussion i was involved.
i was online at this time as well and i saw a little js-box popping up with this log message: "your friend XXX commented on his post".

i thought: wow great feature, which contributes to page activity.

i do not know, if facebook only shows this for comment-replies (this can be integrated inti heartbeat as well), but i thought of a generic stream, who realizes some instantanous messages for online users: a live notification.

first i thought about rules integration: when hb-log is inserted, there can be an rules event thrown and some action be triggered, which produce this js-boxes on the next pageload of message adressees, if they are online.
but its too complex and i found finally: a bullshit approach ;)

but i found a generic and "simple" one:

1. we need a new stream "live notification"
2. there is a activity log selection for this stream as for every other stream with the additional restriction: select only messages, which have been inserted since last user-login-time (so we ensure, that every log is shown during the time the user is logged in and uses the portal active via single page requests; if he is lazy for some minutes he gets the whole new notifications after his next page request without logout inbetween)
3. one message, has to be shown for the user exactly 1 time! so, we have to log the view of the message by ths specific user (new logging table: uid/aid as primary key);
4. so there is a second new restriction for activity log selection: current user has not seen the message before!
5. the stream is shown automatized via in a little js-box after page was loaded (e.g. on the upper right corner of the screen): so it has to be imlemented very performant! therefore i propose to create a second activity_log_table, which holds only logs for the live notification and is cleaned via cron very often (all 1 or 2 days)
6. to decrease performance problems, may be there is a time threshold between 2 requests for the live notification stream per user: next pagecall with possible stream view only after XX secs (eg. 30 secs; config setting) passed since the last view
7. stream load can be realised via AJAX request for faster page load
8. in each case the requests have to be surpressed, if traffic in portal is too high -> may be use of drupals trottle module for an traffic indication

Finally a user sees all activities, which are adressed to him, "live" when he is online at time of activity logging.
I think this should be a standard submodule of the heartbeat package.

Comments

Stalski’s picture

Project: Heartbeat » Micro activity
Version: 6.x-4.10 » 6.x-1.0-beta1
Status: Active » Postponed

This is in fact possible in an even easier way.
We just provide a selection box of stream in the configuration section. For instance, you select the related stream as "live notification stream".
We also create a table that just holds the times and last message that is shown for each user. We trigger a js action that checks if something needs to be displayed on the user.
The only problem to encounter there, is to make sure that we don't display live notifications if we are viewing a stream. Then again, facebook does not check that either.

I still think this is more likely to be a separate module or make a patch for micro-activity. I am not eager to put this in heartbeat core at this moment. I am moving this to micro-activity so it still lives somewhere.