Changeset

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 3581:dbc67120097f
children 3583:a36412d4fafd
files mod_http_muc_log/README.markdown mod_http_muc_log/http_muc_log.html mod_http_muc_log/mod_http_muc_log.lua
diffstat 3 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_muc_log/README.markdown	Sun May 05 14:05:00 2019 +0200
+++ b/mod_http_muc_log/README.markdown	Sun May 05 14:06:50 2019 +0200
@@ -50,6 +50,15 @@
 for rendering templates, with the pattern `"%b{}"` and HTML / XML
 escaping enabled.
 
+## Inline images
+
+Inline images can optionally be shown. This is disabled by default for
+privacy reasons.
+
+``` {.lua}
+http_muc_log_show_images = true
+```
+
 ## Calendar optimization
 
 The calendar view relies on an optional part of the Prosody archive
--- a/mod_http_muc_log/http_muc_log.html	Sun May 05 14:05:00 2019 +0200
+++ b/mod_http_muc_log/http_muc_log.html	Sun May 05 14:06:50 2019 +0200
@@ -89,6 +89,7 @@
 <b class="nick">{item.nick}</b>
 <em class="verb">{item.verb?}</em>
 <q class="body">{item.body?}</q>
+{item.oob.url&<figure><a rel="nofollow" href="{item.oob.url?}"><img style="max-height:9em;max-width:16em" alt="{item.oob.desc?}" src="{item.oob.url?}"/></a><figcaption>{item.oob.desc?}</figcaption></figure>}
 </li>}
 </ol>
 </div>
--- 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;