mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
mod_offline: make some database callbacks optional
This commit is contained in:
parent
06d69c5277
commit
edf03b0f3d
@ -101,6 +101,8 @@
|
|||||||
-callback remove_all_messages(binary(), binary()) -> {atomic, any()}.
|
-callback remove_all_messages(binary(), binary()) -> {atomic, any()}.
|
||||||
-callback count_messages(binary(), binary()) -> non_neg_integer().
|
-callback count_messages(binary(), binary()) -> non_neg_integer().
|
||||||
|
|
||||||
|
-optional_callbacks([remove_expired_messages/1, remove_old_messages/2]).
|
||||||
|
|
||||||
depends(_Host, _Opts) ->
|
depends(_Host, _Opts) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
@ -551,12 +553,18 @@ privacy_check_packet(#{lserver := LServer} = State, Pkt, Dir) ->
|
|||||||
remove_expired_messages(Server) ->
|
remove_expired_messages(Server) ->
|
||||||
LServer = jid:nameprep(Server),
|
LServer = jid:nameprep(Server),
|
||||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||||
Mod:remove_expired_messages(LServer).
|
case erlang:function_exported(Mod, remove_expired_messages, 1) of
|
||||||
|
true -> Mod:remove_expired_messages(LServer);
|
||||||
|
false -> erlang:error(not_implemented)
|
||||||
|
end.
|
||||||
|
|
||||||
remove_old_messages(Days, Server) ->
|
remove_old_messages(Days, Server) ->
|
||||||
LServer = jid:nameprep(Server),
|
LServer = jid:nameprep(Server),
|
||||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||||
Mod:remove_old_messages(Days, LServer).
|
case erlang:function_exported(Mod, remove_old_messages, 2) of
|
||||||
|
true -> Mod:remove_old_messages(Days, LServer);
|
||||||
|
false -> erlang:error(not_implemented)
|
||||||
|
end.
|
||||||
|
|
||||||
-spec remove_user(binary(), binary()) -> ok.
|
-spec remove_user(binary(), binary()) -> ok.
|
||||||
remove_user(User, Server) ->
|
remove_user(User, Server) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user