# HG changeset patch # User JC Brand # Date 1614011870 -3600 # Node ID dbfda7f5522de274e1926b5c6d8465d09277cd7f # Parent 5234d0c8883dca2ac4bb78578d861afd6696ec2b mod_ogp: Make sure OGP fasten messages get archived - By adding a type of "groupchat" - By adding a hook for `muc-message-is-historic` diff -r 5234d0c8883d -r dbfda7f5522d mod_ogp/mod_ogp.lua --- a/mod_ogp/mod_ogp.lua Mon Feb 22 16:44:40 2021 +0100 +++ b/mod_ogp/mod_ogp.lua Mon Feb 22 17:37:50 2021 +0100 @@ -1,10 +1,9 @@ local mod_muc = module:depends("muc") local http = require "net.http" local st = require "util.stanza" - -local ogp_pattern = [[]] -local ogp_pattern2 = [[]] local url_pattern = [[https?://%S+]] +local xmlns_fasten = "urn:xmpp:fasten:0"; +local xmlns_xhtml = "http://www.w3.org/1999/xhtml"; local function ogp_handler(event) local room, stanza = event.room, st.clone(event.stanza) @@ -27,7 +26,7 @@ local to = room.jid local from = room and room.jid or module.host - local fastening = st.message({to = to, from = from}):tag("apply-to", {xmlns = "urn:xmpp:fasten:0", id = origin_id}) + local fastening = st.message({to = to, from = from, type = 'groupchat'}):tag("apply-to", {xmlns = xmlns_fasten, id = origin_id}) local found_metadata = false local message_body = "" @@ -54,7 +53,7 @@ fastening:tag( "meta", { - xmlns = "http://www.w3.org/1999/xhtml", + xmlns = xmlns_xhtml, property = property, content = content } @@ -64,7 +63,6 @@ end end - if found_metadata then mod_muc.get_room_from_jid(room.jid):broadcast_message(fastening) end @@ -74,3 +72,11 @@ end module:hook("muc-occupant-groupchat", ogp_handler) + + +module:hook("muc-message-is-historic", function (event) + local fastening = event.stanza:get_child('apply-to', xmlns_fasten) + if fastening and fastening:get_child('meta', xmlns_xhtml) then + return true + end +end);