Changeset

5764:5232d12eb74d

mod_storage_xmlarchive: Pass hostname to converter for converting all users
author Kim Alvefur <zash@zash.se>
date Tue, 28 Nov 2023 19:55:43 +0100
parents 5763:100110d539d3
children 5765:645de410dbca
files mod_storage_xmlarchive/README.markdown mod_storage_xmlarchive/mod_storage_xmlarchive.lua
diffstat 2 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mod_storage_xmlarchive/README.markdown	Tue Nov 28 19:48:34 2023 +0100
+++ b/mod_storage_xmlarchive/README.markdown	Tue Nov 28 19:55:43 2023 +0100
@@ -63,13 +63,14 @@
 `mod_storage_xmlarchive`:
 
 ``` bash
-prosodyctl mod_storage_xmlarchive convert $DIR internal $STORE [$JID]
+prosodyctl mod_storage_xmlarchive convert $DIR internal $STORE $JID+
 ```
 
 Where `$DIR` is `to` or `from`, `$STORE` is e.g. `archive` or `archive2`
 for MAM and `muc_log` for MUC logs. Finally, `$JID` is one or more JID
-of the users or MUC rooms to be migrated. If omitted, all users/rooms
-are migrated.
+of the users or MUC rooms to be migrated.
+
+To migrate all users/rooms on a particular host, pass a bare hostname.
 
 ::: {.alert .alert-danger}
 Since this is a destructive command, don't forget to backup your data
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Tue Nov 28 19:48:34 2023 +0100
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Tue Nov 28 19:55:43 2023 +0100
@@ -548,18 +548,17 @@
 
 		local store = arg[4];
 		if arg[3] == "internal" then
-			if arg[5] then
-				for i = 5, #arg do
-					local user, host = jid.prepped_split(arg[i]);
-					if not user then
-						print(string.format("Argument #%d (%q) is an invalid JID, aborting", i, arg[i]));
-						os.exit(1);
+			for i = 5, #arg do
+				local user, host = jid.prepped_split(arg[i]);
+				if user then
+					print(arg[i]);
+					convert(user, host, store);
+				else
+					-- luacheck: ignore 421/user
+					for user in archive.users({ host = host; store = store }) do
+						print(user.."@"..host);
+						convert(user, host, store);
 					end
-					convert(user, host, store);
-				end
-			else
-				for user in archive.users({ host = host; store = store }) do
-					convert(user, host, store);
 				end
 			end
 			print("Done");