Software /
code /
prosody
Comparison
tools/ejabberd2prosody.lua @ 5993:ef11b8bab405
Merge 0.9->0.10
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 18 Jan 2014 18:46:12 +0000 |
parent | 5776:bd0ff8ae98a8 |
parent | 5992:72157e928c23 |
child | 6000:0f6399c86c10 |
comparison
equal
deleted
inserted
replaced
5985:98ed9fe368ac | 5993:ef11b8bab405 |
---|---|
150 else print("[warn] default privacy list doesn't exist: "..tostring(default)); end | 150 else print("[warn] default privacy list doesn't exist: "..tostring(default)); end |
151 end | 151 end |
152 local ret, err = dm.store(node, host, "privacy", privacy); | 152 local ret, err = dm.store(node, host, "privacy", privacy); |
153 print("["..(err or "success").."] privacy: " ..node.."@"..host.." - "..count.." list(s)"); | 153 print("["..(err or "success").."] privacy: " ..node.."@"..host.." - "..count.." list(s)"); |
154 end | 154 end |
155 local function _table_to_jid(t) | |
156 if type(t[2]) == "string" then | |
157 local jid = t[2]; | |
158 if type(t[1]) == "string" then jid = t[1].."@"..jid; end | |
159 if type(t[3]) == "string" then jid = jid.."/"..t[3]; end | |
160 return jid; | |
161 end | |
162 end | |
163 function muc_room(node, host, properties) | |
164 local store = { jid = node.."@"..host, _data = {}, _affiliations = {} }; | |
165 for _,aff in ipairs(properties.affiliations) do | |
166 store._affiliations[_table_to_jid(aff[1])] = aff[2]; | |
167 end | |
168 store._data.subject = properties.subject; | |
169 if properties.subject_author then | |
170 store._data.subject_from = store.jid .. "/" .. properties.subject_author; | |
171 end | |
172 store._data.name = properties.title; | |
173 store._data.description = properties.description; | |
174 store._data.password = properties.password; | |
175 store._data.moderated = (properties.moderated == "true") or nil; | |
176 store._data.members_only = (properties.members_only == "true") or nil; | |
177 store._data.persistent = (properties.persistent == "true") or nil; | |
178 store._data.changesubject = (properties.allow_change_subj == "true") or nil; | |
179 store._data.whois = properties.anonymous == "true" and "moderators" or "anyone"; | |
180 store._data.hidden = (properties.public_list == "false") or nil; | |
181 | |
182 if not store._data.persistent then | |
183 return print("[error] muc_room: skipping non-persistent room: "..node.."@"..host); | |
184 end | |
185 | |
186 local ret, err = dm.store(node, host, "config", store); | |
187 if ret then | |
188 ret, err = dm.load(nil, host, "persistent"); | |
189 if ret or not err then | |
190 ret = ret or {}; | |
191 ret[store.jid] = true; | |
192 ret, err = dm.store(nil, host, "persistent", ret); | |
193 end | |
194 end | |
195 print("["..(err or "success").."] muc_room: " ..node.."@"..host); | |
196 end | |
155 | 197 |
156 | 198 |
157 local filters = { | 199 local filters = { |
158 passwd = function(tuple) | 200 passwd = function(tuple) |
159 password(tuple[2][1], tuple[2][2], tuple[3]); | 201 password(tuple[2][1], tuple[2][2], tuple[3]); |
193 offline_msg = function(tuple) | 235 offline_msg = function(tuple) |
194 offline_msg(tuple[2][1], tuple[2][2], build_time(tuple[3]), build_stanza(tuple[7])); | 236 offline_msg(tuple[2][1], tuple[2][2], build_time(tuple[3]), build_stanza(tuple[7])); |
195 end; | 237 end; |
196 privacy = function(tuple) | 238 privacy = function(tuple) |
197 privacy(tuple[2][1], tuple[2][2], tuple[3], tuple[4]); | 239 privacy(tuple[2][1], tuple[2][2], tuple[3], tuple[4]); |
240 end; | |
241 muc_room = function(tuple) | |
242 local properties = {}; | |
243 for _,pair in ipairs(tuple[3]) do | |
244 if not(type(pair[2]) == "table" and #pair[2] == 0) then -- skip nil values | |
245 properties[pair[1]] = pair[2]; | |
246 end | |
247 end | |
248 muc_room(tuple[2][1], tuple[2][2], properties); | |
198 end; | 249 end; |
199 config = function(tuple) | 250 config = function(tuple) |
200 if tuple[2] == "hosts" then | 251 if tuple[2] == "hosts" then |
201 local output = io.output(); io.output("prosody.cfg.lua"); | 252 local output = io.output(); io.output("prosody.cfg.lua"); |
202 io.write("-- Configuration imported from ejabberd --\n"); | 253 io.write("-- Configuration imported from ejabberd --\n"); |