Software /
code /
prosody-modules
Comparison
mod_atom/mod_atom.lua @ 3424:6ae875c98daf
mod_atom: Check whether user exists
This is in order to prevent creation of PEP service objects for
non-existant users.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 03 Jan 2019 11:39:28 +0100 |
parent | 3423:4a8fa0364f35 |
child | 3432:61368aec97d6 |
comparison
equal
deleted
inserted
replaced
3423:4a8fa0364f35 | 3424:6ae875c98daf |
---|---|
1 -- HTTP Access to PEP -> microblog | 1 -- HTTP Access to PEP -> microblog |
2 -- By Kim Alvefur <zash@zash.se> | 2 -- By Kim Alvefur <zash@zash.se> |
3 | 3 |
4 local mod_pep = module:depends"pep"; | 4 local mod_pep = module:depends"pep"; |
5 | 5 |
6 local um = require "core.usermanager"; | |
6 local nodeprep = require "util.encodings".stringprep.nodeprep; | 7 local nodeprep = require "util.encodings".stringprep.nodeprep; |
7 local st = require "util.stanza"; | 8 local st = require "util.stanza"; |
8 | 9 |
9 module:depends("http") | 10 module:depends("http") |
10 module:provides("http", { | 11 module:provides("http", { |
13 local request, response = event.request, event.response; | 14 local request, response = event.request, event.response; |
14 local actor = request.ip; | 15 local actor = request.ip; |
15 | 16 |
16 user = nodeprep(user); | 17 user = nodeprep(user); |
17 if not user then return 400; end | 18 if not user then return 400; end |
19 if not um.user_exists(user, module.host) then | |
20 return 404; | |
21 end | |
18 | 22 |
19 local pubsub_service = mod_pep.get_pep_service(user); | 23 local pubsub_service = mod_pep.get_pep_service(user); |
20 local ok, items = pubsub_service:get_items("urn:xmpp:microblog:0", actor); | 24 local ok, items = pubsub_service:get_items("urn:xmpp:microblog:0", actor); |
21 if ok then | 25 if ok then |
22 response.headers.content_type = "application/xml"; | 26 response.headers.content_type = "application/xml"; |