changeset 3282:9346ed926842

mod_bookmarks: Display the bare JID instead of the username in logs.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 25 Aug 2018 17:39:01 +0200
parents 27cc66bf918b
children 97b8b07ae1d1
files mod_bookmarks/mod_bookmarks.lua
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mod_bookmarks/mod_bookmarks.lua	Sat Aug 25 14:28:15 2018 +0200
+++ b/mod_bookmarks/mod_bookmarks.lua	Sat Aug 25 17:39:01 2018 +0200
@@ -23,22 +23,23 @@
 	module:log("debug", "Getting private bookmarks: %s", bookmarks);
 
 	local username = session.username;
+	local jid = username.."@"..session.host;
 	local service = mod_pep.get_pep_service(username);
 	local ok, id, item = service:get_last_item("storage:bookmarks", session.full_jid);
 	if not ok then
-		module:log("error", "Failed to retrieve PEP bookmarks of %s: %s", username, id);
+		module:log("error", "Failed to retrieve PEP bookmarks of %s: %s", jid, id);
 		session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to retrive bookmarks from PEP"));
 		return;
 	end
 	if not id or not item then
-		module:log("debug", "Got no PEP bookmarks item for %s, returning empty private bookmarks", username);
+		module:log("debug", "Got no PEP bookmarks item for %s, returning empty private bookmarks", jid);
 		session.send(st.reply(stanza):add_child(query));
 		return
 	end
 	module:log("debug", "Got item %s: %s", id, item);
 
 	local content = item.tags[1];
-	module:log("debug", "Sending back private for %s: %s", username, content);
+	module:log("debug", "Sending back private for %s: %s", jid, content);
 	session.send(st.reply(stanza):query("jabber:iq:private"):add_child(content));
 	return true;
 end
@@ -70,7 +71,7 @@
 	module:log("debug", "Private bookmarks set by client, publishing to pep");
 	local ok, err = publish_to_pep(session.full_jid, bookmarks);
 	if not ok then
-		module:log("error", "Failed to publish to PEP bookmarks for %s: %s", session.username, err);
+		module:log("error", "Failed to publish to PEP bookmarks for %s@%s: %s", session.username, session.host, err);
 		session.send(st.error_reply(stanza, "cancel", "internal-server-error", "Failed to store bookmarks to PEP"));
 		return;
 	end
@@ -82,35 +83,36 @@
 local function on_resource_bind(event)
 	local session = event.session;
 	local username = session.username;
+	local jid = username.."@"..session.host;
 
 	local data, err = private_storage:get(username, "storage:storage:bookmarks");
 	if not data then
-		module:log("debug", "No existing Private XML bookmarks for %s, migration already done: %s", username, err);
+		module:log("debug", "No existing Private XML bookmarks for %s, migration already done: %s", jid, err);
 		local service = mod_pep.get_pep_service(username);
 		local ok, id = service:get_last_item("storage:bookmarks", session.full_jid);
 		if not ok or not id then
-			module:log("debug", "Additionally, no PEP bookmarks were existing for %s", username);
+			module:log("debug", "Additionally, no PEP bookmarks were existing for %s", jid);
 			module:fire_event("bookmarks/empty", { session = session });
 		end
 		return;
 	end
 	local bookmarks = st.deserialize(data);
-	module:log("debug", "Got private bookmarks of %s: %s", username, bookmarks);
+	module:log("debug", "Got private bookmarks of %s: %s", jid, bookmarks);
 
-	module:log("debug", "Going to store PEP item for %s", username);
+	module:log("debug", "Going to store PEP item for %s", jid);
 	local ok, err = publish_to_pep(session.full_jid, bookmarks);
 	if not ok then
-		module:log("error", "Failed to store bookmarks to PEP for %s, aborting migration: %s", username, err);
+		module:log("error", "Failed to store bookmarks to PEP for %s, aborting migration: %s", jid, err);
 		return;
 	end
-	module:log("debug", "Stored bookmarks to PEP for %s", username);
+	module:log("debug", "Stored bookmarks to PEP for %s", jid);
 
 	local ok, err = private_storage:set(username, "storage:storage:bookmarks", nil);
 	if not ok then
-		module:log("error", "Failed to remove private bookmarks of %s: %s", username, err);
+		module:log("error", "Failed to remove private bookmarks of %s: %s", jid, err);
 		return;
 	end
-	module:log("debug", "Removed private bookmarks of %s, migration done!", username);
+	module:log("debug", "Removed private bookmarks of %s, migration done!", jid);
 end
 
 local function on_item_published(event)