aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-01-14 16:55:18 +0000
committerMatthew Wild <mwild1@gmail.com>2022-01-14 16:55:18 +0000
commit2d0db1b0a3a9887f9c94b6a8e4e14836bd2747b9 (patch)
treecbad8d1776ef699e369c703f78313b6379f6ecea
parente0b15fcba3125d7f5f981f565a65f6bae770ace6 (diff)
downloadprosody-2d0db1b0a3a9887f9c94b6a8e4e14836bd2747b9.tar.gz
prosody-2d0db1b0a3a9887f9c94b6a8e4e14836bd2747b9.zip
mod_storage_xep0227: Skip self-contacts on roster import
-rw-r--r--plugins/mod_storage_xep0227.lua26
1 files changed, 15 insertions, 11 deletions
diff --git a/plugins/mod_storage_xep0227.lua b/plugins/mod_storage_xep0227.lua
index fa6bffc7..45cfaa77 100644
--- a/plugins/mod_storage_xep0227.lua
+++ b/plugins/mod_storage_xep0227.lua
@@ -238,6 +238,7 @@ handlers.roster = {
local xml = self:_get_user_xml(user, self.host);
local usere = xml and getUserElement(xml);
if usere then
+ local user_jid = jid.join(usere.name, self.host);
usere:remove_children("query", "jabber:iq:roster");
usere:maptags(function (tag)
if tag.attr.xmlns == "jabber:client" and tag.name == "presence" and tag.attr.type == "subscribe" then
@@ -248,18 +249,21 @@ handlers.roster = {
if data and next(data) ~= nil then
local roster = st.stanza("query", {xmlns='jabber:iq:roster'});
usere:add_child(roster);
- for jid, item in pairs(data) do
- if jid then
- roster:tag("item", {
- jid = jid,
- subscription = item.subscription,
- ask = item.ask,
- name = item.name,
- });
- for group in pairs(item.groups) do
- roster:tag("group"):text(group):up();
+ for contact_jid, item in pairs(data) do
+ contact_jid = jid.bare(jid.prep(contact_jid));
+ if contact_jid ~= false then
+ if contact_jid ~= user_jid then -- Skip self-contacts
+ roster:tag("item", {
+ jid = contact_jid,
+ subscription = item.subscription,
+ ask = item.ask,
+ name = item.name,
+ });
+ for group in pairs(item.groups) do
+ roster:tag("group"):text(group):up();
+ end
+ roster:up(); -- move out from item
end
- roster:up(); -- move out from item
else
roster.attr.version = item.version;
for pending_jid in pairs(item.pending) do