1 |
|
-module(mongoose_graphql_private_admin_mutation). |
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, <<"setPrivate">>, #{<<"user">> := CallerJID, |
13 |
|
<<"elementString">> := Element}) -> |
14 |
:-( |
case mod_private_api:private_set(CallerJID, Element) of |
15 |
:-( |
{ok, _} = Result -> Result; |
16 |
:-( |
Error -> make_error(Error, #{user => jid:to_binary(CallerJID), |
17 |
|
element => exml:to_binary(Element)}) |
18 |
|
end. |