Annotate

tools/migration/migrator/jabberd14.lua @ 10043:ce8e18f20693

core/sessionmanager: Remove unnecessary fallback in make_authenticated
author Maxime “pep” Buquet <pep@bouah.net>
date Sat, 01 Jun 2019 15:00:35 +0200
parent 7881:4e3067272fae
child 13142:879a6a33c21b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4417
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local lfs = require "lfs";
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 local st = require "util.stanza";
5218
8350eaa3f3f3 tools/migration/migrator/jabberd14: Use util.xml.
Waqas Hussain <waqas20@gmail.com>
parents: 4445
diff changeset
4 local parse_xml = require "util.xml".parse;
4417
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 local os_getenv = os.getenv;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 local io_open = io.open;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7 local assert = assert;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8 local ipairs = ipairs;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9 local coroutine = coroutine;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 local print = print;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 local function is_file(path) return lfs.attributes(path, "mode") == "file"; end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 local function clean_path(path)
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 return path:gsub("\\", "/"):gsub("//+", "/"):gsub("^~", os_getenv("HOME") or "~");
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 local function load_xml(path)
4445
0434eb77d18c migrator/jabberd14: Minor refactoring.
Waqas Hussain <waqas20@gmail.com>
parents: 4417
diff changeset
20 local f, err = io_open(path);
0434eb77d18c migrator/jabberd14: Minor refactoring.
Waqas Hussain <waqas20@gmail.com>
parents: 4417
diff changeset
21 if not f then return f, err; end
0434eb77d18c migrator/jabberd14: Minor refactoring.
Waqas Hussain <waqas20@gmail.com>
parents: 4417
diff changeset
22 local data = f:read("*a");
0434eb77d18c migrator/jabberd14: Minor refactoring.
Waqas Hussain <waqas20@gmail.com>
parents: 4417
diff changeset
23 f:close();
0434eb77d18c migrator/jabberd14: Minor refactoring.
Waqas Hussain <waqas20@gmail.com>
parents: 4417
diff changeset
24 if not data then return; end
0434eb77d18c migrator/jabberd14: Minor refactoring.
Waqas Hussain <waqas20@gmail.com>
parents: 4417
diff changeset
25 return parse_xml(data);
4417
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
26 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
27
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28 local function load_spool_file(host, filename, path)
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
29 local xml = load_xml(path);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
30 if not xml then return; end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
32 local register_element = xml:get_child("query", "jabber:iq:register");
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
33 local username_element = register_element and register_element:get_child("username", "jabber:iq:register");
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
34 local password_element = register_element and register_element:get_child("password", "jabber:iq:auth");
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
35 local username = username_element and username_element:get_text();
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
36 local password = password_element and password_element:get_text();
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
37 if not username then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
38 print("[warn] Missing /xdb/{jabber:iq:register}register/username> in file "..filename)
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
39 return;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
40 elseif username..".xml" ~= filename then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
41 print("[warn] Missing /xdb/{jabber:iq:register}register/username does not match filename "..filename);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
42 return;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
43 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
44
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
45 local userdata = {
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
46 user = username;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
47 host = host;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
48 stores = {};
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
49 };
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
50 local stores = userdata.stores;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
51 stores.accounts = { password = password };
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
52
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
53 for i=1,#xml.tags do
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
54 local tag = xml.tags[i];
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
55 local xname = (tag.attr.xmlns or "")..":"..tag.name;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
56 if tag.attr.j_private_flag == "1" and tag.attr.xmlns then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
57 -- Private XML
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
58 stores.private = stores.private or {};
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
59 tag.attr.j_private_flag = nil;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
60 stores.private[tag.attr.xmlns] = st.preserialize(tag);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
61 elseif xname == "jabber:iq:auth:password" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
62 if stores.accounts.password ~= tag:get_text() then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
63 if password then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
64 print("[warn] conflicting passwords")
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
65 else
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
66 stores.accounts.password = tag:get_text();
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
67 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
68 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
69 elseif xname == "jabber:iq:register:query" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
70 -- already processed
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
71 elseif xname == "jabber:xdb:nslist:foo" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
72 -- ignore
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
73 elseif xname == "jabber:iq:auth:0k:zerok" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
74 -- ignore
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
75 elseif xname == "jabber:iq:roster:query" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
76 -- Roster
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
77 local roster = {};
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
78 local subscription_types = { from = true, to = true, both = true, none = true };
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
79 for _,item_element in ipairs(tag.tags) do
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
80 assert(item_element.name == "item");
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
81 assert(item_element.attr.jid);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
82 assert(subscription_types[item_element.attr.subscription]);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
83 assert((item_element.attr.ask or "subscribe") == "subscribe")
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
84 if item_element.name == "item" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
85 local groups = {};
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
86 for _,group_element in ipairs(item_element.tags) do
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
87 assert(group_element.name == "group");
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
88 groups[group_element:get_text()] = true;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
89 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
90 local item = {
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
91 name = item_element.attr.name;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
92 subscription = item_element.attr.subscription;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
93 ask = item_element.attr.ask;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
94 groups = groups;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
95 };
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
96 roster[item_element.attr.jid] = item;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
97 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
98 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
99 stores.roster = roster;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
100 elseif xname == "jabber:iq:last:query" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
101 -- Last activity
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
102 elseif xname == "jabber:x:offline:foo" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
103 -- Offline messages
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
104 elseif xname == "vcard-temp:vCard" then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
105 -- vCards
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
106 stores.vcard = st.preserialize(tag);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
107 else
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
108 print("[warn] Unknown tag: "..xname);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
109 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
110 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
111 return userdata;
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
112 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
113
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
114 local function loop_over_users(path, host, cb)
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
115 for file in lfs.dir(path) do
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
116 if file:match("%.xml$") then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
117 local user = load_spool_file(host, file, path.."/"..file);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
118 if user then cb(user); end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
119 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
120 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
121 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
122 local function loop_over_hosts(path, cb)
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
123 for host in lfs.dir(path) do
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
124 if host ~= "." and host ~= ".." and is_dir(path.."/"..host) then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
125 loop_over_users(path.."/"..host, host, cb);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
126 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
127 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
128 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
129
7881
4e3067272fae tools/migration/migrator/*: Remove use of module()
Kim Alvefur <zash@zash.se>
parents: 5218
diff changeset
130 local function reader(input)
4417
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
131 local path = clean_path(assert(input.path, "no input.path specified"));
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
132 assert(is_dir(path), "input.path is not a directory");
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
133
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
134 if input.host then
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
135 return coroutine.wrap(function() loop_over_users(input.path, input.host, coroutine.yield) end);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
136 else
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
137 return coroutine.wrap(function() loop_over_hosts(input.path, coroutine.yield) end);
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
138 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
139 end
33c149394dcb migrator/jabberd14: Support for reading jabberd14 spool files.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
140
7881
4e3067272fae tools/migration/migrator/*: Remove use of module()
Kim Alvefur <zash@zash.se>
parents: 5218
diff changeset
141 return {
4e3067272fae tools/migration/migrator/*: Remove use of module()
Kim Alvefur <zash@zash.se>
parents: 5218
diff changeset
142 reader = reader;
4e3067272fae tools/migration/migrator/*: Remove use of module()
Kim Alvefur <zash@zash.se>
parents: 5218
diff changeset
143 };