Skip to content

Commit

Permalink
feat(event_sync): add number of active occupants to join/left events
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtakingiteasy authored and shawnchin committed Oct 21, 2024
1 parent 6a17e19 commit ecfdcdc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions event_sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_count (current number of active occupants, including the one that just joined)
* occupant
* occupant_jid
* joined_at
Expand All @@ -87,6 +88,7 @@ Example:
"room_name": "catchup",
"room_jid": "[email protected]",
"is_breakout": false,
"active_occupants_count": 4,
"occupant": {
"name": "James Barrow",
"email": "[email protected]",
Expand All @@ -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_count (current number of active occupants, excluding the one that just left)
* occupant
* occupant_jid
* joined_at
Expand All @@ -121,6 +124,7 @@ Example:
"room_name": "catchup",
"room_jid": "[email protected]",
"is_breakout": false,
"active_occupants_count": 3,
"occupant": {
"name": "James Barrow",
"email": "[email protected]",
Expand Down
12 changes: 12 additions & 0 deletions event_sync/mod_event_sync_component.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ function EventData:get_occupant_array()
return output;
end

--- Returns number of active occupants
function EventData:get_active_occupants_count()
local output = 0;
for _ in pairs(self.active) do
output = output + 1
end

return output;
end

--- End EventData implementation


Expand Down Expand Up @@ -291,6 +301,7 @@ function occupant_joined(event)
local payload = {
['event_name'] = 'muc-occupant-joined';
['occupant'] = occupant_data;
['active_occupants_count'] = room_data:get_active_occupants_count();
};
update_with_room_attributes(payload, room);

Expand Down Expand Up @@ -323,6 +334,7 @@ function occupant_left(event)
local payload = {
['event_name'] = 'muc-occupant-left';
['occupant'] = occupant_data;
['active_occupants_count'] = room_data:get_active_occupants_count();
};
update_with_room_attributes(payload, room);

Expand Down

0 comments on commit ecfdcdc

Please sign in to comment.