Adds some checks about async.

There are modules that will not work with prosody 0.10 as they depend on util.async. Adds a safeguard and print error about it in the logs.
And others that just do not work because of the muc module API that they use.
This commit is contained in:
damencho 2019-12-05 10:09:58 +00:00 committed by Дамян Минков
parent 2420a68be9
commit b4be1bcd05
4 changed files with 30 additions and 3 deletions

View File

@ -4,6 +4,13 @@ local jid = require "util.jid";
local neturl = require "net.url";
local parse = neturl.parseQuery;
local poltergeist = module:require "poltergeist";
local have_async = pcall(require, "util.async");
if not have_async then
module:log("error", "requires a version of Prosody with util.async");
return;
end
local wrap_async_run = module:require "util".wrap_async_run;
-- Options

View File

@ -7,6 +7,13 @@ local it = require "util.iterators";
local json = require "util.json";
local iterators = require "util.iterators";
local array = require"util.array";
local have_async = pcall(require, "util.async");
if not have_async then
module:log("error", "requires a version of Prosody with util.async");
return;
end
local wrap_async_run = module:require "util".wrap_async_run;
local tostring = tostring;

View File

@ -6,6 +6,13 @@ local st = require "util.stanza";
local socket = require "socket";
local json = require "util.json";
-- we use async to detect Prosody 0.10 and earlier
local have_async = pcall(require, "util.async");
if not have_async then
module:log("warn", "speaker stats will not work with Prosody version 0.10 or less.");
return;
end
local muc_component_host = module:get_option_string("muc_component");
if muc_component_host == nil then
log("error", "No muc_component specified. No muc to operate on!");
@ -204,4 +211,4 @@ if prosody.hosts[muc_component_host] == nil then
prosody.events.add_handler("host-activated", process_host);
else
process_host(muc_component_host);
end
end

View File

@ -1,6 +1,5 @@
local jid = require "util.jid";
local runner, waiter = require "util.async".runner, require "util.async".waiter;
local have_async, async = pcall(require, "util.async");
local muc_domain_prefix
= module:get_option_string("muc_mapper_domain_prefix", "conference");
@ -62,6 +61,13 @@ end
function wrap_async_run(event,handler)
local have_async = pcall(require, "util.async");
if not have_async then
module:log("error", "requires a version of Prosody with util.async");
return nil;
end
local runner = async.runner;
-- Grab a local response so that we can send the http response when
-- the handler is done.
local response = event.response;