./ct_report/coverage/mongoose_graphql_muc_light_helper.COVER.html

1 -module(mongoose_graphql_muc_light_helper).
2
3 -export([make_room/1, make_ok_user/1, blocking_item_to_map/1,
4 null_to_undefined/1, prepare_blocking_items/1,
5 page_size_or_max_limit/2]).
6
7 -spec page_size_or_max_limit(null | integer(), integer()) -> integer().
8 page_size_or_max_limit(null, MaxLimit) ->
9
:-(
MaxLimit;
10 page_size_or_max_limit(PageSize, MaxLimit) when PageSize > MaxLimit ->
11
:-(
MaxLimit;
12 page_size_or_max_limit(PageSize, _MaxLimit) ->
13
:-(
PageSize.
14
15 -spec make_room(mod_muc_light_api:room()) -> map().
16 make_room(#{jid := JID, name := Name, subject := Subject, aff_users := Users}) ->
17 9 Participants = lists:map(fun make_ok_user/1, Users),
18 9 #{<<"jid">> => JID, <<"name">> => Name, <<"subject">> => Subject,
19 <<"participants">> => Participants}.
20
21 make_ok_user({JID, Aff}) ->
22 12 {ok, #{<<"jid">> => JID, <<"affiliation">> => Aff}}.
23
24 prepare_blocking_items(Items) ->
25 5 [{What, Action, jid:to_lus(Who)} || #{<<"entity">> := Who, <<"entityType">> := What,
26 5 <<"action">> := Action} <- Items].
27
28 blocking_item_to_map({What, Action, Who}) ->
29 3 {ok, #{<<"entityType">> => What, <<"action">> => Action, <<"entity">> => Who}}.
30
31
:-(
null_to_undefined(null) -> undefined;
32
:-(
null_to_undefined(V) -> V.
Line Hits Source