Diff

plugins/muc/muc.lib.lua @ 7667:5523880760b3

MUC: Insert the appropriate status code (210) if the nickname is overridden
author Kim Alvefur <zash@zash.se>
date Thu, 29 Sep 2016 22:04:59 +0200
parent 7661:37ab6c6326fe
child 7668:96c6c25a51e1
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Mon Sep 12 22:31:25 2016 +0100
+++ b/plugins/muc/muc.lib.lua	Thu Sep 29 22:04:59 2016 +0200
@@ -491,6 +491,7 @@
 		is_first_session = is_first_dest_session;
 		is_last_session = is_last_orig_session;
 	};
+	local orig_nick = dest_occupant and dest_occupant.jid;
 	if orig_occupant == nil then
 		event_name = "muc-occupant-pre-join";
 		event.occupant = dest_occupant;
@@ -503,6 +504,7 @@
 		event.dest_occupant = dest_occupant;
 	end
 	if module:fire_event(event_name, event) then return true; end
+	local nick_overridden = dest_occupant and orig_nick ~= dest_occupant.nick;
 
 	-- Check for nick conflicts
 	if dest_occupant ~= nil and not is_first_dest_session and bare_jid ~= jid_bare(dest_occupant.bare_jid) then -- new nick or has different bare real jid
@@ -555,6 +557,7 @@
 				dest_nick = nil; -- set dest_nick to nil; so general populance doesn't see it for whole orig_occupant
 			end
 		end
+
 		self:save_occupant(orig_occupant);
 		self:publicise_occupant_status(orig_occupant, orig_x, dest_nick);
 
@@ -575,6 +578,9 @@
 		if orig_occupant == nil and self:get_whois() == "anyone" then
 			dest_x:tag("status", {code = "100"}):up();
 		end
+		if nick_overridden then
+			dest_x:tag("status", {code = "210"}):up();
+		end
 		self:save_occupant(dest_occupant);
 
 		if orig_occupant == nil or muc_x then