Diff

plugins/mod_muc.lua @ 811:863046d84b56

MUC: Private stanzas (private messages, IQs, etc)
author Waqas Hussain <waqas20@gmail.com>
date Mon, 16 Feb 2009 20:05:03 +0500
parent 810:09d6b5fadc84
child 812:1dbcf57154bd
line wrap: on
line diff
--- a/plugins/mod_muc.lua	Mon Feb 16 19:39:10 2009 +0500
+++ b/plugins/mod_muc.lua	Mon Feb 16 20:05:03 2009 +0500
@@ -327,11 +327,19 @@
 		elseif type ~= 'result' then -- bad type
 			origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error?
 		end
+	elseif not current_nick then -- not in room
+		origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
 	elseif stanza.name == "message" and type == "groupchat" then
 		-- groupchat messages not allowed in PM
 		origin.send(st.error_reply(stanza, "modify", "bad-request"));
-	else
-		origin.send(st.error_reply(stanza, "cancel", "not-implemented", "Private stanzas not implemented")); -- TODO route private stanza
+	else -- private stanza
+		local o_data = rooms:get(room, to);
+		if o_data then
+			stanza.attr.to, stanza.attr.from = o_data.jid, current_nick;
+			core_route_stanza(component, stanza);
+		else -- recipient not in room
+			origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Recipient not in room"));
+		end
 	end
 end