Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 8940:365b16109d95
mod_pubsub: Apply normalization to JIDs retrieved from attributes
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 26 Jun 2018 20:28:53 +0200 |
parent | 8939:849c4683eaa0 |
child | 8953:19cbe80df9c8 |
comparison
equal
deleted
inserted
replaced
8939:849c4683eaa0 | 8940:365b16109d95 |
---|---|
1 local t_unpack = table.unpack or unpack; -- luacheck: ignore 113 | 1 local t_unpack = table.unpack or unpack; -- luacheck: ignore 113 |
2 local time_now = os.time; | 2 local time_now = os.time; |
3 | 3 |
4 local jid_prep = require "util.jid".prep; | |
4 local set = require "util.set"; | 5 local set = require "util.set"; |
5 local st = require "util.stanza"; | 6 local st = require "util.stanza"; |
6 local it = require "util.iterators"; | 7 local it = require "util.iterators"; |
7 local uuid_generate = require "util.uuid".generate; | 8 local uuid_generate = require "util.uuid".generate; |
8 local dataform = require"util.dataforms".new; | 9 local dataform = require"util.dataforms".new; |
257 return true; | 258 return true; |
258 end | 259 end |
259 | 260 |
260 function handlers.set_subscribe(origin, stanza, subscribe, service) | 261 function handlers.set_subscribe(origin, stanza, subscribe, service) |
261 local node, jid = subscribe.attr.node, subscribe.attr.jid; | 262 local node, jid = subscribe.attr.node, subscribe.attr.jid; |
263 jid = jid_prep(jid); | |
262 if not (node and jid) then | 264 if not (node and jid) then |
263 origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); | 265 origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); |
264 return true; | 266 return true; |
265 end | 267 end |
266 local options_tag, options = stanza.tags[1]:get_child("options"), nil; | 268 local options_tag, options = stanza.tags[1]:get_child("options"), nil; |
286 origin.send(reply); | 288 origin.send(reply); |
287 end | 289 end |
288 | 290 |
289 function handlers.set_unsubscribe(origin, stanza, unsubscribe, service) | 291 function handlers.set_unsubscribe(origin, stanza, unsubscribe, service) |
290 local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid; | 292 local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid; |
293 jid = jid_prep(jid); | |
291 if not (node and jid) then | 294 if not (node and jid) then |
292 origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); | 295 origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); |
293 return true; | 296 return true; |
294 end | 297 end |
295 local ok, ret = service:remove_subscription(node, stanza.attr.from, jid); | 298 local ok, ret = service:remove_subscription(node, stanza.attr.from, jid); |
502 | 505 |
503 for affiliation_tag in affiliations:childtags("affiliation") do | 506 for affiliation_tag in affiliations:childtags("affiliation") do |
504 local jid = affiliation_tag.attr.jid; | 507 local jid = affiliation_tag.attr.jid; |
505 local affiliation = affiliation_tag.attr.affiliation; | 508 local affiliation = affiliation_tag.attr.affiliation; |
506 | 509 |
510 jid = jid_prep(jid); | |
507 if affiliation == "none" then affiliation = nil; end | 511 if affiliation == "none" then affiliation = nil; end |
508 | 512 |
509 local ok, err = service:set_affiliation(node, stanza.attr.from, jid, affiliation); | 513 local ok, err = service:set_affiliation(node, stanza.attr.from, jid, affiliation); |
510 if not ok then | 514 if not ok then |
511 -- FIXME Incomplete error handling, | 515 -- FIXME Incomplete error handling, |