Software /
code /
prosody-modules
Changeset
3018:727a8beeb5c3
mod_pubsub_post: Add an option for what to use as pubsub 'actor'
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 20 May 2018 03:03:59 +0200 |
parents | 3017:8e48c0b233e0 |
children | 3019:b19d64dd4c66 |
files | mod_pubsub_post/mod_pubsub_post.lua |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_pubsub_post/mod_pubsub_post.lua Sun May 20 02:56:48 2018 +0200 +++ b/mod_pubsub_post/mod_pubsub_post.lua Sun May 20 03:03:59 2018 +0200 @@ -67,6 +67,8 @@ end end +local actor_source = module:get_option_string("pubsub_post_actor", "superuser"); + function handle_POST(event, path) local request = event.request; module:log("debug", "Handling POST: \n%s\n", tostring(request.body)); @@ -74,6 +76,13 @@ local content_type = request.headers.content_type or "application/octet-stream"; local actor = true; + if actor_source == "request.ip" then + actor = request.ip or request.conn:ip(); + elseif actor_source ~= "superuser" then + module:log("error", "pubsub_post_actor set to unsupported value %q", actor_source); + return 500; + end + if content_type == "application/xml" or content_type:sub(-4) == "+xml" then return handle_xml(path, actor, request.body); elseif content_type == "application/json" or content_type:sub(-5) == "+json" then