aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-06-26 02:24:56 +0200
committerKim Alvefur <zash@zash.se>2018-06-26 02:24:56 +0200
commitf31d13d48690b1f9253f991001ddf2226659fd55 (patch)
tree006533d651ff2f398a7aaaf492b18451ee700e4f
parent8ada72f3a29ee9583cd06c77121866d073772673 (diff)
downloadprosody-f31d13d48690b1f9253f991001ddf2226659fd55.tar.gz
prosody-f31d13d48690b1f9253f991001ddf2226659fd55.zip
MUC: Record timestamp of subject changes and stamp delay tag later
Thanks whoever mentioned this. Can't find who it was now.
-rw-r--r--plugins/muc/subject.lib.lua13
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