./ct_report/coverage/ejabberd_auth_anonymous_cets.COVER.html

1 -module(ejabberd_auth_anonymous_cets).
2
3 -behaviour(ejabberd_auth_anonymous_backend).
4
5 -export([init/1, stop/1, does_anonymous_user_exist/2, add_connection/3, remove_connection/3]).
6
7 -spec init(mongooseim:host_type()) -> ok.
8 init(HostType) ->
9
:-(
Tab = table_name(HostType),
10
:-(
cets:start(Tab, #{type => bag}),
11
:-(
cets_discovery:add_table(mongoose_cets_discovery, Tab),
12
:-(
ok.
13
14 -spec does_anonymous_user_exist(mongooseim:host_type(), jid:simple_bare_jid()) -> boolean().
15 does_anonymous_user_exist(HostType, US) ->
16
:-(
Tab = table_name(HostType),
17
:-(
[] =/= ets:lookup(Tab, US).
18
19 -spec add_connection(mongooseim:host_type(), ejabberd_sm:sid(), jid:simple_bare_jid()) -> ok.
20 add_connection(HostType, SID, US) ->
21
:-(
Tab = table_name(HostType),
22
:-(
cets:insert(Tab, {US, SID}).
23
24 -spec remove_connection(mongooseim:host_type(), ejabberd_sm:sid(), jid:simple_bare_jid()) -> ok.
25 remove_connection(HostType, SID, US) ->
26
:-(
Tab = table_name(HostType),
27
:-(
cets:delete_object(Tab, {US, SID}).
28
29 -spec stop(mongooseim:host_type()) -> ok.
30 stop(HostType) ->
31
:-(
Tab = table_name(HostType),
32
:-(
cets_discovery:delete_table(mongoose_cets_discovery, Tab),
33
:-(
cets:stop(Tab),
34
:-(
ok.
35
36 table_name(HostType) ->
37
:-(
binary_to_atom(<<"cets_auth_anonymous_", HostType/binary>>).
Line Hits Source