mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Store who defines a command, specially when defined by ejabberd modules
This commit is contained in:
parent
2050cdffb4
commit
ccb4328d06
@ -59,6 +59,7 @@
|
||||
policy = restricted :: open | restricted | admin | user,
|
||||
%% access is: [accessRuleName] or [{Module, AccessOption, DefaultAccessRuleName}]
|
||||
access = [] :: [{atom(),atom(),atom()}|atom()],
|
||||
definer = unknown :: atom(),
|
||||
result = {res, rescode} :: rterm() | '_' | '$2',
|
||||
args_rename = [] :: [{atom(),atom()}],
|
||||
args_desc = none :: none | [string()] | '_',
|
||||
|
@ -41,6 +41,7 @@
|
||||
get_tags_commands/0,
|
||||
get_tags_commands/1,
|
||||
register_commands/1,
|
||||
register_commands/2,
|
||||
unregister_commands/1,
|
||||
get_commands_spec/0,
|
||||
get_commands_definition/0,
|
||||
@ -129,10 +130,13 @@ code_change(_OldVsn, State, _Extra) ->
|
||||
-spec register_commands([ejabberd_commands()]) -> ok.
|
||||
|
||||
register_commands(Commands) ->
|
||||
register_commands(unknown, Commands).
|
||||
|
||||
register_commands(Definer, Commands) ->
|
||||
lists:foreach(
|
||||
fun(Command) ->
|
||||
%% XXX check if command exists
|
||||
mnesia:dirty_write(Command)
|
||||
mnesia:dirty_write(Command#ejabberd_commands{definer = Definer})
|
||||
%% ?DEBUG("This command is already defined:~n~p", [Command])
|
||||
end,
|
||||
Commands),
|
||||
|
@ -92,7 +92,7 @@
|
||||
%%%
|
||||
|
||||
start(_Host, _Opts) ->
|
||||
ejabberd_commands:register_commands(get_commands_spec()).
|
||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()).
|
||||
|
||||
stop(Host) ->
|
||||
case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of
|
||||
|
@ -46,7 +46,7 @@
|
||||
%%%
|
||||
|
||||
start(_Host, _Opts) ->
|
||||
ejabberd_commands:register_commands(get_commands_spec()).
|
||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()).
|
||||
|
||||
stop(_Host) ->
|
||||
ejabberd_commands:unregister_commands(get_commands_spec()).
|
||||
|
@ -107,7 +107,7 @@ c2s_stream_started(#{ip := {Addr, _}} = State, _) ->
|
||||
start(Host, Opts) ->
|
||||
catch ets:new(failed_auth, [named_table, public,
|
||||
{heir, erlang:group_leader(), none}]),
|
||||
ejabberd_commands:register_commands(get_commands_spec()),
|
||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()),
|
||||
gen_mod:start_child(?MODULE, Host, Opts).
|
||||
|
||||
stop(Host) ->
|
||||
|
@ -148,7 +148,7 @@ start(Host, Opts) ->
|
||||
ejabberd_hooks:add(check_create_room, Host, ?MODULE,
|
||||
check_create_room, 50)
|
||||
end,
|
||||
ejabberd_commands:register_commands(get_commands_spec()),
|
||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()),
|
||||
ok;
|
||||
Err ->
|
||||
Err
|
||||
|
@ -57,7 +57,7 @@
|
||||
%%----------------------------
|
||||
|
||||
start(Host, _Opts) ->
|
||||
ejabberd_commands:register_commands(get_commands_spec()),
|
||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()),
|
||||
ejabberd_hooks:add(webadmin_menu_main, ?MODULE, web_menu_main, 50),
|
||||
ejabberd_hooks:add(webadmin_menu_host, Host, ?MODULE, web_menu_host, 50),
|
||||
ejabberd_hooks:add(webadmin_page_main, ?MODULE, web_page_main, 50),
|
||||
|
@ -66,7 +66,7 @@ start(Host, Opts) ->
|
||||
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, get_sm_features, 50),
|
||||
ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE, pubsub_publish_item, 50),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE, ?MODULE, process_sm_iq),
|
||||
ejabberd_commands:register_commands(get_commands_spec()).
|
||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()).
|
||||
|
||||
stop(Host) ->
|
||||
ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50),
|
||||
|
@ -98,7 +98,7 @@ start(Host, Opts) ->
|
||||
init_cache(Mod, Host, Opts),
|
||||
register_iq_handlers(Host),
|
||||
register_hooks(Host),
|
||||
ejabberd_commands:register_commands(get_commands_spec()).
|
||||
ejabberd_commands:register_commands(?MODULE, get_commands_spec()).
|
||||
|
||||
-spec stop(binary()) -> ok.
|
||||
stop(Host) ->
|
||||
|
Loading…
Reference in New Issue
Block a user