# HG changeset patch
# User daurnimator <quae@daurnimator.com>
# Date 1403032723 14400
# Node ID f2c9c36979b3cb25ee561331ff4bf58e7ea52319
# Parent  9290a2906feb740af4598d877b7690cd58520026
plugins/muc: Fix use of incorrect event on occupant join

diff -r 9290a2906feb -r f2c9c36979b3 plugins/muc/history.lib.lua
--- a/plugins/muc/history.lib.lua	Wed Jun 11 17:54:23 2014 -0400
+++ b/plugins/muc/history.lib.lua	Tue Jun 17 15:18:43 2014 -0400
@@ -130,7 +130,7 @@
 end
 
 -- Send history on join
-module:hook("muc-occupant-joined", function(event)
+module:hook("muc-occupant-session-new", function(event)
 	send_history(event.room, event.stanza);
 end, 50); -- Before subject(20)
 
diff -r 9290a2906feb -r f2c9c36979b3 plugins/muc/muc.lib.lua
--- a/plugins/muc/muc.lib.lua	Wed Jun 11 17:54:23 2014 -0400
+++ b/plugins/muc/muc.lib.lua	Tue Jun 17 15:18:43 2014 -0400
@@ -487,8 +487,11 @@
 				self:route_stanza(pr);
 			end
 
-			if orig_occupant == nil and is_first_dest_session then
-				module:fire_event("muc-occupant-joined", {room = self; nick = dest_occupant.nick; stanza = stanza;});
+			if orig_occupant == nil then
+				if is_first_dest_session then
+					module:fire_event("muc-occupant-joined", {room = self; nick = dest_occupant.nick; stanza = stanza;});
+				end
+				module:fire_event("muc-occupant-session-new", {room = self; nick = dest_occupant.nick; stanza = stanza; jid = real_jid;});
 			end
 		end
 	elseif type ~= 'result' then -- bad type
diff -r 9290a2906feb -r f2c9c36979b3 plugins/muc/subject.lib.lua
--- a/plugins/muc/subject.lib.lua	Wed Jun 11 17:54:23 2014 -0400
+++ b/plugins/muc/subject.lib.lua	Tue Jun 17 15:18:43 2014 -0400
@@ -66,7 +66,7 @@
 end
 
 -- Send subject to joining user
-module:hook("muc-occupant-joined", function(event)
+module:hook("muc-occupant-session-new", function(event)
 	send_subject(event.room, event.stanza.attr.from);
 end, 20);