1 |
|
-module(mongoose_graphql_private_admin_query). |
2 |
|
-behaviour(mongoose_graphql). |
3 |
|
|
4 |
|
-export([execute/4]). |
5 |
|
|
6 |
|
-ignore_xref([execute/4]). |
7 |
|
|
8 |
|
-include("../mongoose_graphql_types.hrl"). |
9 |
|
|
10 |
|
-import(mongoose_graphql_helper, [make_error/2, format_result/2]). |
11 |
|
|
12 |
|
execute(_Ctx, _Obj, <<"getPrivate">>, #{<<"user">> := CallerJID, |
13 |
|
<<"element">> := Element, <<"nameSpace">> := SubElement}) -> |
14 |
8 |
case mod_private_api:private_get(CallerJID, Element, SubElement) of |
15 |
6 |
{ok, _} = Result -> Result; |
16 |
|
Error -> |
17 |
2 |
make_error(Error, #{user => jid:to_binary(CallerJID), element => Element, |
18 |
|
subElement => SubElement}) |
19 |
|
end. |