Changeset

3423:4a8fa0364f35

mod_atom: Unpack event object Improves readability and reduces table indexing.
author Kim Alvefur <zash@zash.se>
date Thu, 03 Jan 2019 11:36:01 +0100
parents 3422:ba3c79ef2253
children 3424:6ae875c98daf
files mod_atom/mod_atom.lua
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_atom/mod_atom.lua	Wed Jan 02 10:49:43 2019 +0100
+++ b/mod_atom/mod_atom.lua	Thu Jan 03 11:36:01 2019 +0100
@@ -10,7 +10,8 @@
 module:provides("http", {
 	route = {
 		["GET /*"] = function (event, user)
-			local actor = event.request.ip;
+			local request, response = event.request, event.response;
+			local actor = request.ip;
 
 			user = nodeprep(user);
 			if not user then return 400; end
@@ -18,7 +19,7 @@
 			local pubsub_service = mod_pep.get_pep_service(user);
 			local ok, items = pubsub_service:get_items("urn:xmpp:microblog:0", actor);
 			if ok then
-				event.response.headers.content_type = "application/atom+xml";
+				response.headers.content_type = "application/xml";
 				local feed = st.stanza("feed", { xmlns = "http://www.w3.org/2005/Atom" })
 					:text_tag("generator", "Prosody", { uri = "xmpp:prosody.im", version = prosody.version })
 					:text_tag("title", pubsub_service.nodes["urn:xmpp:microblog:0"].config.title or "Microblog feed")
@@ -36,7 +37,6 @@
 				for i = #items, 1, -1 do
 					feed:add_direct_child(items[items[i]].tags[1]);
 				end
-				event.response.headers.content_type = "application/atom+xml";
 				return tostring(feed);
 			elseif items == "forbidden" then
 				return 403;