Diff

plugins/muc/muc.lib.lua @ 2053:f5a198127dd3

MUC: Fixed: affiliation='none' was omitted from some presence broadcasts.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 25 Oct 2009 21:07:32 +0500
parent 2051:2567f4bf0085
child 2064:1ee862fd1afe
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Sun Oct 25 21:06:35 2009 +0500
+++ b/plugins/muc/muc.lib.lua	Sun Oct 25 21:07:32 2009 +0500
@@ -115,7 +115,7 @@
 	stanza = get_filtered_presence(stanza);
 	local occupant = self._occupants[stanza.attr.from];
 	stanza:tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
-		:tag("item", {affiliation=occupant.affiliation, role=occupant.role, nick=nick}):up();
+		:tag("item", {affiliation=occupant.affiliation or "none", role=occupant.role or "none", nick=nick}):up();
 	if code then
 		stanza:tag("status", {code=code}):up();
 	end
@@ -162,7 +162,7 @@
 			local pres = get_filtered_presence(o_data.sessions[o_data.jid]);
 			pres.attr.to, pres.attr.from = to, occupant;
 			pres:tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
-				:tag("item", {affiliation=o_data.affiliation, role=o_data.role}):up();
+				:tag("item", {affiliation=o_data.affiliation or "none", role=o_data.role or "none"}):up();
 			self:route_stanza(pres);
 		end
 	end
@@ -232,13 +232,13 @@
 					occupant.sessions[from] = nil;
 					pr.attr.to = from;
 					pr:tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
-						:tag("item", {affiliation=occupant.affiliation, role='none'}):up()
+						:tag("item", {affiliation=occupant.affiliation or "none", role='none'}):up()
 						:tag("status", {code='110'});
 					self:route_stanza(pr);
 					if jid ~= new_jid then
 						pr = st.clone(occupant.sessions[new_jid])
 							:tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
-							:tag("item", {affiliation=occupant.affiliation, role=occupant.role});
+							:tag("item", {affiliation=occupant.affiliation or "none", role=occupant.role or "none"});
 						pr.attr.from = current_nick;
 						self:broadcast_except_nick(pr, current_nick);
 					end
@@ -323,7 +323,7 @@
 						else
 							pr.attr.to = from;
 							self:route_stanza(pr:tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
-								:tag("item", {affiliation=affiliation, role=role}):up()
+								:tag("item", {affiliation=affiliation or "none", role=role or "none"}):up()
 								:tag("status", {code='110'}));
 						end
 						self:send_history(from);