# HG changeset patch # User Kim Alvefur # Date 1701197314 -3600 # Node ID 100110d539d3378f21fcb49f827a5eebee820d98 # Parent 7e6bf0a5aef21dd17e2b72d5f0aabdd50e1af1be mod_storage_xmlarchive: Migrate all users/rooms if no JID argument given diff -r 7e6bf0a5aef2 -r 100110d539d3 mod_storage_xmlarchive/README.markdown --- a/mod_storage_xmlarchive/README.markdown Mon Nov 27 17:16:15 2023 +0100 +++ b/mod_storage_xmlarchive/README.markdown Tue Nov 28 19:48:34 2023 +0100 @@ -63,12 +63,13 @@ `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 the JID of the -user or MUC room to be migrated, which can be repeated. +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. ::: {.alert .alert-danger} Since this is a destructive command, don't forget to backup your data diff -r 7e6bf0a5aef2 -r 100110d539d3 mod_storage_xmlarchive/mod_storage_xmlarchive.lua --- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Mon Nov 27 17:16:15 2023 +0100 +++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Tue Nov 28 19:48:34 2023 +0100 @@ -445,7 +445,7 @@ end function archive:users() - return it.filter(skip_at_date, dm.users(module.host, self.store, "list")); + return it.filter(skip_at_date, dm.users(self.host, self.store, "list")); end local provider = {}; @@ -548,13 +548,19 @@ local store = arg[4]; if arg[3] == "internal" 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); + 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); + end + convert(user, host, store); end - convert(user, host, store); + else + for user in archive.users({ host = host; store = store }) do + convert(user, host, store); + end end print("Done"); return 0; @@ -563,6 +569,6 @@ print("Check out https://modules.prosody.im/mod_migrate"); end end - print("prosodyctl mod_storage_xmlarchive convert (from|to) internal (archive|archive2|muc_log) user@host"); + print("prosodyctl mod_storage_xmlarchive convert (from|to) internal (archive|archive2|muc_log) [user@host]"); end