comparison mod_mam_adhoc/mod_mam_adhoc.lua @ 1147:27b41ee61601

mod_mam_adhoc: Use the new adhoc permission level for local users
author Kim Alvefur <zash@zash.se>
date Sat, 10 Aug 2013 21:51:29 +0200
parents 91d210b6106a
children
comparison
equal deleted inserted replaced
1146:9fa89dc7a86f 1147:27b41ee61601
37 never = false, [false] = "never", 37 never = false, [false] = "never",
38 roster = "roster", 38 roster = "roster",
39 } 39 }
40 40
41 local function mam_prefs_handler(self, data, state) 41 local function mam_prefs_handler(self, data, state)
42 local username, hostname = jid_split(data.from); 42 local username = jid_split(data.from);
43 if state then -- the second return value 43 if state then -- the second return value
44 if data.action == "cancel" then 44 if data.action == "cancel" then
45 return { status = "canceled" }; 45 return { status = "canceled" };
46 end
47
48 if not username or not hostname or hostname ~= module.host then
49 return { status = "error", error = { type = "cancel",
50 condition = "forbidden", message = "Invalid user or hostname." } };
51 end 46 end
52 47
53 local fields = mam_prefs_form:data(data.form); 48 local fields = mam_prefs_form:data(data.form);
54 49
55 local default, always, never = fields.default, fields.always, fields.never; 50 local default, always, never = fields.default, fields.always, fields.never;
97 end 92 end
98 return { status = "executing", actions = { "complete" }, form = { layout = mam_prefs_form, values = values } }, true; 93 return { status = "executing", actions = { "complete" }, form = { layout = mam_prefs_form, values = values } }, true;
99 end 94 end
100 end 95 end
101 96
102 module:provides("adhoc", module:require"adhoc".new("Archive settings", "urn:xmpp:mam#configure", mam_prefs_handler)); 97 module:provides("adhoc", module:require"adhoc".new("Archive settings", "urn:xmpp:mam#configure", mam_prefs_handler, "local_user"));