Software / code / prosody
Comparison
core/moduleapi.lua @ 7950:f91e7ec9654e
Merge 0.10->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 06 Mar 2017 01:14:32 +0100 |
| parent | 7647:e9d7a409e236 |
| parent | 7947:24170d74b00b |
| child | 7982:e30b0cbed472 |
comparison
equal
deleted
inserted
replaced
| 7946:c92102fe409b | 7950:f91e7ec9654e |
|---|---|
| 114 xmlns, name, handler, priority = nil, xmlns, name, handler; | 114 xmlns, name, handler, priority = nil, xmlns, name, handler; |
| 115 elseif not (handler and name) then | 115 elseif not (handler and name) then |
| 116 self:log("warn", "Error: Insufficient parameters to module:hook_stanza()"); | 116 self:log("warn", "Error: Insufficient parameters to module:hook_stanza()"); |
| 117 return; | 117 return; |
| 118 end | 118 end |
| 119 return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority); | 119 return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, |
| 120 function (data) return handler(data.origin, data.stanza, data); end, priority); | |
| 120 end | 121 end |
| 121 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9 | 122 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9 |
| 122 | 123 |
| 123 function api:unhook(event, handler) | 124 function api:unhook(event, handler) |
| 124 return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler); | 125 return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler); |
| 186 local default_path_components = { self.host, self.name }; | 187 local default_path_components = { self.host, self.name }; |
| 187 for i = 1, paths.n do | 188 for i = 1, paths.n do |
| 188 local path = paths[i]; | 189 local path = paths[i]; |
| 189 if path:sub(1,1) ~= "/" then -- Prepend default components | 190 if path:sub(1,1) ~= "/" then -- Prepend default components |
| 190 local n_components = select(2, path:gsub("/", "%1")); | 191 local n_components = select(2, path:gsub("/", "%1")); |
| 191 path = (n_components<#default_path_components and "/" or "")..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path; | 192 path = (n_components<#default_path_components and "/" or "") |
| 193 ..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path; | |
| 192 end | 194 end |
| 193 local shared = shared_data[path]; | 195 local shared = shared_data[path]; |
| 194 if not shared then | 196 if not shared then |
| 195 shared = {}; | 197 shared = {}; |
| 196 if path:match("%-cache$") then | 198 if path:match("%-cache$") then |