# HG changeset patch # User Kim Alvefur # Date 1526778239 -7200 # Node ID 727a8beeb5c31beb1dba7e8e799328e823f57961 # Parent 8e48c0b233e0cedbf51a62d15967b4cc955f83eb mod_pubsub_post: Add an option for what to use as pubsub 'actor' diff -r 8e48c0b233e0 -r 727a8beeb5c3 mod_pubsub_post/mod_pubsub_post.lua --- 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