Changeset

1016:9f7c97e55593

mod_broadcast: Allow overriding from address on the broadcast stanza
author Matthew Wild <mwild1@gmail.com>
date Sun, 19 May 2013 22:25:54 +0100
parents 1015:0fc9e1f086c1
children 1017:28e3257d2ae5
files mod_broadcast/mod_broadcast.lua
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_broadcast/mod_broadcast.lua	Sun May 19 22:09:54 2013 +0100
+++ b/mod_broadcast/mod_broadcast.lua	Sun May 19 22:25:54 2013 +0100
@@ -1,5 +1,6 @@
 local is_admin = require "core.usermanager".is_admin;
 local allowed_senders = module:get_option_set("broadcast_senders", {});
+local from_address = module:get_option_string("broadcast_from");
 
 local jid_bare = require "util.jid".bare;
 
@@ -21,6 +22,10 @@
 	local stanza = event.stanza;
 	local from = stanza.attr.from;
 	if is_admin(from) or allowed_senders:contains(jid_bare(from)) then
+		if from_address then
+			stanza = st.clone(stanza);
+			stanza.attr.from = from_address;
+		end
 		local c = send_to_online(stanza);
 		module:log("debug", "Broadcast stanza from %s to %d online users", from, c);
 		return true;