Software /
code /
prosody
Comparison
plugins/muc/presence_broadcast.lib.lua @ 10685:98f21a155737
MUC: Don't unconditionally broadcast presence with role="none"
Detailed explanation in de607875d4bd. A presence with role="none"
(which is always type="unavailable") should only be broadcast if
available presence was previously broadcast for that occupant.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 12 Mar 2020 14:13:22 +0000 |
parent | 10516:d3e6941546a8 |
child | 10687:8c2c5b4fde32 |
comparison
equal
deleted
inserted
replaced
10684:de607875d4bd | 10685:98f21a155737 |
---|---|
9 | 9 |
10 local st = require "util.stanza"; | 10 local st = require "util.stanza"; |
11 | 11 |
12 local valid_roles = { "visitor", "participant", "moderator" }; | 12 local valid_roles = { "visitor", "participant", "moderator" }; |
13 local default_broadcast = { | 13 local default_broadcast = { |
14 none = true; | |
15 visitor = true; | 14 visitor = true; |
16 participant = true; | 15 participant = true; |
17 moderator = true; | 16 moderator = true; |
18 }; | 17 }; |
19 | 18 |
21 return room._data.presence_broadcast or default_broadcast; | 20 return room._data.presence_broadcast or default_broadcast; |
22 end | 21 end |
23 | 22 |
24 local function set_presence_broadcast(room, broadcast_roles) | 23 local function set_presence_broadcast(room, broadcast_roles) |
25 broadcast_roles = broadcast_roles or default_broadcast; | 24 broadcast_roles = broadcast_roles or default_broadcast; |
26 | |
27 -- Ensure that unavailable presence is always sent when role changes to none | |
28 broadcast_roles.none = true; | |
29 | 25 |
30 local changed = false; | 26 local changed = false; |
31 local old_broadcast_roles = get_presence_broadcast(room); | 27 local old_broadcast_roles = get_presence_broadcast(room); |
32 for _, role in ipairs(valid_roles) do | 28 for _, role in ipairs(valid_roles) do |
33 if old_broadcast_roles[role] ~= broadcast_roles[role] then | 29 if old_broadcast_roles[role] ~= broadcast_roles[role] then |