Sfoglia il codice sorgente

feat: Visitors stats (#13139)

* fix: Fixes mac occupants check logic.

Now works and with missing muc_access_whitelist option.

* feat: Adds visitor stats.

* squash: Drops check for healthcheck room.
factor2
Дамян Минков 2 anni fa
parent
commit
275e7b00a9
Nessun account collegato all'indirizzo email del committer

+ 30
- 0
resources/prosody-plugins/mod_fmuc.lua Vedi File

25
 
25
 
26
 local NICK_NS = 'http://jabber.org/protocol/nick';
26
 local NICK_NS = 'http://jabber.org/protocol/nick';
27
 
27
 
28
+-- we send stats for the total number of rooms, total number of participants and total number of visitors
29
+local measure_rooms = module:measure("vnode-rooms", "amount");
30
+local measure_participants = module:measure("vnode-participants", "amount");
31
+local measure_visitors = module:measure("vnode-visitors", "amount");
32
+
28
 -- This is the domain of the main prosody that is federating with us;
33
 -- This is the domain of the main prosody that is federating with us;
29
 local fmuc_main_domain;
34
 local fmuc_main_domain;
30
 
35
 
294
             "Private messaging is disabled on visitor nodes"));
299
             "Private messaging is disabled on visitor nodes"));
295
     return true;
300
     return true;
296
 end, 10);
301
 end, 10);
302
+
303
+-- we calculate the stats on the configured interval (60 seconds by default)
304
+module:hook_global("stats-update", function ()
305
+    local participants_count, rooms_count, visitors_count = 0, 0, 0;
306
+
307
+    -- iterate over all rooms
308
+    for room in prosody.hosts[module.host].modules.muc.each_room() do
309
+        rooms_count = rooms_count + 1;
310
+        for _, o in room:each_occupant() do
311
+            if jid.host(o.bare_jid) == main_domain then
312
+                visitors_count = visitors_count + 1;
313
+            else
314
+                participants_count = participants_count + 1;
315
+            end
316
+        end
317
+        -- do not count jicofo
318
+        participants_count = participants_count - 1;
319
+    end
320
+
321
+    measure_rooms(rooms_count);
322
+    measure_visitors(visitors_count);
323
+    measure_participants(participants_count);
324
+end);
325
+
326
+

+ 2
- 2
resources/prosody-plugins/mod_muc_max_occupants.lua Vedi File

30
   end
30
   end
31
   -- If we're a whitelisted user joining the room, don't bother checking the max
31
   -- If we're a whitelisted user joining the room, don't bother checking the max
32
   -- occupants.
32
   -- occupants.
33
-  if whitelist and whitelist:contains(domain) or whitelist:contains(user..'@'..domain) then
33
+  if whitelist and (whitelist:contains(domain) or whitelist:contains(user..'@'..domain)) then
34
     return;
34
     return;
35
   end
35
   end
36
 
36
 
53
 		-- from the count.
53
 		-- from the count.
54
 		for _, occupant in room:each_occupant() do
54
 		for _, occupant in room:each_occupant() do
55
 			user, domain, res = split_jid(occupant.bare_jid);
55
 			user, domain, res = split_jid(occupant.bare_jid);
56
-			if not whitelist:contains(domain) and not whitelist:contains(user..'@'..domain) then
56
+			if not whitelist or (not whitelist:contains(domain) and not whitelist:contains(user..'@'..domain)) then
57
 				slots = slots - 1
57
 				slots = slots - 1
58
 			end
58
 			end
59
 		end
59
 		end

Loading…
Annulla
Salva