ejabberd_commands: Add the command version as a tag "vX"

This commit is contained in:
Badlop 2023-11-30 11:17:22 +01:00
parent 1326a7764a
commit 98d7519274
1 changed files with 13 additions and 1 deletions

View File

@ -147,13 +147,25 @@ register_commands(Definer, Commands) ->
lists:foreach(
fun(Command) ->
%% XXX check if command exists
mnesia:dirty_write(Command#ejabberd_commands{definer = Definer})
mnesia:dirty_write(register_command_prepare(Command, Definer))
%% ?DEBUG("This command is already defined:~n~p", [Command])
end,
Commands),
ejabberd_access_permissions:invalidate(),
ok.
register_command_prepare(Command, Definer) ->
Tags1 = Command#ejabberd_commands.tags,
Tags2 = case Command#ejabberd_commands.version of
0 -> Tags1;
Version -> Tags1 ++ [list_to_atom("v"++integer_to_list(Version))]
end,
Command#ejabberd_commands{definer = Definer, tags = Tags2}.
-spec unregister_commands([ejabberd_commands()]) -> ok.
unregister_commands(Commands) ->