From 3e15f71ed1009637849f478352b271b6f11b7f51 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 5 Jul 2017 04:38:08 +0200 Subject: mod_mam: Request a total count if no items are requested --- plugins/mod_mam/mod_mam.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index b40b8a9a..1dcce4e4 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -141,7 +141,7 @@ module:hook("iq-set/self/"..xmlns_mam..":query", function(event) limit = qmax + 1; before = before; after = after; reverse = reverse; - total = use_total; + total = use_total or qmax == 0; }); if not data then -- cgit v1.2.3 From 04d52fd099de46112313d47ded426e56938686ea Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 5 Jul 2017 05:44:56 +0200 Subject: mod_storage_internal: Return a noop iterator if archive is empty (fixes #920) --- plugins/mod_storage_internal.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua index 0a382cee..76052575 100644 --- a/plugins/mod_storage_internal.lua +++ b/plugins/mod_storage_internal.lua @@ -62,7 +62,13 @@ end function archive:find(username, query) local items, err = datamanager.list_load(username, host, self.store); - if not items then return items, err; end + if not items then + if err then + return items, err; + else + return function () end, 0; + end + end local count = #items; local i = 0; if query then -- cgit v1.2.3 From 19f9d45e8ca19778137a0a571ed127cdd26c1fac Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 6 Jul 2017 10:33:16 +0200 Subject: MUC: Include status code 110 on role change notifications (fixes #765)) --- plugins/muc/muc.lib.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index df4c50bb..79daad92 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -1083,17 +1083,20 @@ function room_mt:set_role(actor, occupant_jid, role, callback, reason) else occupant.role = role; end + local self_x = st.clone(x); + self_x:tag("status", {code = "110"}):up(); local bp; for jid,pres in pairs(occupant.sessions) do -- send to all sessions of the nick local p = st.clone(pres); p.attr.from = occupant_jid; p.attr.type = presence_type; p.attr.to = jid; - p:add_child(x); - self:_route_stanza(p); if occupant.jid == jid then - bp = p; + bp = st.clone(p); + bp:add_child(x); end + p:add_child(self_x); + self:_route_stanza(p); end if callback then callback(); end if bp then -- cgit v1.2.3 From c0ac4526f686ce1faf21891a6d1bcb242aba0b90 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 6 Jul 2017 10:36:22 +0200 Subject: MUC: Include status code 110 on affiliation changes (see #765) --- plugins/muc/muc.lib.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 79daad92..24582eae 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -1009,6 +1009,8 @@ function room_mt:set_affiliation(actor, jid, affiliation, callback, reason) x:tag("status", {code="321"}):up(); -- affiliation change end end + local self_x = st.clone(x); + self_x:tag("status", {code="110"}); local modified_nicks = {}; for nick, occupant in pairs(self._occupants) do if jid_bare(occupant.jid) == jid then @@ -1023,11 +1025,13 @@ function room_mt:set_affiliation(actor, jid, affiliation, callback, reason) p.attr.from = nick; p.attr.type = presence_type; p.attr.to = jid; - p:add_child(x); - self:_route_stanza(p); if occupant.jid == jid then - modified_nicks[nick] = p; + local bp = st.clone(p); + bp:add_child(x); + modified_nicks[nick] = bp; end + p:add_child(self_x); + self:_route_stanza(p); end end end -- cgit v1.2.3 From ae4828d86147bfe18e0e70416ac6c5c0130e5285 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 6 Jul 2017 10:40:00 +0200 Subject: MUC: Add some comments attempting to explain what presence and tag goes where --- plugins/muc/muc.lib.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 24582eae..8c486b87 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -1009,6 +1009,7 @@ function room_mt:set_affiliation(actor, jid, affiliation, callback, reason) x:tag("status", {code="321"}):up(); -- affiliation change end end + -- Your own presence should have status 110 local self_x = st.clone(x); self_x:tag("status", {code="110"}); local modified_nicks = {}; @@ -1026,6 +1027,7 @@ function room_mt:set_affiliation(actor, jid, affiliation, callback, reason) p.attr.type = presence_type; p.attr.to = jid; if occupant.jid == jid then + -- Broadcast this presence to everyone else later, with the public variant local bp = st.clone(p); bp:add_child(x); modified_nicks[nick] = bp; -- cgit v1.2.3