# HG changeset patch # User Kim Alvefur # Date 1701197743 -3600 # Node ID 5232d12eb74dcee9e07007153445eb8acd989826 # Parent 100110d539d3378f21fcb49f827a5eebee820d98 mod_storage_xmlarchive: Pass hostname to converter for converting all users diff -r 100110d539d3 -r 5232d12eb74d mod_storage_xmlarchive/README.markdown --- 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 diff -r 100110d539d3 -r 5232d12eb74d mod_storage_xmlarchive/mod_storage_xmlarchive.lua --- 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");