Software /
code /
prosody-modules
Changeset
5763:100110d539d3
mod_storage_xmlarchive: Migrate all users/rooms if no JID argument given
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 28 Nov 2023 19:48:34 +0100 |
parents | 5762:7e6bf0a5aef2 |
children | 5764:5232d12eb74d |
files | mod_storage_xmlarchive/README.markdown mod_storage_xmlarchive/mod_storage_xmlarchive.lua |
diffstat | 2 files changed, 18 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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