Mercurial > prosody-modules
comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 5740: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 | 79ba1a1a75cc |
| children | 5232d12eb74d |
comparison
equal
deleted
inserted
replaced
| 5739:7e6bf0a5aef2 | 5740:100110d539d3 |
|---|---|
| 443 local function skip_at_date(item) | 443 local function skip_at_date(item) |
| 444 return not item:find("@"); | 444 return not item:find("@"); |
| 445 end | 445 end |
| 446 | 446 |
| 447 function archive:users() | 447 function archive:users() |
| 448 return it.filter(skip_at_date, dm.users(module.host, self.store, "list")); | 448 return it.filter(skip_at_date, dm.users(self.host, self.store, "list")); |
| 449 end | 449 end |
| 450 | 450 |
| 451 local provider = {}; | 451 local provider = {}; |
| 452 function provider:open(store, typ) | 452 function provider:open(store, typ) |
| 453 if typ ~= "archive" then return nil, "unsupported-store"; end | 453 if typ ~= "archive" then return nil, "unsupported-store"; end |
| 546 end | 546 end |
| 547 end | 547 end |
| 548 | 548 |
| 549 local store = arg[4]; | 549 local store = arg[4]; |
| 550 if arg[3] == "internal" then | 550 if arg[3] == "internal" then |
| 551 for i = 5, #arg do | 551 if arg[5] then |
| 552 local user, host = jid.prepped_split(arg[i]); | 552 for i = 5, #arg do |
| 553 if not user then | 553 local user, host = jid.prepped_split(arg[i]); |
| 554 print(string.format("Argument #%d (%q) is an invalid JID, aborting", i, arg[i])); | 554 if not user then |
| 555 os.exit(1); | 555 print(string.format("Argument #%d (%q) is an invalid JID, aborting", i, arg[i])); |
| 556 end | 556 os.exit(1); |
| 557 convert(user, host, store); | 557 end |
| 558 convert(user, host, store); | |
| 559 end | |
| 560 else | |
| 561 for user in archive.users({ host = host; store = store }) do | |
| 562 convert(user, host, store); | |
| 563 end | |
| 558 end | 564 end |
| 559 print("Done"); | 565 print("Done"); |
| 560 return 0; | 566 return 0; |
| 561 else | 567 else |
| 562 print("Currently only conversion to/from mod_storage_internal is supported"); | 568 print("Currently only conversion to/from mod_storage_internal is supported"); |
| 563 print("Check out https://modules.prosody.im/mod_migrate"); | 569 print("Check out https://modules.prosody.im/mod_migrate"); |
| 564 end | 570 end |
| 565 end | 571 end |
| 566 print("prosodyctl mod_storage_xmlarchive convert (from|to) internal (archive|archive2|muc_log) user@host"); | 572 print("prosodyctl mod_storage_xmlarchive convert (from|to) internal (archive|archive2|muc_log) [user@host]"); |
| 567 end | 573 end |
| 568 | 574 |
