Comparison

mod_archive/mod_archive.lua @ 172:ac826882a8cf

mod_archive: The element auto MAY include a 'scope' attribute; Added message hook.
author shinysky<shinysky1986(AT)gmail.com>
date Sun, 13 Jun 2010 23:47:50 +0800
parent 165:fd8d76daad97
child 178:62f47a93b5b7
comparison
equal deleted inserted replaced
171:d15c7d86db11 172:ac826882a8cf
131 push:add_child(elem); 131 push:add_child(elem);
132 end 132 end
133 push = push:up(); 133 push = push:up();
134 for _, res in pairs(user and user.sessions or NULL) do -- broadcast to all resources 134 for _, res in pairs(user and user.sessions or NULL) do -- broadcast to all resources
135 if res.presence then -- to resource 135 if res.presence then -- to resource
136 push.attr.to = res.full_jid; -- TODO how to gen the message that new modes're set? 136 push.attr.to = res.full_jid;
137 res.send(push); 137 res.send(push);
138 end 138 end
139 end 139 end
140 end 140 end
141 return true; 141 return true;
202 local data = load_prefs(node, host); 202 local data = load_prefs(node, host);
203 if not data then 203 if not data then
204 return false; 204 return false;
205 end 205 end
206 local setting = data:child_with_name(elem.name) 206 local setting = data:child_with_name(elem.name)
207 setting.attr["save"] = elem.attr["save"]; 207 for k, v in pairs(elem.attr) do
208 setting.attr[k] = v;
209 end
208 store_prefs(data, node, host); 210 store_prefs(data, node, host);
209 origin.send(st.reply(stanza)); 211 origin.send(st.reply(stanza));
210 return true; 212 return true;
211 end 213 end
212 214
236 end 238 end
237 239
238 local function save_handler(event) 240 local function save_handler(event)
239 module:log("debug", "-- stanza:\n%s", tostring(event.stanza)); 241 module:log("debug", "-- stanza:\n%s", tostring(event.stanza));
240 return true; 242 return true;
243 end
244
245 local function msg_handler(data)
246 module:log("debug", "-- Enter msg_handler()");
247 local origin, stanza = data.origin, data.stanza;
248 module:log("debug", "-- msg:\n%s", tostring(stanza));
249 return nil;
241 end 250 end
242 251
243 module:hook("iq/self/urn:xmpp:archive:pref", preferences_handler); 252 module:hook("iq/self/urn:xmpp:archive:pref", preferences_handler);
244 module:hook("iq/self/urn:xmpp:archive:itemremove", itemremove_handler); 253 module:hook("iq/self/urn:xmpp:archive:itemremove", itemremove_handler);
245 module:hook("iq/self/urn:xmpp:archive:sessionremove", sessionremove_handler); 254 module:hook("iq/self/urn:xmpp:archive:sessionremove", sessionremove_handler);
249 module:hook("iq/self/urn:xmpp:archive:modified", modified_handler); 258 module:hook("iq/self/urn:xmpp:archive:modified", modified_handler);
250 module:hook("iq/self/urn:xmpp:archive:remove", remove_handler); 259 module:hook("iq/self/urn:xmpp:archive:remove", remove_handler);
251 module:hook("iq/self/urn:xmpp:archive:retrieve", retrieve_handler); 260 module:hook("iq/self/urn:xmpp:archive:retrieve", retrieve_handler);
252 module:hook("iq/self/urn:xmpp:archive:save", save_handler); 261 module:hook("iq/self/urn:xmpp:archive:save", save_handler);
253 262
263 module:hook("message/full", msg_handler, 10);
264 module:hook("message/bare", msg_handler, 10);
265