diff mod_http_muc_log/mod_http_muc_log.lua @ 3582:444e2306c99a

mod_http_muc_log: Add option to show OOB images
author Kim Alvefur <zash@zash.se>
date Sun, 05 May 2019 14:06:50 +0200
parents ea63dc0cc824
children a36412d4fafd
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua	Sun May 05 14:05:00 2019 +0200
+++ b/mod_http_muc_log/mod_http_muc_log.lua	Sun May 05 14:06:50 2019 +0200
@@ -28,6 +28,7 @@
 	return get_room_from_jid(jid);
 end
 
+local use_oob = module:get_option_boolean(module.name .. "_show_images", false);
 module:depends"http";
 
 local template;
@@ -268,8 +269,9 @@
 			-- TODO Distinguish between join and presence update
 			verb = item.attr.type == "unavailable" and "has left" or "has joined";
 		end
-		if body or verb then
-			logs[i], i = {
+		local oob = use_oob and item:get_child("x", "jabber:x:oob");
+		if body or verb or oob then
+			local line = {
 				key = key;
 				datetime = datetime.datetime(when);
 				time = datetime.time(when);
@@ -278,7 +280,14 @@
 				nick = select(3, jid_split(item.attr.from));
 				st_name = item.name;
 				st_type = item.attr.type;
-			}, i + 1;
+			};
+			if oob then
+				line.oob = {
+					url = oob:get_child_text("url");
+					desc = oob:get_child_text("desc");
+				}
+			end
+			logs[i], i = line, i + 1;
 		end
 		first = first or key;
 		last = key;