Diff

plugins/mod_motd.lua @ 4649:e07ce18c503e

mod_motd: Send only to resource coming online, not the user's bare JID (fixes #282)
author Matthew Wild <mwild1@gmail.com>
date Sat, 21 Apr 2012 21:16:53 +0100
parent 4390:5e84fb3c4ba0
child 4654:0975505f5a54
line wrap: on
line diff
--- a/plugins/mod_motd.lua	Sat Apr 21 21:03:57 2012 +0100
+++ b/plugins/mod_motd.lua	Sat Apr 21 21:16:53 2012 +0100
@@ -13,15 +13,15 @@
 
 if not motd_text then return; end
 
+local jid_join = require "util.jid".join;
 local st = require "util.stanza";
 
 motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n%s+", "\n"); -- Strip indentation from the config
 
-module:hook("resource-bind",
-	function (event)
+module:hook("resource-bind", function (event)
 		local session = event.session;
 		local motd_stanza =
-			st.message({ to = session.username..'@'..session.host, from = motd_jid })
+			st.message({ to = jid_join(session.username, session.host, session.resource), from = motd_jid })
 				:tag("body"):text(motd_text);
 		core_route_stanza(hosts[host], motd_stanza);
 		module:log("debug", "MOTD send to user %s@%s", session.username, session.host);