From 8fde704fb28e38ba181faad442a233d459649225 Mon Sep 17 00:00:00 2001 From: Alexander Tumin Date: Sat, 19 Oct 2024 21:49:12 +0300 Subject: [PATCH] feat(event_sync): add number of active occupants to join/left events --- event_sync/README.md | 4 ++++ event_sync/mod_event_sync_component.lua | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/event_sync/README.md b/event_sync/README.md index 8340c60..cad02dc 100644 --- a/event_sync/README.md +++ b/event_sync/README.md @@ -72,6 +72,7 @@ When an occupant joins, `POST ${api_prefix}/events/occupant/joined` is called wi * room_jid * is_breakout * breakout_room_id (only if is_breakout is true) +* active_occupants * occupant * occupant_jid * joined_at @@ -87,6 +88,7 @@ Example: "room_name": "catchup", "room_jid": "catchup@conference.meet.mydomain.com", "is_breakout": false, + "active_occupants": 4, "occupant": { "name": "James Barrow", "email": "j.barrow@domain.com", @@ -105,6 +107,7 @@ When an occupant leaves, `POST ${api_prefix}/events/occupant/left` is called wit * room_jid * is_breakout * breakout_room_id (only if is_breakout is true) +* active_occupants * occupant * occupant_jid * joined_at @@ -121,6 +124,7 @@ Example: "room_name": "catchup", "room_jid": "catchup@conference.meet.mydomain.com", "is_breakout": false, + "active_occupants": 3, "occupant": { "name": "James Barrow", "email": "j.barrow@domain.com", diff --git a/event_sync/mod_event_sync_component.lua b/event_sync/mod_event_sync_component.lua index 4680812..1e9678c 100644 --- a/event_sync/mod_event_sync_component.lua +++ b/event_sync/mod_event_sync_component.lua @@ -187,6 +187,16 @@ function EventData:get_occupant_array() return output; end +--- Returns number of active occupants +function EventData:get_active_occupants() + local output = 0; + for _ in pairs(self.active) do + output = output + 1 + end + + return output; +end + --- End EventData implementation @@ -291,6 +301,7 @@ function occupant_joined(event) local payload = { ['event_name'] = 'muc-occupant-joined'; ['occupant'] = occupant_data; + ['active_occupants'] = room_data:get_active_occupants(); }; update_with_room_attributes(payload, room); @@ -323,6 +334,7 @@ function occupant_left(event) local payload = { ['event_name'] = 'muc-occupant-left'; ['occupant'] = occupant_data; + ['active_occupants'] = room_data:get_active_occupants(); }; update_with_room_attributes(payload, room);