mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Update some modules to the new gen_mod API
This commit is contained in:
parent
20a8654be2
commit
60002fc145
@ -42,49 +42,20 @@
|
|||||||
-include_lib("xmpp/include/xmpp.hrl").
|
-include_lib("xmpp/include/xmpp.hrl").
|
||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
{ok, [{iq_handler, ejabberd_local, ?NS_COMMANDS, process_local_iq},
|
||||||
?NS_COMMANDS, ?MODULE, process_local_iq),
|
{iq_handler, ejabberd_sm, ?NS_COMMANDS, process_sm_iq},
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
{hook, disco_local_identity, get_local_identity, 99},
|
||||||
?NS_COMMANDS, ?MODULE, process_sm_iq),
|
{hook, disco_local_features, get_local_features, 99},
|
||||||
ejabberd_hooks:add(disco_local_identity, Host, ?MODULE,
|
{hook, disco_local_items, get_local_commands, 99},
|
||||||
get_local_identity, 99),
|
{hook, disco_sm_identity, get_sm_identity, 99},
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE,
|
{hook, disco_sm_features, get_sm_features, 99},
|
||||||
get_local_features, 99),
|
{hook, disco_sm_items, get_sm_commands, 99},
|
||||||
ejabberd_hooks:add(disco_local_items, Host, ?MODULE,
|
{hook, adhoc_local_items, ping_item, 100},
|
||||||
get_local_commands, 99),
|
{hook, adhoc_local_commands, ping_command, 100}]}.
|
||||||
ejabberd_hooks:add(disco_sm_identity, Host, ?MODULE,
|
|
||||||
get_sm_identity, 99),
|
|
||||||
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE,
|
|
||||||
get_sm_features, 99),
|
|
||||||
ejabberd_hooks:add(disco_sm_items, Host, ?MODULE,
|
|
||||||
get_sm_commands, 99),
|
|
||||||
ejabberd_hooks:add(adhoc_local_items, Host, ?MODULE,
|
|
||||||
ping_item, 100),
|
|
||||||
ejabberd_hooks:add(adhoc_local_commands, Host, ?MODULE,
|
|
||||||
ping_command, 100).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(adhoc_local_commands, Host,
|
ok.
|
||||||
?MODULE, ping_command, 100),
|
|
||||||
ejabberd_hooks:delete(adhoc_local_items, Host, ?MODULE,
|
|
||||||
ping_item, 100),
|
|
||||||
ejabberd_hooks:delete(disco_sm_items, Host, ?MODULE,
|
|
||||||
get_sm_commands, 99),
|
|
||||||
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE,
|
|
||||||
get_sm_features, 99),
|
|
||||||
ejabberd_hooks:delete(disco_sm_identity, Host, ?MODULE,
|
|
||||||
get_sm_identity, 99),
|
|
||||||
ejabberd_hooks:delete(disco_local_items, Host, ?MODULE,
|
|
||||||
get_local_commands, 99),
|
|
||||||
ejabberd_hooks:delete(disco_local_features, Host,
|
|
||||||
?MODULE, get_local_features, 99),
|
|
||||||
ejabberd_hooks:delete(disco_local_identity, Host,
|
|
||||||
?MODULE, get_local_identity, 99),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_COMMANDS),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
|
||||||
?NS_COMMANDS).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -43,23 +43,14 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE,
|
{ok, [{hook, pubsub_publish_item, pubsub_publish_item, 50},
|
||||||
pubsub_publish_item, 50),
|
{hook, vcard_iq_set, vcard_iq_convert, 30},
|
||||||
ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
|
{hook, vcard_iq_set, vcard_iq_publish, 100},
|
||||||
vcard_iq_convert, 30),
|
{hook, disco_sm_features, get_sm_features, 50}]}.
|
||||||
ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE,
|
|
||||||
vcard_iq_publish, 100),
|
|
||||||
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE,
|
|
||||||
get_sm_features, 50).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(pubsub_publish_item, Host, ?MODULE,
|
ok.
|
||||||
pubsub_publish_item, 50),
|
|
||||||
ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, vcard_iq_convert, 30),
|
|
||||||
ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, vcard_iq_publish, 100),
|
|
||||||
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE,
|
|
||||||
get_sm_features, 50).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -45,21 +45,13 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Callbacks and hooks
|
%%% Callbacks and hooks
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(user_receive_packet, Host,
|
{ok, [{hook, user_receive_packet, filter_packet, 25},
|
||||||
?MODULE, filter_packet, 25),
|
{hook, roster_in_subscription, filter_subscription, 25},
|
||||||
ejabberd_hooks:add(roster_in_subscription, Host,
|
{hook, offline_message_hook, filter_offline_msg, 25}]}.
|
||||||
?MODULE, filter_subscription, 25),
|
|
||||||
ejabberd_hooks:add(offline_message_hook, Host,
|
|
||||||
?MODULE, filter_offline_msg, 25).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(user_receive_packet, Host,
|
ok.
|
||||||
?MODULE, filter_packet, 25),
|
|
||||||
ejabberd_hooks:delete(roster_in_subscription, Host,
|
|
||||||
?MODULE, filter_subscription, 25),
|
|
||||||
ejabberd_hooks:delete(offline_message_hook, Host,
|
|
||||||
?MODULE, filter_offline_msg, 25).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -37,14 +37,12 @@
|
|||||||
-include("mod_privacy.hrl").
|
-include("mod_privacy.hrl").
|
||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50),
|
{ok, [{hook, disco_local_features, disco_features, 50},
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
{iq_handler, ejabberd_sm, ?NS_BLOCKING, process_iq}]}.
|
||||||
?NS_BLOCKING, ?MODULE, process_iq).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, disco_features, 50),
|
ok.
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_BLOCKING).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -48,25 +48,18 @@
|
|||||||
-type direction() :: sent | received.
|
-type direction() :: sent | received.
|
||||||
-type c2s_state() :: ejabberd_c2s:state().
|
-type c2s_state() :: ejabberd_c2s:state().
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50),
|
{ok, [{hook, disco_local_features, disco_features, 50},
|
||||||
%% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90)
|
%% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90)
|
||||||
ejabberd_hooks:add(user_send_packet,Host, ?MODULE, user_send_packet, 89),
|
{hook, user_send_packet, user_send_packet, 89},
|
||||||
ejabberd_hooks:add(user_receive_packet,Host, ?MODULE, user_receive_packet, 89),
|
{hook, user_receive_packet, user_receive_packet, 89},
|
||||||
ejabberd_hooks:add(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50),
|
{hook, c2s_copy_session, c2s_copy_session, 50},
|
||||||
ejabberd_hooks:add(c2s_session_resumed, Host, ?MODULE, c2s_session_resumed, 50),
|
{hook, c2s_session_resumed, c2s_session_resumed, 50},
|
||||||
ejabberd_hooks:add(c2s_session_opened, Host, ?MODULE, c2s_session_opened, 50),
|
{hook, c2s_session_opened, c2s_session_opened, 50},
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2, ?MODULE, iq_handler).
|
{iq_handler, ejabberd_sm, ?NS_CARBONS_2, iq_handler}]}.
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2),
|
ok.
|
||||||
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, disco_features, 50),
|
|
||||||
%% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90)
|
|
||||||
ejabberd_hooks:delete(user_send_packet,Host, ?MODULE, user_send_packet, 89),
|
|
||||||
ejabberd_hooks:delete(user_receive_packet,Host, ?MODULE, user_receive_packet, 89),
|
|
||||||
ejabberd_hooks:delete(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_session_resumed, Host, ?MODULE, c2s_session_resumed, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_session_opened, Host, ?MODULE, c2s_session_opened, 50).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -44,50 +44,20 @@
|
|||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
-include_lib("stdlib/include/ms_transform.hrl").
|
-include_lib("stdlib/include/ms_transform.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(disco_local_items, Host, ?MODULE,
|
{ok, [{hook, disco_local_items, get_local_items, 50},
|
||||||
get_local_items, 50),
|
{hook, disco_local_features, get_local_features, 50},
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE,
|
{hook, disco_local_identity, get_local_identity, 50},
|
||||||
get_local_features, 50),
|
{hook, disco_sm_items, get_sm_items, 50},
|
||||||
ejabberd_hooks:add(disco_local_identity, Host, ?MODULE,
|
{hook, disco_sm_features, get_sm_features, 50},
|
||||||
get_local_identity, 50),
|
{hook, disco_sm_identity, get_sm_identity, 50},
|
||||||
ejabberd_hooks:add(disco_sm_items, Host, ?MODULE,
|
{hook, adhoc_local_items, adhoc_local_items, 50},
|
||||||
get_sm_items, 50),
|
{hook, adhoc_local_commands, adhoc_local_commands, 50},
|
||||||
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE,
|
{hook, adhoc_sm_items, adhoc_sm_items, 50},
|
||||||
get_sm_features, 50),
|
{hook, adhoc_sm_commands, adhoc_sm_commands, 50}]}.
|
||||||
ejabberd_hooks:add(disco_sm_identity, Host, ?MODULE,
|
|
||||||
get_sm_identity, 50),
|
|
||||||
ejabberd_hooks:add(adhoc_local_items, Host, ?MODULE,
|
|
||||||
adhoc_local_items, 50),
|
|
||||||
ejabberd_hooks:add(adhoc_local_commands, Host, ?MODULE,
|
|
||||||
adhoc_local_commands, 50),
|
|
||||||
ejabberd_hooks:add(adhoc_sm_items, Host, ?MODULE,
|
|
||||||
adhoc_sm_items, 50),
|
|
||||||
ejabberd_hooks:add(adhoc_sm_commands, Host, ?MODULE,
|
|
||||||
adhoc_sm_commands, 50),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(adhoc_sm_commands, Host, ?MODULE,
|
ok.
|
||||||
adhoc_sm_commands, 50),
|
|
||||||
ejabberd_hooks:delete(adhoc_sm_items, Host, ?MODULE,
|
|
||||||
adhoc_sm_items, 50),
|
|
||||||
ejabberd_hooks:delete(adhoc_local_commands, Host,
|
|
||||||
?MODULE, adhoc_local_commands, 50),
|
|
||||||
ejabberd_hooks:delete(adhoc_local_items, Host, ?MODULE,
|
|
||||||
adhoc_local_items, 50),
|
|
||||||
ejabberd_hooks:delete(disco_sm_identity, Host, ?MODULE,
|
|
||||||
get_sm_identity, 50),
|
|
||||||
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE,
|
|
||||||
get_sm_features, 50),
|
|
||||||
ejabberd_hooks:delete(disco_sm_items, Host, ?MODULE,
|
|
||||||
get_sm_items, 50),
|
|
||||||
ejabberd_hooks:delete(disco_local_identity, Host,
|
|
||||||
?MODULE, get_local_identity, 50),
|
|
||||||
ejabberd_hooks:delete(disco_local_features, Host,
|
|
||||||
?MODULE, get_local_features, 50),
|
|
||||||
ejabberd_hooks:delete(disco_local_items, Host, ?MODULE,
|
|
||||||
get_local_items, 50).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -62,32 +62,15 @@ start(Host, Opts) ->
|
|||||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
{ok, [{iq_handler, ejabberd_local, ?NS_LAST, process_local_iq},
|
||||||
?NS_LAST, ?MODULE, process_local_iq),
|
{iq_handler, ejabberd_sm, ?NS_LAST, process_sm_iq},
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
{hook, privacy_check_packet, privacy_check_packet, 30},
|
||||||
?NS_LAST, ?MODULE, process_sm_iq),
|
{hook, register_user, register_user, 50},
|
||||||
ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE,
|
{hook, remove_user, remove_user, 50},
|
||||||
privacy_check_packet, 30),
|
{hook, unset_presence_hook, on_presence_update, 50}]}.
|
||||||
ejabberd_hooks:add(register_user, Host, ?MODULE,
|
|
||||||
register_user, 50),
|
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
|
||||||
remove_user, 50),
|
|
||||||
ejabberd_hooks:add(unset_presence_hook, Host, ?MODULE,
|
|
||||||
on_presence_update, 50).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(register_user, Host, ?MODULE,
|
ok.
|
||||||
register_user, 50),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
|
||||||
remove_user, 50),
|
|
||||||
ejabberd_hooks:delete(unset_presence_hook, Host,
|
|
||||||
?MODULE, on_presence_update, 50),
|
|
||||||
ejabberd_hooks:delete(privacy_check_packet, Host, ?MODULE,
|
|
||||||
privacy_check_packet, 30),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
|
||||||
?NS_LAST),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_LAST).
|
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(Host, NewOpts, OldOpts) ->
|
||||||
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
||||||
|
@ -37,17 +37,12 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(c2s_unauthenticated_packet, Host, ?MODULE,
|
{ok, [{hook, c2s_unauthenticated_packet, c2s_unauthenticated_packet, 50},
|
||||||
c2s_unauthenticated_packet, 50),
|
{hook, c2s_pre_auth_features, c2s_stream_features, 50}]}.
|
||||||
ejabberd_hooks:add(c2s_pre_auth_features, Host, ?MODULE,
|
|
||||||
c2s_stream_features, 50).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(c2s_unauthenticated_packet, Host, ?MODULE,
|
ok.
|
||||||
c2s_unauthenticated_packet, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_pre_auth_features, Host, ?MODULE,
|
|
||||||
c2s_stream_features, 50).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -49,27 +49,19 @@
|
|||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE, offline_message_hook, 20),
|
{ok, [{hook, offline_message_hook, offline_message_hook, 20},
|
||||||
ejabberd_hooks:add(sm_register_connection_hook, Host, ?MODULE, sm_register_connection_hook, 20),
|
{hook, sm_register_connection_hook, sm_register_connection_hook, 20},
|
||||||
ejabberd_hooks:add(sm_remove_connection_hook, Host, ?MODULE, sm_remove_connection_hook, 20),
|
{hook, sm_remove_connection_hook, sm_remove_connection_hook, 20},
|
||||||
ejabberd_hooks:add(user_send_packet, Host, ?MODULE, user_send_packet, 20),
|
{hook, user_send_packet, user_send_packet, 20},
|
||||||
ejabberd_hooks:add(user_receive_packet, Host, ?MODULE, user_receive_packet, 20),
|
{hook, user_receive_packet, user_receive_packet, 20},
|
||||||
ejabberd_hooks:add(s2s_send_packet, Host, ?MODULE, s2s_send_packet, 20),
|
{hook, s2s_send_packet, s2s_send_packet, 20},
|
||||||
ejabberd_hooks:add(s2s_receive_packet, Host, ?MODULE, s2s_receive_packet, 20),
|
{hook, s2s_receive_packet, s2s_receive_packet, 20},
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 20),
|
{hook, remove_user, remove_user, 20},
|
||||||
ejabberd_hooks:add(register_user, Host, ?MODULE, register_user, 20).
|
{hook, register_user, register_user, 20}]}.
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(offline_message_hook, Host, ?MODULE, offline_message_hook, 20),
|
ok.
|
||||||
ejabberd_hooks:delete(sm_register_connection_hook, Host, ?MODULE, sm_register_connection_hook, 20),
|
|
||||||
ejabberd_hooks:delete(sm_remove_connection_hook, Host, ?MODULE, sm_remove_connection_hook, 20),
|
|
||||||
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, user_send_packet, 20),
|
|
||||||
ejabberd_hooks:delete(user_receive_packet, Host, ?MODULE, user_receive_packet, 20),
|
|
||||||
ejabberd_hooks:delete(s2s_send_packet, Host, ?MODULE, s2s_send_packet, 20),
|
|
||||||
ejabberd_hooks:delete(s2s_receive_packet, Host, ?MODULE, s2s_receive_packet, 20),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 20),
|
|
||||||
ejabberd_hooks:delete(register_user, Host, ?MODULE, register_user, 20).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -32,13 +32,12 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, Opts) ->
|
start(_Host, Opts) ->
|
||||||
User = mod_mqtt_bridge_opt:replication_user(Opts),
|
User = mod_mqtt_bridge_opt:replication_user(Opts),
|
||||||
start_servers(User, element(1, mod_mqtt_bridge_opt:servers(Opts))),
|
start_servers(User, element(1, mod_mqtt_bridge_opt:servers(Opts))),
|
||||||
ejabberd_hooks:add(mqtt_publish, Host, ?MODULE, mqtt_publish_hook, 50).
|
{ok, [{hook, mqtt_publish, mqtt_publish_hook, 50}]}.
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(mqtt_publish, Host, ?MODULE, mqtt_publish_hook, 50),
|
|
||||||
stop_servers(element(1, mod_mqtt_bridge_opt:servers(Host))),
|
stop_servers(element(1, mod_mqtt_bridge_opt:servers(Host))),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -120,51 +120,23 @@ start(Host, Opts) ->
|
|||||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
|
{ok, [{hook, offline_message_hook, store_packet, 50},
|
||||||
store_packet, 50),
|
{hook, c2s_self_presence, c2s_self_presence, 50},
|
||||||
ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, c2s_self_presence, 50),
|
{hook, remove_user, remove_user, 50},
|
||||||
ejabberd_hooks:add(remove_user, Host,
|
{hook, disco_sm_features, get_sm_features, 50},
|
||||||
?MODULE, remove_user, 50),
|
{hook, disco_local_features, get_sm_features, 50},
|
||||||
ejabberd_hooks:add(disco_sm_features, Host,
|
{hook, disco_sm_identity, get_sm_identity, 50},
|
||||||
?MODULE, get_sm_features, 50),
|
{hook, disco_sm_items, get_sm_items, 50},
|
||||||
ejabberd_hooks:add(disco_local_features, Host,
|
{hook, disco_info, get_info, 50},
|
||||||
?MODULE, get_sm_features, 50),
|
{hook, c2s_handle_info, c2s_handle_info, 50},
|
||||||
ejabberd_hooks:add(disco_sm_identity, Host,
|
{hook, c2s_copy_session, c2s_copy_session, 50},
|
||||||
?MODULE, get_sm_identity, 50),
|
{hook, webadmin_page_host, webadmin_page, 50},
|
||||||
ejabberd_hooks:add(disco_sm_items, Host,
|
{hook, webadmin_user, webadmin_user, 50},
|
||||||
?MODULE, get_sm_items, 50),
|
{hook, webadmin_user_parse_query, webadmin_user_parse_query, 50},
|
||||||
ejabberd_hooks:add(disco_info, Host, ?MODULE, get_info, 50),
|
{iq_handler, ejabberd_sm, ?NS_FLEX_OFFLINE, handle_offline_query}]}.
|
||||||
ejabberd_hooks:add(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50),
|
|
||||||
ejabberd_hooks:add(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50),
|
|
||||||
ejabberd_hooks:add(webadmin_page_host, Host,
|
|
||||||
?MODULE, webadmin_page, 50),
|
|
||||||
ejabberd_hooks:add(webadmin_user, Host,
|
|
||||||
?MODULE, webadmin_user, 50),
|
|
||||||
ejabberd_hooks:add(webadmin_user_parse_query, Host,
|
|
||||||
?MODULE, webadmin_user_parse_query, 50),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE,
|
|
||||||
?MODULE, handle_offline_query).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(offline_message_hook, Host,
|
ok.
|
||||||
?MODULE, store_packet, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_self_presence, Host, ?MODULE, c2s_self_presence, 50),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
|
||||||
remove_user, 50),
|
|
||||||
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, get_sm_features, 50),
|
|
||||||
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, get_sm_features, 50),
|
|
||||||
ejabberd_hooks:delete(disco_sm_identity, Host, ?MODULE, get_sm_identity, 50),
|
|
||||||
ejabberd_hooks:delete(disco_sm_items, Host, ?MODULE, get_sm_items, 50),
|
|
||||||
ejabberd_hooks:delete(disco_info, Host, ?MODULE, get_info, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50),
|
|
||||||
ejabberd_hooks:delete(webadmin_page_host, Host,
|
|
||||||
?MODULE, webadmin_page, 50),
|
|
||||||
ejabberd_hooks:delete(webadmin_user, Host,
|
|
||||||
?MODULE, webadmin_user, 50),
|
|
||||||
ejabberd_hooks:delete(webadmin_user_parse_query, Host,
|
|
||||||
?MODULE, webadmin_user_parse_query, 50),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE).
|
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(Host, NewOpts, OldOpts) ->
|
||||||
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
||||||
|
@ -37,14 +37,10 @@
|
|||||||
-record(pres_counter,
|
-record(pres_counter,
|
||||||
{dir, start, count, logged = false}).
|
{dir, start, count, logged = false}).
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE,
|
{ok, [{hook, privacy_check_packet, check_packet, 25}]}.
|
||||||
check_packet, 25),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(privacy_check_packet, Host,
|
|
||||||
?MODULE, check_packet, 25),
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
|
@ -73,32 +73,15 @@ start(Host, Opts) ->
|
|||||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
ejabberd_hooks:add(disco_local_features, Host, ?MODULE,
|
{ok, [{hook, disco_local_features, disco_features, 50},
|
||||||
disco_features, 50),
|
{hook, c2s_copy_session, c2s_copy_session, 50},
|
||||||
ejabberd_hooks:add(c2s_copy_session, Host, ?MODULE,
|
{hook, user_send_packet, user_send_packet, 50},
|
||||||
c2s_copy_session, 50),
|
{hook, privacy_check_packet, check_packet, 50},
|
||||||
ejabberd_hooks:add(user_send_packet, Host, ?MODULE,
|
{hook, remove_user, remove_user, 50},
|
||||||
user_send_packet, 50),
|
{iq_handler, ejabberd_sm, ?NS_PRIVACY, process_iq}]}.
|
||||||
ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE,
|
|
||||||
check_packet, 50),
|
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
|
||||||
remove_user, 50),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_PRIVACY, ?MODULE, process_iq).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE,
|
ok.
|
||||||
disco_features, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_copy_session, Host, ?MODULE,
|
|
||||||
c2s_copy_session, 50),
|
|
||||||
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE,
|
|
||||||
user_send_packet, 50),
|
|
||||||
ejabberd_hooks:delete(privacy_check_packet, Host,
|
|
||||||
?MODULE, check_packet, 50),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
|
||||||
remove_user, 50),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_PRIVACY).
|
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(Host, NewOpts, OldOpts) ->
|
||||||
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
||||||
|
@ -62,17 +62,13 @@ start(Host, Opts) ->
|
|||||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50),
|
ejabberd_commands:register_commands(?MODULE, get_commands_spec()),
|
||||||
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, get_sm_features, 50),
|
{ok, [{hook, remove_user, remove_user, 50},
|
||||||
ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE, pubsub_publish_item, 50),
|
{hook, disco_sm_features, get_sm_features, 50},
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE, ?MODULE, process_sm_iq),
|
{hook, pubsub_publish_item, pubsub_publish_item, 50},
|
||||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()).
|
{iq_handler, ejabberd_sm, ?NS_PRIVATE, process_sm_iq}]}.
|
||||||
|
|
||||||
stop(Host) ->
|
stop(Host) ->
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50),
|
|
||||||
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, get_sm_features, 50),
|
|
||||||
ejabberd_hooks:delete(pubsub_publish_item, Host, ?MODULE, pubsub_publish_item, 50),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE),
|
|
||||||
case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of
|
case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of
|
||||||
false ->
|
false ->
|
||||||
ejabberd_commands:unregister_commands(get_commands_spec());
|
ejabberd_commands:unregister_commands(get_commands_spec());
|
||||||
|
@ -43,29 +43,17 @@
|
|||||||
-include_lib("xmpp/include/xmpp.hrl").
|
-include_lib("xmpp/include/xmpp.hrl").
|
||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
|
||||||
?NS_REGISTER, ?MODULE, process_iq),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_REGISTER, ?MODULE, process_iq),
|
|
||||||
ejabberd_hooks:add(c2s_pre_auth_features, Host, ?MODULE,
|
|
||||||
stream_feature_register, 50),
|
|
||||||
ejabberd_hooks:add(c2s_unauthenticated_packet, Host,
|
|
||||||
?MODULE, c2s_unauthenticated_packet, 50),
|
|
||||||
ejabberd_mnesia:create(?MODULE, mod_register_ip,
|
ejabberd_mnesia:create(?MODULE, mod_register_ip,
|
||||||
[{ram_copies, [node()]}, {local_content, true},
|
[{ram_copies, [node()]}, {local_content, true},
|
||||||
{attributes, [key, value]}]),
|
{attributes, [key, value]}]),
|
||||||
ok.
|
{ok, [{iq_handler, ejabberd_local, ?NS_REGISTER, process_iq},
|
||||||
|
{iq_handler, ejabberd_sm, ?NS_REGISTER, process_iq},
|
||||||
|
{hook, c2s_pre_auth_features, stream_feature_register, 50},
|
||||||
|
{hook, c2s_unauthenticated_packet, c2s_unauthenticated_packet, 50}]}.
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(c2s_pre_auth_features, Host,
|
ok.
|
||||||
?MODULE, stream_feature_register, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_unauthenticated_packet, Host,
|
|
||||||
?MODULE, c2s_unauthenticated_packet, 50),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
|
||||||
?NS_REGISTER),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_REGISTER).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -91,48 +91,19 @@ start(Host, Opts) ->
|
|||||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
ejabberd_hooks:add(roster_get, Host, ?MODULE,
|
{ok, [{hook, roster_get, get_user_roster_items, 50},
|
||||||
get_user_roster_items, 50),
|
{hook, roster_in_subscription, in_subscription, 50},
|
||||||
ejabberd_hooks:add(roster_in_subscription, Host,
|
{hook, roster_out_subscription, out_subscription, 50},
|
||||||
?MODULE, in_subscription, 50),
|
{hook, roster_get_jid_info, get_jid_info, 50},
|
||||||
ejabberd_hooks:add(roster_out_subscription, Host,
|
{hook, remove_user, remove_user, 50},
|
||||||
?MODULE, out_subscription, 50),
|
{hook, c2s_self_presence, c2s_self_presence, 50},
|
||||||
ejabberd_hooks:add(roster_get_jid_info, Host, ?MODULE,
|
{hook, c2s_post_auth_features, get_versioning_feature, 50},
|
||||||
get_jid_info, 50),
|
{hook, webadmin_page_host, webadmin_page, 50},
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
{hook, webadmin_user, webadmin_user, 50},
|
||||||
remove_user, 50),
|
{iq_handler, ejabberd_sm, ?NS_ROSTER, process_iq}]}.
|
||||||
ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE,
|
|
||||||
c2s_self_presence, 50),
|
|
||||||
ejabberd_hooks:add(c2s_post_auth_features, Host,
|
|
||||||
?MODULE, get_versioning_feature, 50),
|
|
||||||
ejabberd_hooks:add(webadmin_page_host, Host, ?MODULE,
|
|
||||||
webadmin_page, 50),
|
|
||||||
ejabberd_hooks:add(webadmin_user, Host, ?MODULE,
|
|
||||||
webadmin_user, 50),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_ROSTER, ?MODULE, process_iq).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(roster_get, Host, ?MODULE,
|
ok.
|
||||||
get_user_roster_items, 50),
|
|
||||||
ejabberd_hooks:delete(roster_in_subscription, Host,
|
|
||||||
?MODULE, in_subscription, 50),
|
|
||||||
ejabberd_hooks:delete(roster_out_subscription, Host,
|
|
||||||
?MODULE, out_subscription, 50),
|
|
||||||
ejabberd_hooks:delete(roster_get_jid_info, Host,
|
|
||||||
?MODULE, get_jid_info, 50),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
|
||||||
remove_user, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_self_presence, Host, ?MODULE,
|
|
||||||
c2s_self_presence, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_post_auth_features,
|
|
||||||
Host, ?MODULE, get_versioning_feature, 50),
|
|
||||||
ejabberd_hooks:delete(webadmin_page_host, Host, ?MODULE,
|
|
||||||
webadmin_page, 50),
|
|
||||||
ejabberd_hooks:delete(webadmin_user, Host, ?MODULE,
|
|
||||||
webadmin_user, 50),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
|
||||||
?NS_ROSTER).
|
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(Host, NewOpts, OldOpts) ->
|
||||||
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
||||||
|
@ -40,49 +40,21 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(s2s_out_init, Host, ?MODULE, s2s_out_init, 50),
|
{ok, [{hook, s2s_out_init, s2s_out_init, 50},
|
||||||
ejabberd_hooks:add(s2s_out_closed, Host, ?MODULE, s2s_out_closed, 50),
|
{hook, s2s_out_closed, s2s_out_closed, 50},
|
||||||
ejabberd_hooks:add(s2s_in_pre_auth_features, Host, ?MODULE,
|
{hook, s2s_in_pre_auth_features, s2s_in_features, 50},
|
||||||
s2s_in_features, 50),
|
{hook, s2s_in_post_auth_features, s2s_in_features, 50},
|
||||||
ejabberd_hooks:add(s2s_in_post_auth_features, Host, ?MODULE,
|
{hook, s2s_in_handle_recv, s2s_in_recv, 50},
|
||||||
s2s_in_features, 50),
|
{hook, s2s_in_unauthenticated_packet, s2s_in_packet, 50},
|
||||||
ejabberd_hooks:add(s2s_in_handle_recv, Host, ?MODULE,
|
{hook, s2s_in_authenticated_packet, s2s_in_packet, 50},
|
||||||
s2s_in_recv, 50),
|
{hook, s2s_out_packet, s2s_out_packet, 50},
|
||||||
ejabberd_hooks:add(s2s_in_unauthenticated_packet, Host, ?MODULE,
|
{hook, s2s_out_downgraded, s2s_out_downgraded, 50},
|
||||||
s2s_in_packet, 50),
|
{hook, s2s_out_auth_result, s2s_out_auth_result, 50},
|
||||||
ejabberd_hooks:add(s2s_in_authenticated_packet, Host, ?MODULE,
|
{hook, s2s_out_tls_verify, s2s_out_tls_verify, 50}]}.
|
||||||
s2s_in_packet, 50),
|
|
||||||
ejabberd_hooks:add(s2s_out_packet, Host, ?MODULE,
|
|
||||||
s2s_out_packet, 50),
|
|
||||||
ejabberd_hooks:add(s2s_out_downgraded, Host, ?MODULE,
|
|
||||||
s2s_out_downgraded, 50),
|
|
||||||
ejabberd_hooks:add(s2s_out_auth_result, Host, ?MODULE,
|
|
||||||
s2s_out_auth_result, 50),
|
|
||||||
ejabberd_hooks:add(s2s_out_tls_verify, Host, ?MODULE,
|
|
||||||
s2s_out_tls_verify, 50).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(s2s_out_init, Host, ?MODULE, s2s_out_init, 50),
|
ok.
|
||||||
ejabberd_hooks:delete(s2s_out_closed, Host, ?MODULE, s2s_out_closed, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_in_pre_auth_features, Host, ?MODULE,
|
|
||||||
s2s_in_features, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_in_post_auth_features, Host, ?MODULE,
|
|
||||||
s2s_in_features, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_in_handle_recv, Host, ?MODULE,
|
|
||||||
s2s_in_recv, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_in_unauthenticated_packet, Host, ?MODULE,
|
|
||||||
s2s_in_packet, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_in_authenticated_packet, Host, ?MODULE,
|
|
||||||
s2s_in_packet, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_out_packet, Host, ?MODULE,
|
|
||||||
s2s_out_packet, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_out_downgraded, Host, ?MODULE,
|
|
||||||
s2s_out_downgraded, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_out_auth_result, Host, ?MODULE,
|
|
||||||
s2s_out_auth_result, 50),
|
|
||||||
ejabberd_hooks:delete(s2s_out_tls_verify, Host, ?MODULE,
|
|
||||||
s2s_out_tls_verify, 50).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -36,18 +36,11 @@
|
|||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
-include_lib("xmpp/include/xmpp.hrl").
|
-include_lib("xmpp/include/xmpp.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
ejabberd_hooks:add(user_send_packet, Host, ?MODULE,
|
{ok, [{hook, user_send_packet, log_user_send, 50},
|
||||||
log_user_send, 50),
|
{hook, user_receive_packet, log_user_receive, 50}]}.
|
||||||
ejabberd_hooks:add(user_receive_packet, Host, ?MODULE,
|
|
||||||
log_user_receive, 50),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE,
|
|
||||||
log_user_send, 50),
|
|
||||||
ejabberd_hooks:delete(user_receive_packet, Host,
|
|
||||||
?MODULE, log_user_receive, 50),
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
|
@ -85,53 +85,20 @@ start(Host, Opts) ->
|
|||||||
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
Mod = gen_mod:db_mod(Opts, ?MODULE),
|
||||||
Mod:init(Host, Opts),
|
Mod:init(Host, Opts),
|
||||||
init_cache(Mod, Host, Opts),
|
init_cache(Mod, Host, Opts),
|
||||||
ejabberd_hooks:add(webadmin_menu_host, Host, ?MODULE,
|
{ok, [{hook, webadmin_menu_host, webadmin_menu, 70},
|
||||||
webadmin_menu, 70),
|
{hook, webadmin_page_host, webadmin_page, 50},
|
||||||
ejabberd_hooks:add(webadmin_page_host, Host, ?MODULE,
|
{hook, roster_get, get_user_roster, 70},
|
||||||
webadmin_page, 50),
|
{hook, roster_in_subscription, in_subscription, 30},
|
||||||
ejabberd_hooks:add(roster_get, Host, ?MODULE,
|
{hook, roster_out_subscription, out_subscription, 30},
|
||||||
get_user_roster, 70),
|
{hook, roster_get_jid_info, get_jid_info, 70},
|
||||||
ejabberd_hooks:add(roster_in_subscription, Host,
|
{hook, roster_process_item, process_item, 50},
|
||||||
?MODULE, in_subscription, 30),
|
{hook, c2s_self_presence, c2s_self_presence, 50},
|
||||||
ejabberd_hooks:add(roster_out_subscription, Host,
|
{hook, unset_presence_hook, unset_presence, 50},
|
||||||
?MODULE, out_subscription, 30),
|
{hook, register_user, register_user, 50},
|
||||||
ejabberd_hooks:add(roster_get_jid_info, Host, ?MODULE,
|
{hook, remove_user, remove_user, 50}]}.
|
||||||
get_jid_info, 70),
|
|
||||||
ejabberd_hooks:add(roster_process_item, Host, ?MODULE,
|
|
||||||
process_item, 50),
|
|
||||||
ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE,
|
|
||||||
c2s_self_presence, 50),
|
|
||||||
ejabberd_hooks:add(unset_presence_hook, Host, ?MODULE,
|
|
||||||
unset_presence, 50),
|
|
||||||
ejabberd_hooks:add(register_user, Host, ?MODULE,
|
|
||||||
register_user, 50),
|
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE,
|
|
||||||
remove_user, 50).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(webadmin_menu_host, Host, ?MODULE,
|
ok.
|
||||||
webadmin_menu, 70),
|
|
||||||
ejabberd_hooks:delete(webadmin_page_host, Host, ?MODULE,
|
|
||||||
webadmin_page, 50),
|
|
||||||
ejabberd_hooks:delete(roster_get, Host, ?MODULE,
|
|
||||||
get_user_roster, 70),
|
|
||||||
ejabberd_hooks:delete(roster_in_subscription, Host,
|
|
||||||
?MODULE, in_subscription, 30),
|
|
||||||
ejabberd_hooks:delete(roster_out_subscription, Host,
|
|
||||||
?MODULE, out_subscription, 30),
|
|
||||||
ejabberd_hooks:delete(roster_get_jid_info, Host,
|
|
||||||
?MODULE, get_jid_info, 70),
|
|
||||||
ejabberd_hooks:delete(roster_process_item, Host,
|
|
||||||
?MODULE, process_item, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_self_presence, Host,
|
|
||||||
?MODULE, c2s_self_presence, 50),
|
|
||||||
ejabberd_hooks:delete(unset_presence_hook, Host,
|
|
||||||
?MODULE, unset_presence, 50),
|
|
||||||
ejabberd_hooks:delete(register_user, Host, ?MODULE,
|
|
||||||
register_user, 50),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE,
|
|
||||||
remove_user,
|
|
||||||
50).
|
|
||||||
|
|
||||||
reload(Host, NewOpts, OldOpts) ->
|
reload(Host, NewOpts, OldOpts) ->
|
||||||
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),
|
||||||
|
@ -38,21 +38,14 @@
|
|||||||
-include_lib("xmpp/include/xmpp.hrl").
|
-include_lib("xmpp/include/xmpp.hrl").
|
||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_0,
|
{ok, [{iq_handler, ejabberd_local, ?NS_SIC_0, process_local_iq},
|
||||||
?MODULE, process_local_iq),
|
{iq_handler, ejabberd_sm, ?NS_SIC_0, process_sm_iq},
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_0,
|
{iq_handler, ejabberd_local, ?NS_SIC_1, process_local_iq},
|
||||||
?MODULE, process_sm_iq),
|
{iq_handler, ejabberd_sm, ?NS_SIC_1, process_sm_iq}]}.
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_1,
|
|
||||||
?MODULE, process_local_iq),
|
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_1,
|
|
||||||
?MODULE, process_sm_iq).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_0),
|
ok.
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_SIC_0),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_1),
|
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_SIC_1).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -38,15 +38,14 @@
|
|||||||
-include_lib("xmpp/include/xmpp.hrl").
|
-include_lib("xmpp/include/xmpp.hrl").
|
||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_STATS,
|
{ok, [{iq_handler, ejabberd_local, ?NS_STATS, process_iq}]}.
|
||||||
?MODULE, process_iq).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_STATS).
|
ok.
|
||||||
|
|
||||||
reload(Host, NewOpts, _OldOpts) ->
|
reload(Host, NewOpts, _OldOpts) ->
|
||||||
start(Host, NewOpts).
|
ok.
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
@ -61,42 +61,22 @@
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
start(Host, Opts) ->
|
start(_Host, Opts) ->
|
||||||
init_cache(Opts),
|
init_cache(Opts),
|
||||||
ejabberd_hooks:add(c2s_stream_started, Host, ?MODULE,
|
{ok, [{hook, c2s_stream_started, c2s_stream_started, 50},
|
||||||
c2s_stream_started, 50),
|
{hook, c2s_post_auth_features, c2s_stream_features, 50},
|
||||||
ejabberd_hooks:add(c2s_post_auth_features, Host, ?MODULE,
|
{hook, c2s_unauthenticated_packet, c2s_unauthenticated_packet, 50},
|
||||||
c2s_stream_features, 50),
|
{hook, c2s_unbinded_packet, c2s_unbinded_packet, 50},
|
||||||
ejabberd_hooks:add(c2s_unauthenticated_packet, Host, ?MODULE,
|
{hook, c2s_authenticated_packet, c2s_authenticated_packet, 50},
|
||||||
c2s_unauthenticated_packet, 50),
|
{hook, c2s_handle_send, c2s_handle_send, 50},
|
||||||
ejabberd_hooks:add(c2s_unbinded_packet, Host, ?MODULE,
|
{hook, c2s_handle_recv, c2s_handle_recv, 50},
|
||||||
c2s_unbinded_packet, 50),
|
{hook, c2s_handle_info, c2s_handle_info, 50},
|
||||||
ejabberd_hooks:add(c2s_authenticated_packet, Host, ?MODULE,
|
{hook, c2s_handle_call, c2s_handle_call, 50},
|
||||||
c2s_authenticated_packet, 50),
|
{hook, c2s_closed, c2s_closed, 50},
|
||||||
ejabberd_hooks:add(c2s_handle_send, Host, ?MODULE, c2s_handle_send, 50),
|
{hook, c2s_terminated, c2s_terminated, 50}]}.
|
||||||
ejabberd_hooks:add(c2s_handle_recv, Host, ?MODULE, c2s_handle_recv, 50),
|
|
||||||
ejabberd_hooks:add(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50),
|
|
||||||
ejabberd_hooks:add(c2s_handle_call, Host, ?MODULE, c2s_handle_call, 50),
|
|
||||||
ejabberd_hooks:add(c2s_closed, Host, ?MODULE, c2s_closed, 50),
|
|
||||||
ejabberd_hooks:add(c2s_terminated, Host, ?MODULE, c2s_terminated, 50).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(c2s_stream_started, Host, ?MODULE,
|
ok.
|
||||||
c2s_stream_started, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_post_auth_features, Host, ?MODULE,
|
|
||||||
c2s_stream_features, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_unauthenticated_packet, Host, ?MODULE,
|
|
||||||
c2s_unauthenticated_packet, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_unbinded_packet, Host, ?MODULE,
|
|
||||||
c2s_unbinded_packet, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_authenticated_packet, Host, ?MODULE,
|
|
||||||
c2s_authenticated_packet, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_handle_send, Host, ?MODULE, c2s_handle_send, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_handle_recv, Host, ?MODULE, c2s_handle_recv, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_handle_call, Host, ?MODULE, c2s_handle_call, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_closed, Host, ?MODULE, c2s_closed, 50),
|
|
||||||
ejabberd_hooks:delete(c2s_terminated, Host, ?MODULE, c2s_terminated, 50).
|
|
||||||
|
|
||||||
reload(_Host, NewOpts, _OldOpts) ->
|
reload(_Host, NewOpts, _OldOpts) ->
|
||||||
init_cache(NewOpts),
|
init_cache(NewOpts),
|
||||||
|
@ -39,13 +39,11 @@
|
|||||||
-include_lib("xmpp/include/xmpp.hrl").
|
-include_lib("xmpp/include/xmpp.hrl").
|
||||||
-include("translate.hrl").
|
-include("translate.hrl").
|
||||||
|
|
||||||
start(Host, _Opts) ->
|
start(_Host, _Opts) ->
|
||||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
|
{ok, [{iq_handler, ejabberd_local, ?NS_TIME, process_local_iq}]}.
|
||||||
?NS_TIME, ?MODULE, process_local_iq).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
ok.
|
||||||
?NS_TIME).
|
|
||||||
|
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
@ -48,22 +48,13 @@
|
|||||||
|
|
||||||
start(Host, Opts) ->
|
start(Host, Opts) ->
|
||||||
init_cache(Host, Opts),
|
init_cache(Host, Opts),
|
||||||
ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE,
|
{ok, [{hook, c2s_self_presence, update_presence, 100},
|
||||||
update_presence, 100),
|
{hook, user_send_packet, user_send_packet, 50},
|
||||||
ejabberd_hooks:add(user_send_packet, Host, ?MODULE,
|
{hook, vcard_iq_set, vcard_set, 90},
|
||||||
user_send_packet, 50),
|
{hook, remove_user, remove_user, 50}]}.
|
||||||
ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE, vcard_set,
|
|
||||||
90),
|
|
||||||
ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50).
|
|
||||||
|
|
||||||
stop(Host) ->
|
stop(_Host) ->
|
||||||
ejabberd_hooks:delete(c2s_self_presence, Host,
|
ok.
|
||||||
?MODULE, update_presence, 100),
|
|
||||||
ejabberd_hooks:delete(user_send_packet, Host, ?MODULE,
|
|
||||||
user_send_packet, 50),
|
|
||||||
ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE,
|
|
||||||
vcard_set, 90),
|
|
||||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50).
|
|
||||||
|
|
||||||
reload(Host, NewOpts, _OldOpts) ->
|
reload(Host, NewOpts, _OldOpts) ->
|
||||||
init_cache(Host, NewOpts).
|
init_cache(Host, NewOpts).
|
||||||
|
Loading…
Reference in New Issue
Block a user