# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1512941012 -3600
# Node ID 597c23e1c38ec41e0b5d66d21613af5d19f63379
# Parent  df970f76c7205ca0bba9f5e1577232a87695f854# Parent  082d127286451eb55420c36424dd321e8d9bceee
Merge 0.9->0.10

diff -r df970f76c720 -r 597c23e1c38e plugins/muc/muc.lib.lua
--- a/plugins/muc/muc.lib.lua	Sat Dec 09 15:37:10 2017 +0100
+++ b/plugins/muc/muc.lib.lua	Sun Dec 10 22:23:32 2017 +0100
@@ -99,6 +99,22 @@
 end
 function room_mt:broadcast_message(stanza, historic)
 	local to = stanza.attr.to;
+	local room_jid = self.jid;
+
+	stanza:maptags(function (child)
+		if child.name == "delay" and child.attr["xmlns"] == "urn:xmpp:delay" then
+			if child.attr["from"] == room_jid then
+				return nil;
+			end
+		end
+		if child.name == "x" and child.attr["xmlns"] == "jabber:x:delay" then
+			if child.attr["from"] == room_jid then
+				return nil;
+			end
+		end
+		return child;
+	end)
+
 	for occupant, o_data in pairs(self._occupants) do
 		for jid in pairs(o_data.sessions) do
 			stanza.attr.to = jid;
@@ -116,8 +132,8 @@
 	stanza = st.clone(stanza);
 	stanza.attr.to = "";
 	local stamp = datetime.datetime();
-	stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = muc_domain, stamp = stamp}):up(); -- XEP-0203
-	stanza:tag("x", {xmlns = "jabber:x:delay", from = muc_domain, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
+	stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = self.jid, stamp = stamp}):up(); -- XEP-0203
+	stanza:tag("x", {xmlns = "jabber:x:delay", from = self.jid, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
 	local entry = { stanza = stanza, stamp = stamp };
 	t_insert(history, entry);
 	while #history > (self._data.history_length or default_history_length) do t_remove(history, 1) end