Move mod_irc to ejabberd-contrib

This commit is contained in:
Evgeniy Khramtsov 2018-06-20 12:27:44 +03:00
parent aea6166efe
commit 3a5d2dbed8
29 changed files with 7 additions and 2594 deletions

3
README
View File

@ -93,7 +93,6 @@ Moreover, ejabberd comes with a wide range of other state-of-the-art features:
- Users Directory based on users vCards. - Users Directory based on users vCards.
- Publish-Subscribe component with support for Personal Eventing. - Publish-Subscribe component with support for Personal Eventing.
- Support for web clients: HTTP Polling and HTTP Binding (BOSH). - Support for web clients: HTTP Polling and HTTP Binding (BOSH).
- IRC transport.
- Component support: interface with networks such as AIM, ICQ and MSN. - Component support: interface with networks such as AIM, ICQ and MSN.
@ -112,8 +111,6 @@ To compile ejabberd you need:
- OpenSSL 1.0.0 or higher, for STARTTLS, SASL and SSL encryption. - OpenSSL 1.0.0 or higher, for STARTTLS, SASL and SSL encryption.
- Zlib 1.2.3 or higher, for Stream Compression support (XEP-0138). Optional. - Zlib 1.2.3 or higher, for Stream Compression support (XEP-0138). Optional.
- PAM library. Optional. For Pluggable Authentication Modules (PAM). - PAM library. Optional. For Pluggable Authentication Modules (PAM).
- GNU Iconv 1.8 or higher, for the IRC Transport (mod_irc). Optional. Not
needed on systems with GNU Libc.
- ImageMagick's Convert program. Optional. For CAPTCHA challenges. - ImageMagick's Convert program. Optional. For CAPTCHA challenges.
If your system splits packages in libraries and development headers, you must If your system splits packages in libraries and development headers, you must

View File

@ -94,9 +94,6 @@ defmodule Ejabberd.ConfigFile do
module :mod_disco do module :mod_disco do
end end
module :mod_irc do
end
module :mod_http_bind do module :mod_http_bind do
end end

View File

@ -565,7 +565,6 @@ modules:
mod_configure: {} # requires mod_adhoc mod_configure: {} # requires mod_adhoc
mod_disco: {} mod_disco: {}
## mod_echo: {} ## mod_echo: {}
mod_irc: {}
mod_http_bind: {} mod_http_bind: {}
## mod_http_fileserver: ## mod_http_fileserver:
## docroot: "/var/www" ## docroot: "/var/www"

View File

@ -197,12 +197,12 @@ AC_ARG_ENABLE(elixir,
esac],[if test "x$elixir" = "x"; then elixir=false; fi]) esac],[if test "x$elixir" = "x"; then elixir=false; fi])
AC_ARG_ENABLE(iconv, AC_ARG_ENABLE(iconv,
[AC_HELP_STRING([--enable-iconv], [enable iconv support (default: yes)])], [AC_HELP_STRING([--enable-iconv], [enable iconv support (default: no)])],
[case "${enableval}" in [case "${enableval}" in
yes) iconv=true ;; yes) iconv=true ;;
no) iconv=false ;; no) iconv=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-iconv) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-iconv) ;;
esac],[if test "x$iconv" = "x"; then iconv=true; fi]) esac],[if test "x$iconv" = "x"; then iconv=false; fi])
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
[AC_HELP_STRING([--enable-debug], [enable debug information (default: yes)])], [AC_HELP_STRING([--enable-debug], [enable debug information (default: yes)])],

View File

@ -734,7 +734,6 @@ modules:
## mod_delegation: {} # for xep0356 ## mod_delegation: {} # for xep0356
mod_disco: {} mod_disco: {}
mod_echo: {} mod_echo: {}
mod_irc: {}
mod_bosh: {} mod_bosh: {}
## mod_http_fileserver: ## mod_http_fileserver:
## docroot: "/var/www" ## docroot: "/var/www"

View File

@ -70,7 +70,7 @@ done
echo '7. compile ejabberd' echo '7. compile ejabberd'
gmake gmake
for A in mod_irc mod_muc mod_pubsub; do for A in mod_muc mod_pubsub; do
(cd $A; gmake) (cd $A; gmake)
done done

View File

