1 |
|
-module(ejabberd_auth_anonymous_backend). |
2 |
|
|
3 |
|
-export([init/1, stop/1, does_anonymous_user_exist/2, remove_connection/3, add_connection/3]). |
4 |
|
|
5 |
|
-define(MAIN_MODULE, ejabberd_auth_anonymous). |
6 |
|
|
7 |
|
-callback init(mongooseim:host_type()) -> ok. |
8 |
|
|
9 |
|
-callback stop(mongooseim:host_type()) -> ok. |
10 |
|
|
11 |
|
-callback does_anonymous_user_exist(mongooseim:host_type(), jid:simple_bare_jid()) -> boolean(). |
12 |
|
|
13 |
|
-callback remove_connection(mongooseim:host_type(), ejabberd_sm:sid(), jid:simple_bare_jid()) -> ok. |
14 |
|
|
15 |
|
-callback add_connection(mongooseim:host_type(), ejabberd_sm:sid(), jid:simple_bare_jid()) -> ok. |
16 |
|
|
17 |
|
-spec init(mongooseim:host_type()) -> ok. |
18 |
|
init(HostType) -> |
19 |
136 |
TrackedFuns = [does_anonymous_user_exist], |
20 |
136 |
Backend = mongoose_config:get_opt([{auth, HostType}, anonymous, backend]), |
21 |
136 |
mongoose_backend:init(HostType, ?MAIN_MODULE, TrackedFuns, #{backend => Backend}), |
22 |
136 |
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, [HostType]). |
23 |
|
|
24 |
|
-spec stop(mongooseim:host_type()) -> ok. |
25 |
|
stop(HostType) -> |
26 |
:-( |
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, [HostType]). |
27 |
|
|
28 |
|
-spec does_anonymous_user_exist(mongooseim:host_type(), jid:simple_bare_jid()) -> boolean(). |
29 |
|
does_anonymous_user_exist(HostType, US) -> |
30 |
16 |
Args = [HostType, US], |
31 |
16 |
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
32 |
|
|
33 |
|
-spec add_connection(mongooseim:host_type(), ejabberd_sm:sid(), jid:simple_bare_jid()) -> ok. |
34 |
|
add_connection(HostType, SID, US) -> |
35 |
4 |
Args = [HostType, SID, US], |
36 |
4 |
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
37 |
|
|
38 |
|
-spec remove_connection(mongooseim:host_type(), ejabberd_sm:sid(), jid:simple_bare_jid()) -> ok. |
39 |
|
remove_connection(HostType, SID, US) -> |
40 |
4 |
Args = [HostType, SID, US], |
41 |
4 |
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |