Merge 0.10->trunk
[prosody.git] / plugins / muc / occupant.lib.lua
index 5cecb139915205967e3b89d1b7a481b192acf6fe..8fe4bbdf12b5f19c2c1d45d82a86b4dbadd74cb9 100644 (file)
@@ -1,22 +1,10 @@
-local next = next;
 local pairs = pairs;
 local setmetatable = setmetatable;
 local st = require "util.stanza";
+local util = module:require "muc/util";
 
-local get_filtered_presence do
-       local presence_filters = {
-               ["http://jabber.org/protocol/muc"] = true;
-               ["http://jabber.org/protocol/muc#user"] = true;
-       }
-       local function presence_filter(tag)
-               if presence_filters[tag.attr.xmlns] then
-                       return nil;
-               end
-               return tag;
-       end
-       function get_filtered_presence(stanza)
-               return st.clone(stanza):maptags(presence_filter);
-       end
+local function get_filtered_presence(stanza)
+       return util.filter_muc_x(st.clone(stanza));
 end
 
 local occupant_mt = {};
@@ -53,7 +41,7 @@ end
 -- finds another session to be the primary (there might not be one)
 function occupant_mt:choose_new_primary()
        for jid, pr in self:each_session() do
-               if pr.attr.type ~= "unavailable" then
+               if pr.attr.type == nil then
                        return jid;
                end
        end