@ -51,7 +51,6 @@ override_acls.
{mod_offline, []}, {mod_offline, []},
{mod_echo, [{host, "echo.jabber.dbc.mtview.ca.us"}]}, {mod_echo, [{host, "echo.jabber.dbc.mtview.ca.us"}]},
{mod_private, []}, {mod_private, []},
% {mod_irc, []},
{mod_muc, []}, {mod_muc, []},
{mod_pubsub, []}, {mod_pubsub, []},
{mod_time, []}, {mod_time, []},

View File

@ -1,35 +0,0 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2018 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------
-type conn_param() :: {binary(), binary(), inet:port_number(), binary()} |
{binary(), binary(), inet:port_number()} |
{binary(), binary()} |
{binary()}.
-type irc_data() :: [{username, binary()} | {connections_params, [conn_param()]}].
-record(irc_connection,
{jid_server_host = {#jid{}, <<"">>, <<"">>} :: {jid(), binary(), binary()},
pid = self() :: pid()}).
-record(irc_custom,
{us_host = {{<<"">>, <<"">>}, <<"">>} :: {{binary(), binary()},
binary()},
data = [] :: irc_data()}).

View File

@ -125,7 +125,7 @@ defmodule Ejabberd.Mixfile do
defp vars do defp vars do
case :file.consult("vars.config") do case :file.consult("vars.config") do
{:ok,config} -> config {:ok,config} -> config
_ -> [zlib: true, iconv: true] _ -> [zlib: true, iconv: false]
end end
end end

View File

@ -329,16 +329,6 @@ CREATE TABLE muc_room_subscribers (
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers(host, jid); CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers(host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers(host, room, jid); CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers(host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom (jid, host);
CREATE TABLE motd ( CREATE TABLE motd (
username text NOT NULL, username text NOT NULL,
server_host text NOT NULL, server_host text NOT NULL,

View File

@ -302,15 +302,6 @@ CREATE TABLE muc_room_subscribers (
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers(host, jid); CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers(host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers(host, room, jid); CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers(host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom (jid, host);
CREATE TABLE motd ( CREATE TABLE motd (
username text PRIMARY KEY, username text PRIMARY KEY,
xml text, xml text,

View File

@ -72,16 +72,6 @@ CREATE TABLE [dbo].[caps_features] (
CREATE CLUSTERED INDEX [caps_features_node_subnode] ON [caps_features] (node, subnode) CREATE CLUSTERED INDEX [caps_features_node_subnode] ON [caps_features] (node, subnode)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON); WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[irc_custom] (
[jid] [varchar] (255) NOT NULL,
[host] [varchar] (255) NOT NULL,
[data] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
) TEXTIMAGE_ON [PRIMARY];
CREATE UNIQUE CLUSTERED INDEX [irc_custom_jid_host] ON [irc_custom] (jid, host)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[last] ( CREATE TABLE [dbo].[last] (
[username] [varchar] (250) NOT NULL, [username] [varchar] (250) NOT NULL,
[seconds] [text] NOT NULL, [seconds] [text] NOT NULL,

View File

@ -345,16 +345,6 @@ CREATE TABLE muc_room_subscribers (
CREATE INDEX i_muc_room_subscribers_host_jid USING BTREE ON muc_room_subscribers(host, jid); CREATE INDEX i_muc_room_subscribers_host_jid USING BTREE ON muc_room_subscribers(host, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
data text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_irc_custom_jid_host USING BTREE ON irc_custom(jid(75), host(75));
CREATE TABLE motd ( CREATE TABLE motd (
username varchar(191) NOT NULL, username varchar(191) NOT NULL,
server_host text NOT NULL, server_host text NOT NULL,

View File

@ -318,15 +318,6 @@ CREATE TABLE muc_room_subscribers (
CREATE INDEX i_muc_room_subscribers_host_jid USING BTREE ON muc_room_subscribers(host, jid); CREATE INDEX i_muc_room_subscribers_host_jid USING BTREE ON muc_room_subscribers(host, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
data text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_irc_custom_jid_host USING BTREE ON irc_custom(jid(75), host(75));
CREATE TABLE motd ( CREATE TABLE motd (
username varchar(191) PRIMARY KEY, username varchar(191) PRIMARY KEY,
xml text, xml text,

View File

@ -144,9 +144,6 @@
-- ALTER TABLE muc_online_users ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>'; -- ALTER TABLE muc_online_users ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>';
-- ALTER TABLE muc_online_users ALTER COLUMN server_host DROP DEFAULT; -- ALTER TABLE muc_online_users ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE irc_custom ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>';
-- ALTER TABLE irc_custom ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE motd ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>'; -- ALTER TABLE motd ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>';
-- ALTER TABLE motd DROP CONSTRAINT motd_pkey; -- ALTER TABLE motd DROP CONSTRAINT motd_pkey;
-- ALTER TABLE motd ADD PRIMARY KEY (server_host, username); -- ALTER TABLE motd ADD PRIMARY KEY (server_host, username);
@ -498,16 +495,6 @@ CREATE TABLE muc_room_subscribers (
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid); CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid); CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom USING btree (jid, host);
CREATE TABLE motd ( CREATE TABLE motd (
username text NOT NULL, username text NOT NULL,
server_host text NOT NULL, server_host text NOT NULL,

View File

@ -320,15 +320,6 @@ CREATE TABLE muc_room_subscribers (
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid); CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid); CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom USING btree (jid, host);
CREATE TABLE motd ( CREATE TABLE motd (
username text PRIMARY KEY, username text PRIMARY KEY,
xml text, xml text,

View File

@ -627,7 +627,6 @@ keep_modules_tables() ->
%% module. %% module.
%% Mapping between modules and their tables %% Mapping between modules and their tables
module_tables(mod_announce) -> [motd, motd_users]; module_tables(mod_announce) -> [motd, motd_users];
module_tables(mod_irc) -> [irc_custom];
module_tables(mod_last) -> [last_activity]; module_tables(mod_last) -> [last_activity];
module_tables(mod_muc) -> [muc_room, muc_registered]; module_tables(mod_muc) -> [muc_room, muc_registered];
module_tables(mod_offline) -> [offline_msg]; module_tables(mod_offline) -> [offline_msg];

View File

@ -1112,7 +1112,6 @@ get_copyright() ->
replace_module(mod_announce_odbc) -> {mod_announce, sql}; replace_module(mod_announce_odbc) -> {mod_announce, sql};
replace_module(mod_blocking_odbc) -> {mod_blocking, sql}; replace_module(mod_blocking_odbc) -> {mod_blocking, sql};
replace_module(mod_caps_odbc) -> {mod_caps, sql}; replace_module(mod_caps_odbc) -> {mod_caps, sql};
replace_module(mod_irc_odbc) -> {mod_irc, sql};
replace_module(mod_last_odbc) -> {mod_last, sql}; replace_module(mod_last_odbc) -> {mod_last, sql};
replace_module(mod_muc_odbc) -> {mod_muc, sql}; replace_module(mod_muc_odbc) -> {mod_muc, sql};
replace_module(mod_offline_odbc) -> {mod_offline, sql}; replace_module(mod_offline_odbc) -> {mod_offline, sql};

View File

@ -51,7 +51,6 @@ modules() ->
[ejabberd_auth, [ejabberd_auth,
mod_announce, mod_announce,
mod_caps, mod_caps,
mod_irc,
mod_last, mod_last,
mod_mam, mod_mam,
mod_muc, mod_muc,

View File

@ -241,9 +241,6 @@ update_tables(State) ->
add_sh_column(State, "muc_online_users"), add_sh_column(State, "muc_online_users"),
drop_sh_default(State, "muc_online_users"), drop_sh_default(State, "muc_online_users"),
add_sh_column(State, "irc_custom"),
drop_sh_default(State, "irc_custom"),
add_sh_column(State, "motd"), add_sh_column(State, "motd"),
drop_pkey(State, "motd"), drop_pkey(State, "motd"),
add_pkey(State, "motd", ["server_host", "username"]), add_pkey(State, "motd", ["server_host", "username"]),

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +0,0 @@
%%%-------------------------------------------------------------------
%%% File : mod_irc_mnesia.erl
%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net>
%%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% ejabberd, Copyright (C) 2002-2018 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------
-module(mod_irc_mnesia).
-behaviour(mod_irc).
%% API
-export([init/2, get_data/3, set_data/4, import/2]).
-export([need_transform/1, transform/1]).
-include("jid.hrl").
-include("mod_irc.hrl").
-include("logger.hrl").
%%%===================================================================
%%% API
%%%===================================================================
init(_Host, _Opts) ->
ejabberd_mnesia:create(?MODULE, irc_custom,
[{disc_copies, [node()]},
{attributes, record_info(fields, irc_custom)}]).
get_data(_LServer, Host, From) ->
{U, S, _} = jid:tolower(From),
case catch mnesia:dirty_read({irc_custom, {{U, S}, Host}}) of
{'EXIT', _Reason} -> error;
[] -> empty;
[#irc_custom{data = Data}] -> Data
end.
set_data(_LServer, Host, From, Data) ->
{U, S, _} = jid:tolower(From),
F = fun () ->
mnesia:write(#irc_custom{us_host = {{U, S}, Host},
data = Data})
end,
mnesia:transaction(F).
import(_LServer, #irc_custom{} = R) ->
mnesia:dirty_write(R).
need_transform(#irc_custom{us_host = {{U, S}, H}})
when is_list(U) orelse is_list(S) orelse is_list(H) ->
?INFO_MSG("Mnesia table 'irc_custom' will be converted to binary", []),
true;
need_transform(_) ->
false.
transform(#irc_custom{us_host = {{U, S}, H},
data = Data} = R) ->
JID = jid:make(U, S),
R#irc_custom{us_host = {{iolist_to_binary(U),
iolist_to_binary(S)},
iolist_to_binary(H)},
data = mod_irc:data_to_binary(JID, Data)}.
%%%===================================================================
%%% Internal functions
%%%===================================================================

View File

@ -1,65 +0,0 @@
%%%-------------------------------------------------------------------
%%% File : mod_irc_riak.erl
%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net>
%%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% ejabberd, Copyright (C) 2002-2018 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------
-module(mod_irc_riak).
-behaviour(mod_irc).
%% API
-export([init/2, get_data/3, set_data/4, import/2]).
-include("jid.hrl").
-include("mod_irc.hrl").
%%%===================================================================
%%% API
%%%===================================================================
init(_Host, _Opts) ->
ok.
get_data(_LServer, Host, From) ->
{U, S, _} = jid:tolower(From),
case ejabberd_riak:get(irc_custom, irc_custom_schema(), {{U, S}, Host}) of
{ok, #irc_custom{data = Data}} ->
Data;
{error, notfound} ->
empty;
_Err ->
error
end.
set_data(_LServer, Host, From, Data) ->
{U, S, _} = jid:tolower(From),
{atomic, ejabberd_riak:put(#irc_custom{us_host = {{U, S}, Host},
data = Data},
irc_custom_schema())}.
import(_LServer, #irc_custom{} = R) ->
ejabberd_riak:put(R, irc_custom_schema()).
%%%===================================================================
%%% Internal functions
%%%===================================================================
irc_custom_schema() ->
{record_info(fields, irc_custom), #irc_custom{}}.

View File

@ -1,106 +0,0 @@
%%%-------------------------------------------------------------------
%%% File : mod_irc_sql.erl
%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net>
%%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% ejabberd, Copyright (C) 2002-2018 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------
-module(mod_irc_sql).
-compile([{parse_transform, ejabberd_sql_pt}]).
-behaviour(mod_irc).
%% API
-export([init/2, get_data/3, set_data/4, import/1, import/2, export/1]).
-include("jid.hrl").
-include("mod_irc.hrl").
-include("ejabberd_sql_pt.hrl").
%%%===================================================================
%%% API
%%%===================================================================
init(_Host, _Opts) ->
ok.
get_data(LServer, Host, From) ->
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
case catch ejabberd_sql:sql_query(
LServer,
?SQL("select @(data)s from irc_custom"
" where jid=%(SJID)s and host=%(Host)s and %(LServer)H")) of
{selected, [{SData}]} ->
mod_irc:data_to_binary(From, ejabberd_sql:decode_term(SData));
{'EXIT', _} -> error;
{selected, _} -> empty
end.
set_data(LServer, Host, From, Data) ->
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
SData = misc:term_to_expr(Data),
F = fun () ->
?SQL_UPSERT_T(
"irc_custom",
["!jid=%(SJID)s",
"!host=%(Host)s",
"server_host=%(LServer)s",
"data=%(SData)s"]),
ok
end,
ejabberd_sql:sql_transaction(LServer, F).
export(_Server) ->
[{irc_custom,
fun(Host, #irc_custom{us_host = {{U, S}, IRCHost},
data = Data}) ->
case str:suffix(Host, IRCHost) of
true ->
SJID = jid:encode(jid:make(U, S)),
LServer = ejabberd_router:host_of_route(IRCHost),
SData = misc:term_to_expr(Data),
[?SQL("delete from irc_custom"
" where jid=%(SJID)s and host=%(IRCHost)s and %(LServer)H;"),
?SQL_INSERT(
"irc_custom",
["jid=%(SJID)s",
"host=%(Host)s",
"server_host=%(LServer)s",
"data=%(SData)s"])];
false ->
[]
end
end}].
import(_LServer) ->
[{<<"select jid, host, data from irc_custom;">>,
fun([SJID, IRCHost, SData]) ->
#jid{luser = U, lserver = S} = jid:decode(SJID),
Data = ejabberd_sql:decode_term(SData),
#irc_custom{us_host = {{U, S}, IRCHost},
data = Data}
end}].
import(_, _) ->
pass.
%%%===================================================================
%%% Internal functions
%%%===================================================================

View File

@ -24,7 +24,7 @@ defmodule Ejabberd.Config.EjabberdLoggerTest do
test "outputs correctly when attr is not supported" do test "outputs correctly when attr is not supported" do
error_msg = "[ WARN ] Annotation @attr_not_supported is not supported.\n" error_msg = "[ WARN ] Annotation @attr_not_supported is not supported.\n"
[_mod_irc, _mod_configure, mod_time] = Store.get(:modules) [_mod_configure, mod_time] = Store.get(:modules)
fun = fn -> fun = fn ->
mod_time mod_time
|> Validation.validate |> Validation.validate
@ -37,7 +37,7 @@ defmodule Ejabberd.Config.EjabberdLoggerTest do
test "outputs correctly when dependency is not found" do test "outputs correctly when dependency is not found" do
error_msg = "[ WARN ] Module :mod_adhoc was not found, but is required as a dependency.\n" error_msg = "[ WARN ] Module :mod_adhoc was not found, but is required as a dependency.\n"
[_mod_irc, mod_configure, _mod_time] = Store.get(:modules) [mod_configure, _mod_time] = Store.get(:modules)
fun = fn -> fun = fn ->
mod_configure mod_configure
|> Validation.validate |> Validation.validate

View File

@ -15,6 +15,4 @@ defmodule Ejabberd.ConfigFile do
@dependency [:mod_adhoc] @dependency [:mod_adhoc]
end end
module :mod_irc do
end
end end

View File

@ -19,7 +19,7 @@ defmodule Ejabberd.Config.ValidationTest do
end end
test "validates correctly the modules" do test "validates correctly the modules" do
[mod_irc, mod_configure, mod_time] = Store.get(:modules) [mod_configure, mod_time] = Store.get(:modules)
[{:error, _mod, errors}] = Validation.validate(mod_configure) [{:error, _mod, errors}] = Validation.validate(mod_configure)
assert %{dependency: [mod_adhoc: :not_found]} == errors assert %{dependency: [mod_adhoc: :not_found]} == errors
@ -27,6 +27,5 @@ defmodule Ejabberd.Config.ValidationTest do
[{:error, _mod, errors}] = Validation.validate(mod_time) [{:error, _mod, errors}] = Validation.validate(mod_time)
assert %{attribute: [{{:attr_not_supported, true}, :attr_not_supported}]} == errors assert %{attribute: [{{:attr_not_supported, true}, :attr_not_supported}]} == errors
[{:ok, _mod}] = Validation.validate(mod_irc)
end end
end end

View File

@ -146,7 +146,6 @@
{mod_offline, []}, {mod_offline, []},
{mod_announce, [{access, announce}]}, {mod_announce, [{access, announce}]},
{mod_private, []}, {mod_private, []},
{mod_irc, []},
% Default options for mod_muc: % Default options for mod_muc:
% host: "conference." ++ ?MYNAME % host: "conference." ++ ?MYNAME
% access: all % access: all