Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event_sync, feat: add number of active occupants to join/left events #35

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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