- Edited
Never mind, I experimented a little and one of the following apparently fixed the problem:
- I renamed the migration file
- I replaced the
afrux-online-users-widget
toekumanov-online-users-widget
everywhere
Never mind, I experimented a little and one of the following apparently fixed the problem:
afrux-online-users-widget
to ekumanov-online-users-widget
everywhere@SychO, one final question. I see that there's a 40 seconds cache. Is that cache multithreaded and multi-user, i.e. having separate instance per-user or is it a shared global/singleton cache? I mean, is it possible that it's me, the admin, that refreshes the cache as an actor, and then lower-privileged users directly reading my version of the cache and see all online users (because I am an admin and can see everybody) instead of their own cached version with less users inside?
CyberGene Yes. And I would guess that's why i didn't initially add a permission check, sorry didn't remember. It's a trade-off to be made between wanting to cache the results to not compute that every time and wanting per-actor results.
You could ofc cache it per-actor. I don't do that in the extension because with big enough traffic the cache grows way too large too quickly as you can imagine, and that can lead to challenges with certain communities so generally not recommended.
SychO thanks, indeed it’s a tricky situation. Actually, now that I thought about it more, I believe the easiest way to workaround the situation is to have just two cache instances, one for the admins/mods (and those who have the permissions to always see online status) and one for the rest (the current one). When fetching the online users for a user request, the actor’s permissions will be determined and one of the two caches will be used. I’m pretty interested in implementing this, in my job I do exactly that type of stuff, however it’s Java backend and I’m not familiar with PHP and the frameworks that are used (I guess that’s Laravel?) but I may experiment a bit when I have more time. Thanks again for all your help with this extension and all you other dev so far and good luck with the forthcoming release
CyberGene oh that's smart. you would just need to change (at least smth like this)
$this->cache->remember('ekumanov-online-users-widget.users', ...
to
$suffix = $actor->hasPermission('user.viewLastSeenAt') ? '-permitted' : '-restricted';
$this->cache->remember('ekumanov-online-users-widget.users'.$suffix, ...
SychO that was really helpful! I implemented it and published it, now it is installed on my prod forum and seems to be working pretty fine. You’re great!
@SychO, currently the widget with my latest changes works as I wanted it, however the widget is not visible for non-admin/mods. That's actually OK for me since I needed that widget only for admin users, but for the sake of correctness, I think the reason is the following code from registerWidget.ts
:
isDisabled: () => {
const loadWithInitialResponse = app.forum.attribute('afrux-forum-widgets-core.preferDataWithInitialLoad');
return (!loadWithInitialResponse && (!app.forum.attribute('canViewLastSeenAt') || !app.forum.attribute('canSearchUsers')))
||
(loadWithInitialResponse && !app.forum.onlineUsers().length);
}
The way I understand it is that the widget will be disabled unless a user has both canViewLastSeenAt
and canSearchUsers
. I think most people wont give the canViewLastSeenAt
to non-mod users hence regular users won't see the widget.
I think what will fix it is replacing the OR with AND:
!app.forum.attribute('canViewLastSeenAt') && !app.forum.attribute('canSearchUsers'))
I changed that, however I believe I should somehow compile it, so that it goes into forum.js
, right? How is that done? I tried directly editing forum.js
(I know that's wrong but I just replaced a ||
with &&
in order to test), however I got HTTP 400, so maybe I messed it up.
Any advice? Is that change above any good, in the first place? And if yes, what's the easiest way to transpile the TS into JS?
Again, feel free to respond only when you have time
Admin: Yes I can see people.
Users / Members: I can't see people, is this problem?
No have allow.
Hi All!
Unfortunately, only the admin can see the widget, not the users.
Will this error be fixed or should I look for another solution?
Thank you for your reply in advance.
It seems to me that this PHP script is not optimized to work with version 8.3, and then delays loading the page. The extension is working, there are no questions
[Mon Sep 16 02:24:45.813877 2024] [fcgid:warn] [pid 52357] [client 46.138.185.215:0] mod_fcgid: stderr: PHP Deprecated: Creation of dynamic property Afrux\\OnlineUsers\\LoadForumOnlineUsersRelationship::$repository is deprecated in /var/www/user/data/www/forumspace.ru/vendor/afrux/online-users-widget/src/LoadForumOnlineUsersRelationship.php on line 29
Capybara make sure to disable deprecation warnings in your php.ini; production environments always should ignore these kind of warnings, check the php.ini or php documentation for more info. Once you've set up your php properly, the extension should work just fine.
I've also sent in a PR to remedy this warning: afrux/online-users-widget3
Full Changelog: afrux/online-users-widgetv0.1.6 → v0.1.7
SychO great, finally it works properly and I removed my half-baked clone that I’ve been using. Thank you!
As a suggestion for a next version: Maybe list the count of the invisible users in another circle? Such as e.g. “+6” meaning there are 6 more users. Can also be used to denote the number of online users above the threshold.
v0.1.8 should do the trick
SychO awesome, thanks!
P.S. Just tested it and I see how it works: it shows that "+N" badge for the number of users above the threshold. Is it possible to show such a badge for the invisible users too (those that hide their status)? It would give the users some idea about how active the forum is, otherwise if everyone is hiding their online status, then there will be no online users listed and it may give the false impression that the forum is dead