Pārlūkot izejas kodu

feat: Fixes filtering not needed presences.

We were filtering only self presences, no it filters and the presences to the other participants.
j8
damencho 4 gadus atpakaļ
vecāks
revīzija
2e308d67d8
1 mainītis faili ar 14 papildinājumiem un 4 dzēšanām
  1. 14
    4
      resources/prosody-plugins/mod_muc_allowners.lua

+ 14
- 4
resources/prosody-plugins/mod_muc_allowners.lua Parādīt failu

@@ -111,15 +111,25 @@ module:hook_global('config-reloaded', load_config);
111 111
 -- Filters self-presences to a jid that exist in joining_participants array
112 112
 -- We want to filter those presences where we send first `participant` and just after it `moderator`
113 113
 function filter_stanza(stanza)
114
-    if not stanza.attr or not stanza.attr.to or stanza.name ~= "presence" then
114
+    -- when joining_moderator_participants is empty there is nothing to filter
115
+    if next(joining_moderator_participants) == nil or not stanza.attr or not stanza.attr.to or stanza.name ~= "presence" then
116
+        return stanza;
117
+    end
118
+
119
+    local muc_x = stanza:get_child('x', MUC_NS..'#user');
120
+    if not muc_x then
115 121
         return stanza;
116 122
     end
117 123
 
118
-    -- Allow self-presence (code=110)
119 124
     local bare_to = jid_bare(stanza.attr.to);
125
+    if joining_moderator_participants[bare_to] and presence_check_status(muc_x, '110') then
126
+        -- skip the local presence for participant
127
+        return nil;
128
+    end
120 129
 
121
-    if joining_moderator_participants[bare_to] then
122
-        if presence_check_status(stanza:get_child('x', MUC_NS..'#user'), '110') then
130
+    -- skip sending the 'participant' presences to all other people in the room
131
+    for item in muc_x:childtags('item') do
132
+        if joining_moderator_participants[jid_bare(item.attr.jid)] then
123 133
             return nil;
124 134
         end
125 135
     end

Notiek ielāde…
Atcelt
Saglabāt