From f31d13d48690b1f9253f991001ddf2226659fd55 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 26 Jun 2018 02:24:56 +0200 Subject: MUC: Record timestamp of subject changes and stamp delay tag later Thanks whoever mentioned this. Can't find who it was now. --- plugins/muc/subject.lib.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugins/muc/subject.lib.lua') diff --git a/plugins/muc/subject.lib.lua b/plugins/muc/subject.lib.lua index 2cf2b92a..b751bc49 100644 --- a/plugins/muc/subject.lib.lua +++ b/plugins/muc/subject.lib.lua @@ -8,6 +8,7 @@ -- local st = require "util.stanza"; +local dt = require "util.datetime"; local muc_util = module:require "muc/util"; local valid_roles = muc_util.valid_roles; @@ -56,9 +57,16 @@ local function get_subject(room) return room._data.subject, room._data.subject_from or room.jid; end -local function send_subject(room, to) +local function send_subject(room, to, time) local msg = create_subject_message(get_subject(room)); msg.attr.to = to; + if time then + msg:tag("delay", { + xmlns = "urn:xmpp:delay", + from = room.jid, + stamp = dt.datetime(time); + }):up(); + end room:route_stanza(msg); end @@ -68,6 +76,7 @@ local function set_subject(room, subject, from) if old_subject == subject and old_from == from then return false; end room._data.subject_from = from; room._data.subject = subject; + room._data.subject_time = os.time(); local msg = create_subject_message(subject, from); room:broadcast_message(msg); return true; @@ -75,7 +84,7 @@ end -- Send subject to joining user module:hook("muc-occupant-session-new", function(event) - send_subject(event.room, event.stanza.attr.from); + send_subject(event.room, event.stanza.attr.from, event.room._data.subject_time); end, 20); -- Prosody has made the decision that messages with are exclusively subject changes -- cgit v1.2.3