From 0487f34a01ccb1a9736ad06cd3377d29067c689e 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 f1e0f5c8dd0fe96c8804161e16371305c9460d22 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 8a606428256ba0bbedf06e7b1798fafecc75c052 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 cb9b053d061266a0fbf2111ed631574845cb27e4 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 943e6be943dae4b05ac76d34176b5e6efd66115c 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