Comparison

mod_delegation/mod_delegation.lua @ 3387:c5e8042b174c

mod_delegation: avoid crash on recent prosody versions
author Goffi <goffi@goffi.org>
date Sat, 01 Dec 2018 12:10:31 +0100
parent 3317:36a9170352b5
child 4616:377546ab50f9
comparison
equal deleted inserted replaced
3386:a76c420eca61 3387:c5e8042b174c
348 end 348 end
349 349
350 local function feature_added(event) 350 local function feature_added(event)
351 local source, item = event.source, event.item 351 local source, item = event.source, event.item
352 for namespace, _ in pairs(ns_delegations) do 352 for namespace, _ in pairs(ns_delegations) do
353 if source ~= module and string.sub(item, 1, #namespace) == namespace then 353 if source ~= nil and source ~= module and string.sub(item, 1, #namespace) == namespace then
354 module:log("debug", "Removing %s feature which is delegated", item) 354 module:log("debug", "Removing %s feature which is delegated", item)
355 source:remove_item("feature", item) 355 source:remove_item("feature", item)
356 disabled_modules:add(source) 356 disabled_modules:add(source)
357 if source.items and source.items.identity then 357 if source.items and source.items.identity then
358 -- we remove all identities added by the source module 358 -- we remove all identities added by the source module
371 local source, stanza = event.source, event.item 371 local source, stanza = event.source, event.item
372 local form_type = find_form_type(stanza) 372 local form_type = find_form_type(stanza)
373 if not form_type then return end 373 if not form_type then return end
374 374
375 for namespace, _ in pairs(ns_delegations) do 375 for namespace, _ in pairs(ns_delegations) do
376 if source ~= module and string.sub(form_type, 1, #namespace) == namespace then 376 if source ~= nil and source ~= module and string.sub(form_type, 1, #namespace) == namespace then
377 module:log("debug", "Removing extension which is delegated: %s", tostring(stanza)) 377 module:log("debug", "Removing extension which is delegated: %s", tostring(stanza))
378 source:remove_item("extension", stanza) 378 source:remove_item("extension", stanza)
379 end 379 end
380 end 380 end
381 end 381 end