Software /
code /
prosody
Changeset
8929:415b2e9d8ba8
MUC: Record timestamp of subject changes and stamp delay tag later
Thanks whoever mentioned this. Can't find who it was now.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 26 Jun 2018 02:24:56 +0200 |
parents | 8928:d41f8ce67c8e |
children | 8930:2e45b1b47918 |
files | plugins/muc/subject.lib.lua |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/subject.lib.lua Tue Jun 26 02:14:14 2018 +0200 +++ b/plugins/muc/subject.lib.lua Tue Jun 26 02:24:56 2018 +0200 @@ -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 @@ 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 @@ 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 @@ -- 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