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 committed Oct 19, 2024
1 parent 6a17e19 commit 8fde704
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
* occupant
* occupant_jid
* joined_at
Expand All @@ -87,6 +88,7 @@ Example:
"room_name": "catchup",
"room_jid": "[email protected]",
"is_breakout": false,
"active_occupants": 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
* occupant
* occupant_jid
* joined_at
Expand All @@ -121,6 +124,7 @@ Example:
"room_name": "catchup",
"room_jid": "[email protected]",
"is_breakout": false,
"active_occupants": 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()
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'] = room_data:get_active_occupants();
};
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'] = room_data:get_active_occupants();
};
update_with_room_attributes(payload, room);

Expand Down

0 comments on commit 8fde704

Please sign in to comment.