diff options
author | Kim Alvefur <zash@zash.se> | 2018-06-26 02:24:56 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-06-26 02:24:56 +0200 |
commit | 06fb966b24832731e64442abe6b70f95e3363127 (patch) | |
tree | 006533d651ff2f398a7aaaf492b18451ee700e4f /plugins/muc | |
parent | 57b6b0c61eee204e2f8c3b67239db1c593e59724 (diff) | |
download | prosody-06fb966b24832731e64442abe6b70f95e3363127.tar.gz prosody-06fb966b24832731e64442abe6b70f95e3363127.zip |
MUC: Record timestamp of subject changes and stamp delay tag later
Thanks whoever mentioned this. Can't find who it was now.
Diffstat (limited to 'plugins/muc')
-rw-r--r-- | plugins/muc/subject.lib.lua | 13 |
1 files changed, 11 insertions, 2 deletions
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 <subject/> are exclusively subject changes |