Comparison

mod_pubsub_post/mod_pubsub_post.lua @ 3254:af73963cf1dd

mod_pubsub_post: Start with actor unset This should make it easier to add actor models in future commits without defaulting to the superuser by default.
author Kim Alvefur <zash@zash.se>
date Fri, 24 Aug 2018 14:48:59 +0200
parent 3018:727a8beeb5c3
child 3255:64d1dfbd1740
comparison
equal deleted inserted replaced
3253:cf8ad9fd7f15 3254:af73963cf1dd
72 function handle_POST(event, path) 72 function handle_POST(event, path)
73 local request = event.request; 73 local request = event.request;
74 module:log("debug", "Handling POST: \n%s\n", tostring(request.body)); 74 module:log("debug", "Handling POST: \n%s\n", tostring(request.body));
75 75
76 local content_type = request.headers.content_type or "application/octet-stream"; 76 local content_type = request.headers.content_type or "application/octet-stream";
77 local actor = true; 77 local actor;
78 78
79 if actor_source == "request.ip" then 79 if actor_source == "request.ip" then
80 actor = request.ip or request.conn:ip(); 80 actor = request.ip or request.conn:ip();
81 elseif actor_source ~= "superuser" then 81 elseif actor_source == "superuser" then
82 actor = true;
83 else
82 module:log("error", "pubsub_post_actor set to unsupported value %q", actor_source); 84 module:log("error", "pubsub_post_actor set to unsupported value %q", actor_source);
83 return 500; 85 return 500;
84 end 86 end
85 87
86 if content_type == "application/xml" or content_type:sub(-4) == "+xml" then 88 if content_type == "application/xml" or content_type:sub(-4) == "+xml" then