mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Merge pull request #988 from tnull/edoc_fix
Fixed type specifications for 'rebar doc'
This commit is contained in:
commit
eb0890284a
@ -222,7 +222,7 @@ check_password_cache(User, Server, Password,
|
||||
get_password_internal(User, Server) ->
|
||||
ejabberd_auth_internal:get_password(User, Server).
|
||||
|
||||
%% @spec (User, Server, CacheTime) -> false | Password::string()
|
||||
-spec get_password_cache(User::binary(), Server::binary(), CacheTime::integer()) -> Password::string() | false.
|
||||
get_password_cache(User, Server, CacheTime) ->
|
||||
case get_last_access(User, Server) of
|
||||
online -> get_password_internal(User, Server);
|
||||
@ -273,10 +273,10 @@ is_fresh_enough(TimeStampLast, CacheTime) ->
|
||||
Now = p1_time_compat:system_time(seconds),
|
||||
TimeStampLast + CacheTime > Now.
|
||||
|
||||
%% @spec (User, Server) -> online | never | mod_last_required | TimeStamp::integer()
|
||||
%% Code copied from mod_configure.erl
|
||||
%% Code copied from web/ejabberd_web_admin.erl
|
||||
%% TODO: Update time format to XEP-0202: Entity Time
|
||||
-spec(get_last_access(User::binary(), Server::binary()) -> (online | never | mod_last_required | integer())).
|
||||
get_last_access(User, Server) ->
|
||||
case ejabberd_sm:get_user_resources(User, Server) of
|
||||
[] ->
|
||||
|
@ -112,7 +112,7 @@ get_env_config() ->
|
||||
%% @doc Read the ejabberd configuration file.
|
||||
%% It also includes additional configuration files and replaces macros.
|
||||
%% This function will crash if finds some error in the configuration file.
|
||||
%% @spec (File::string()) -> #state{}.
|
||||
%% @spec (File::string()) -> #state{}
|
||||
read_file(File) ->
|
||||
read_file(File, [{replace_macros, true},
|
||||
{include_files, true},
|
||||
|
@ -50,6 +50,7 @@
|
||||
%% "ejabberd.log" in current directory.
|
||||
%% Note: If the directory where to place the ejabberd log file to not exist,
|
||||
%% it is not created and no log file will be generated.
|
||||
%% @spec () -> string()
|
||||
get_log_path() ->
|
||||
case ejabberd_config:env_binary_to_list(ejabberd, log_path) of
|
||||
{ok, Path} ->
|
||||
@ -99,6 +100,7 @@ get_string_env(Name, Default) ->
|
||||
Default
|
||||
end.
|
||||
|
||||
%% @spec () -> ok
|
||||
start() ->
|
||||
application:load(sasl),
|
||||
application:set_env(sasl, sasl_error_logger, false),
|
||||
@ -126,10 +128,12 @@ start() ->
|
||||
ejabberd:start_app(lager),
|
||||
ok.
|
||||
|
||||
%% @spec () -> ok
|
||||
reopen_log() ->
|
||||
%% Lager detects external log rotation automatically.
|
||||
ok.
|
||||
|
||||
%% @spec () -> ok
|
||||
rotate_log() ->
|
||||
lager_crash_log ! rotate,
|
||||
lists:foreach(
|
||||
@ -139,6 +143,7 @@ rotate_log() ->
|
||||
ok
|
||||
end, gen_event:which_handlers(lager_event)).
|
||||
|
||||
%% @spec () -> {loglevel(), atom(), string()}
|
||||
get() ->
|
||||
case lager:get_loglevel(lager_console_backend) of
|
||||
none -> {0, no_log, "No log"};
|
||||
@ -152,6 +157,7 @@ get() ->
|
||||
debug -> {5, debug, "Debug"}
|
||||
end.
|
||||
|
||||
%% @spec (loglevel() | {loglevel(), list()}) -> {module, module()}
|
||||
set(LogLevel) when is_integer(LogLevel) ->
|
||||
LagerLogLevel = case LogLevel of
|
||||
0 -> none;
|
||||
|
@ -80,7 +80,6 @@ import_file(FileName) ->
|
||||
import_file(FileName, #state{}).
|
||||
|
||||
-spec import_file(binary(), state()) -> ok | {error, atom()}.
|
||||
|
||||
import_file(FileName, State) ->
|
||||
case file:open(FileName, [read, binary]) of
|
||||
{ok, Fd} ->
|
||||
@ -97,72 +96,14 @@ import_file(FileName, State) ->
|
||||
{error, Reason}
|
||||
end.
|
||||
|
||||
%%%==================================
|
||||
%%%% Process Elements
|
||||
%%%==================================
|
||||
%%%% Process Element
|
||||
%%%==================================
|
||||
%%%% Add user
|
||||
%% @spec (El::xmlel(), Domain::string(), User::binary(), Password::binary() | none)
|
||||
%% -> ok | {error, ErrorText::string()}
|
||||
%% @doc Add a new user to the database.
|
||||
%% If user already exists, it will be only updated.
|
||||
-spec export_server(binary()) -> any().
|
||||
|
||||
%% @spec (User::string(), Password::string(), Domain::string())
|
||||
%% -> ok | {atomic, exists} | {error, not_allowed}
|
||||
%% @doc Create a new user
|
||||
export_server(Dir) ->
|
||||
export_hosts(?MYHOSTS, Dir).
|
||||
|
||||
%%%==================================
|
||||
%%%% Populate user
|
||||
%% @spec (User::string(), Domain::string(), El::xml())
|
||||
%% -> ok | {error, not_found}
|
||||
%%
|
||||
%% @doc Add a new user from a XML file with a roster list.
|
||||
%%
|
||||
%% Example of a file:
|
||||
%% ```
|
||||
%% <?xml version='1.0' encoding='UTF-8'?>
|
||||
%% <server-data xmlns='http://www.xmpp.org/extensions/xep-0227.html#ns'>
|
||||
%% <host jid='localhost'>
|
||||
%% <user name='juliet' password='s3crEt'>
|
||||
%% <query xmlns='jabber:iq:roster'>
|
||||
%% <item jid='romeo@montague.net'
|
||||
%% name='Romeo'
|
||||
%% subscription='both'>
|
||||
%% <group>Friends</group>
|
||||
%% </item>
|
||||
%% </query>
|
||||
%% </user>
|
||||
%% </host>
|
||||
%% </server-data>
|
||||
%% '''
|
||||
-spec export_host(binary(), binary()) -> any().
|
||||
|
||||
export_host(Dir, Host) ->
|
||||
export_hosts([Host], Dir).
|
||||
|
||||
%% @spec User = String with the user name
|
||||
%% Domain = String with a domain name
|
||||
%% El = Sub XML element with vCard tags values
|
||||
%% @ret ok | {error, not_found}
|
||||
%% @doc Read vcards from the XML and send it to the server
|
||||
%%
|
||||
%% Example:
|
||||
%% ```
|
||||
%% <?xml version='1.0' encoding='UTF-8'?>
|
||||
%% <server-data xmlns='http://www.xmpp.org/extensions/xep-0227.html#ns'>
|
||||
%% <host jid='localhost'>
|
||||
%% <user name='admin' password='s3crEt'>
|
||||
%% <vCard xmlns='vcard-temp'>
|
||||
%% <FN>Admin</FN>
|
||||
%% </vCard>
|
||||
%% </user>
|
||||
%% </host>
|
||||
%% </server-data>
|
||||
%% '''
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
@ -194,11 +135,6 @@ export_hosts(Hosts, Dir) ->
|
||||
{error, Reason}
|
||||
end.
|
||||
|
||||
%% @spec User = String with the user name
|
||||
%% Domain = String with a domain name
|
||||
%% El = Sub XML element with offline messages values
|
||||
%% @ret ok | {error, not_found}
|
||||
%% @doc Read off-line message from the XML and send it to the server
|
||||
export_host(Dir, FnH, Host) ->
|
||||
DFn = make_host_basefilename(Dir, FnH),
|
||||
case file:open(DFn, [raw, write]) of
|
||||
@ -223,11 +159,6 @@ export_host(Dir, FnH, Host) ->
|
||||
{error, Reason}
|
||||
end.
|
||||
|
||||
%% @spec User = String with the user name
|
||||
%% Domain = String with a domain name
|
||||
%% El = Sub XML element with private storage values
|
||||
%% @ret ok | {error, not_found}
|
||||
%% @doc Private storage parsing
|
||||
export_users([{User, _S}|Users], Server, Fd) ->
|
||||
case export_user(User, Server, Fd) of
|
||||
ok ->
|
||||
@ -238,8 +169,6 @@ export_users([{User, _S}|Users], Server, Fd) ->
|
||||
export_users([], _Server, _Fd) ->
|
||||
ok.
|
||||
|
||||
%%%==================================
|
||||
%%%% Utilities
|
||||
export_user(User, Server, Fd) ->
|
||||
Password = ejabberd_auth:get_password_s(User, Server),
|
||||
LServer = jid:nameprep(Server),
|
||||
@ -289,7 +218,6 @@ get_vcard(User, Server) ->
|
||||
[]
|
||||
end.
|
||||
|
||||
%%%==================================
|
||||
get_offline(User, Server) ->
|
||||
case mod_offline:get_offline_els(User, Server) of
|
||||
[] ->
|
||||
@ -306,7 +234,6 @@ get_offline(User, Server) ->
|
||||
[#xmlel{name = <<"offline-messages">>, children = NewEls}]
|
||||
end.
|
||||
|
||||
%%%% Export hosts
|
||||
get_privacy(User, Server) ->
|
||||
case mod_privacy:get_user_lists(User, Server) of
|
||||
{ok, #privacy{default = Default,
|
||||
@ -333,7 +260,6 @@ get_privacy(User, Server) ->
|
||||
[]
|
||||
end.
|
||||
|
||||
%% @spec (Dir::string(), Hosts::[string()]) -> ok
|
||||
get_roster(User, Server) ->
|
||||
JID = jid:make(User, Server, <<>>),
|
||||
case mod_roster:get_roster(User, Server) of
|
||||
@ -576,8 +502,6 @@ process_roster(El, State = #state{user = U, server = S}) ->
|
||||
stop("Failed to write roster: ~p", [Err])
|
||||
end.
|
||||
|
||||
%%%==================================
|
||||
%%%% Export server
|
||||
process_privacy(El, State = #state{user = U, server = S}) ->
|
||||
JID = jid:make(U, S, <<"">>),
|
||||
case mod_privacy:process_iq_set(
|
||||
@ -603,7 +527,6 @@ process_privacy(El, State = #state{user = U, server = S}) ->
|
||||
{ok, State}
|
||||
end.
|
||||
|
||||
%% @spec (Dir::string()) -> ok
|
||||
process_private(El, State = #state{user = U, server = S}) ->
|
||||
JID = jid:make(U, S, <<"">>),
|
||||
case mod_private:process_sm_iq(
|
||||
@ -614,8 +537,6 @@ process_private(El, State = #state{user = U, server = S}) ->
|
||||
stop("Failed to write private: ~p", [Err])
|
||||
end.
|
||||
|
||||
%%%==================================
|
||||
%%%% Export host
|
||||
process_vcard(El, State = #state{user = U, server = S}) ->
|
||||
JID = jid:make(U, S, <<"">>),
|
||||
case mod_vcard:process_sm_iq(
|
||||
@ -626,7 +547,6 @@ process_vcard(El, State = #state{user = U, server = S}) ->
|
||||
stop("Failed to write vcard: ~p", [Err])
|
||||
end.
|
||||
|
||||
%% @spec (Dir::string(), Host::string()) -> ok
|
||||
process_offline_msg(El, State = #state{user = U, server = S}) ->
|
||||
FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
||||
case jid:from_string(FromS) of
|
||||
@ -643,7 +563,6 @@ process_offline_msg(El, State = #state{user = U, server = S}) ->
|
||||
stop("Invalid 'from' = ~s", [FromS])
|
||||
end.
|
||||
|
||||
%% @spec (Dir::string(), Fn::string(), Host::string()) -> ok
|
||||
process_presence(El, #state{user = U, server = S} = State) ->
|
||||
FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
||||
case jid:from_string(FromS) of
|
||||
|
@ -1775,6 +1775,20 @@ update_auth(Host, Node, Type, Nidx, Subscriber, Allow, Subs) ->
|
||||
%%<li>nodetree create_node checks if nodeid already exists</li>
|
||||
%%<li>node plugin create_node just sets default affiliation/subscription</li>
|
||||
%%</ul>
|
||||
-spec(create_node/5 ::
|
||||
(
|
||||
Host :: mod_pubsub:host(),
|
||||
ServerHost :: binary(),
|
||||
Node :: <<>> | mod_pubsub:nodeId(),
|
||||
Owner :: jid(),
|
||||
Type :: binary())
|
||||
-> {result, [xmlel(),...]}
|
||||
%%%
|
||||
| {error, xmlel()}
|
||||
).
|
||||
create_node(Host, ServerHost, Node, Owner, Type) ->
|
||||
create_node(Host, ServerHost, Node, Owner, Type, all, []).
|
||||
|
||||
-spec(create_node/7 ::
|
||||
(
|
||||
Host :: mod_pubsub:host(),
|
||||
@ -1788,8 +1802,6 @@ update_auth(Host, Node, Type, Nidx, Subscriber, Allow, Subs) ->
|
||||
%%%
|
||||
| {error, xmlel()}
|
||||
).
|
||||
create_node(Host, ServerHost, Node, Owner, Type) ->
|
||||
create_node(Host, ServerHost, Node, Owner, Type, all, []).
|
||||
create_node(Host, ServerHost, <<>>, Owner, Type, Access, Configuration) ->
|
||||
case lists:member(<<"instant-nodes">>, plugin_features(Host, Type)) of
|
||||
true ->
|
||||
|
Loading…
Reference in New Issue
Block a user