./ct_report/coverage/mongoose_graphql_stanza_user_subscription.COVER.html

1 -module(mongoose_graphql_stanza_user_subscription).
2 -behaviour(mongoose_graphql).
3
4 -import(mongoose_graphql_helper, [format_result/2]).
5
6 -export([execute/4]).
7
8 -ignore_xref([execute/4]).
9
10 -include("../mongoose_graphql_types.hrl").
11
12 execute(Ctx, _Obj, <<"subscribeForMessages">>, #{}) ->
13 3 subscribe_for_messages(Ctx).
14
15 subscribe_for_messages(#{event := terminate, stream := Session}) ->
16 1 mongoose_stanza_api:close_session(Session),
17 1 {ok, null, [{stream, closed}]};
18 subscribe_for_messages(#{event := Event}) ->
19 1 mongoose_graphql_stanza_helper:handle_event(Event);
20 subscribe_for_messages(#{user := Jid}) ->
21 1 {ok, Stream} = mongoose_stanza_api:open_session(Jid, false),
22 1 {ok, null, [{stream, Stream}]}.
Line Hits Source