diff options
author | Kim Alvefur <zash@zash.se> | 2021-11-04 00:55:59 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-11-04 00:55:59 +0100 |
commit | db0e630ad77bb5d1b725d06ae6f253214cbb92f7 (patch) | |
tree | b7ab80b83930d0fa07f6e178686d8829ab93c00a /plugins/mod_pep.lua | |
parent | 4a89e829d4f0eadf57b3bf21c41f1198171936cc (diff) | |
download | prosody-db0e630ad77bb5d1b725d06ae6f253214cbb92f7.tar.gz prosody-db0e630ad77bb5d1b725d06ae6f253214cbb92f7.zip |
mod_pep: Prevent creation of services for non-existent users
Using a dedicated service should give identical behavior, except for a
possible timing difference in the user existence lookup.
Diffstat (limited to 'plugins/mod_pep.lua')
-rw-r--r-- | plugins/mod_pep.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index df29afdc..a96bb1aa 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -9,6 +9,7 @@ local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed local cache = require "util.cache"; local set = require "util.set"; local storagemanager = require "core.storagemanager"; +local usermanager = require "core.usermanager"; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; @@ -174,6 +175,17 @@ local function get_subscriber_filter(username) end end +local nobody_service = pubsub.new({ + service = pubsub.new({ + node_defaults = { + ["max_items"] = 1; + ["persist_items"] = false; + ["access_model"] = "presence"; + ["send_last_published_item"] = "on_sub_and_presence"; + }; + }); +}); + function get_pep_service(username) module:log("debug", "get_pep_service(%q)", username); local user_bare = jid_join(username, host); @@ -181,6 +193,9 @@ function get_pep_service(username) if service then return service; end + if not usermanager.user_exists(username, host) then + return nobody_service; + end service = pubsub.new({ pep_username = username; node_defaults = { |