Software /
code /
prosody-modules
Comparison
mod_remote_roster/mod_remote_roster.lua @ 5376:ad6e9b0fd15b
mod_remote_roster: Set id on generated iq stanzas (thanks @agwa)
Fixes 'iq stanzas require an id attribute' error from util.stanza.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 27 Apr 2023 16:58:48 +0100 |
parent | 758:295ae44b8a01 |
comparison
equal
deleted
inserted
replaced
5375:8b7d97f0ae8a | 5376:ad6e9b0fd15b |
---|---|
17 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; | 17 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; |
18 local rm_add_to_roster = require "core.rostermanager".add_to_roster; | 18 local rm_add_to_roster = require "core.rostermanager".add_to_roster; |
19 local rm_roster_push = require "core.rostermanager".roster_push; | 19 local rm_roster_push = require "core.rostermanager".roster_push; |
20 local user_exists = require "core.usermanager".user_exists; | 20 local user_exists = require "core.usermanager".user_exists; |
21 local add_task = require "util.timer".add_task; | 21 local add_task = require "util.timer".add_task; |
22 local new_id = require "util.id".short; | |
22 | 23 |
23 module:hook("iq-get/bare/jabber:iq:roster:query", function(event) | 24 module:hook("iq-get/bare/jabber:iq:roster:query", function(event) |
24 local origin, stanza = event.origin, event.stanza; | 25 local origin, stanza = event.origin, event.stanza; |
25 | 26 |
26 if origin.type == "component" and stanza.attr.from == origin.host then | 27 if origin.type == "component" and stanza.attr.from == origin.host then |
136 function component_roster_push(node, host, jid) | 137 function component_roster_push(node, host, jid) |
137 local roster = load_roster(node, host); | 138 local roster = load_roster(node, host); |
138 if roster then | 139 if roster then |
139 local item = roster[jid]; | 140 local item = roster[jid]; |
140 local contact_node, contact_host = jid_split(jid); | 141 local contact_node, contact_host = jid_split(jid); |
141 local stanza = st.iq({ type="set", from=node.."@"..host, to=contact_host }):query("jabber:iq:roster"); | 142 local stanza = st.iq({ type="set", from=node.."@"..host, to=contact_host, id = new_id() }):query("jabber:iq:roster"); |
142 if item then | 143 if item then |
143 stanza:tag("item", { jid = jid, subscription = item.subscription, name = item.name, ask = item.ask }); | 144 stanza:tag("item", { jid = jid, subscription = item.subscription, name = item.name, ask = item.ask }); |
144 for group in pairs(item.groups) do | 145 for group in pairs(item.groups) do |
145 stanza:tag("group"):text(group):up(); | 146 stanza:tag("group"):text(group):up(); |
146 end | 147 end |