humhub / mail

A private messaging system for direct communication.

Home Page:https://marketplace.humhub.com/module/mail

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Display who is currently online

marc-farre opened this issue · comments

I need to add the possibility to display who is online, in the conversation and on the left panel of all conversations.
image

It also could be when adding a new user to a conversation:
image

@luke- do you prefer a PR, or should I create new module (e.g. messenger-advanced) for that?
Thanks!

@funkycram We need to check what is possible here with the user_session table. Possibly also mark logged in & inactive users differently (orange).

Additionally, users/operators should have the possibility to hide the online status.

@Eladnarlea Can you take a look here regarding the UI?

@funkycram @luke- what do you think?

I would suggest the following:

  1. display a green dot next to the person that is online
  2. don't display it in group chat preview (to see who's online you have got to click on participants list view-> green dot and (online) signalise the online status)
  3. for now we should integrate only the green dot and the (online) text instead of introducing several colors that display the different status options.

Screenshot 2023-05-03 at 8 43 03 AM

Screenshot 2023-05-03 at 8 56 15 AM

Thanks @luke- and @Eladnarlea . I agree with your suggestions @Eladnarlea , thanks for the screenshots, it will help me!

So I think I need to a property in humhub\modules\user\widgets\Image, perhaps public $showOnlineStatus = false. Have you got a better idea @luke- ?

We need to check what is possible here with the user_session table.

The session doesn't seem to be written in the DB.
If I'm logged in with user ID 1 and I do:

        $user = \humhub\modules\user\models\User::findOne(1);
        echo $user->getHttpSessions()->count();

I have 0.

I also tried var_dump($session->readSession(1)); but it returns an empty string.

And in my DB, I only have one line with a value nether changing:
image

On other Humhub instances, I can see many lines, so perhaps it's different depending some settings.

Anyway, I we have a JS calling humhub\modules\live\controllers\PollController every 20 seconds, only if the page is open in the browser.
Perhaps we could use this controller to update a cache? Something like:

Yii::$app->cache->set(self::CACHE_ONLINE_PREFIX . Yii::$app->user->id, true, 60); // Expires in 60 seconds

And then, we can know if a user is online with Yii::$app->cache->get(self::CACHE_ONLINE_PREFIX . $userId).

What do you think about this idea?

@funkycram Sounds good!

  • I like the feature humhub\modules\user\widgets\Image::$showOnlineStatus.
  • Would be great to have the "is online" handling logic in an extra service class e.g. humhub\modules\user\services\IsOnlineService.
  • Lets start with the Cache idea. Should be no big deal to change this logic afterwards, if everything is bundled in the service.

Thanks.
@luke- PR #328

@luke- Summary of this new feature:

@luke- Maybe we could merge this PR #328 now that Humhub 1.15 beta has been released?

@marc-farre Just merged. Can you please check it? There were some conflicts during merge.

@luke- Thanks for the warning.

Fixed in the same PR #350 as the one for #324 to avoid new conflicts again for only a single change in the less file.

Commit: 3ed802c

@marc-farre Thank you. I'll release the module vor the v15 users.