plugins/groupchat.lua

changeset 215
f86e0b0a0be3
parent 207
78f59d7b1ef7
child 231
9712693ae40a
--- a/plugins/groupchat.lua	Tue Aug 30 19:26:53 2011 +0200
+++ b/plugins/groupchat.lua	Thu Sep 08 17:51:11 2011 +0200
@@ -92,11 +92,14 @@
 				end
 			end
 		end);
-		room:hook("message", function(msg)
-			local subject = msg.stanza:get_child("subject");
-			subject = subject and subject:get_text();
-			if subject then
-				room.subject = #subject > 0 and subject or nil;
+		room:hook("message", function(event)
+			local subject = event.stanza:get_child_text("subject");
+			if not subject then return end
+			subject = #subject > 0 and subject or nil;
+			if subject ~= room.subject then
+				local old_subject = room.subject;
+				room.subject = subject;
+				return room:event("subject-changed", { from = old_subject, to = subject, by = event.sender, event = event });
 			end
 		end, 2000);
 		local join_st = verse.presence():tag("x",{xmlns = xmlns_muc}):reset();

mercurial