1 |
|
-module(mongoose_graphql_vcard_admin_mutation). |
2 |
|
-behaviour(mongoose_graphql). |
3 |
|
|
4 |
|
-include("mod_vcard.hrl"). |
5 |
|
|
6 |
|
-export([execute/4]). |
7 |
|
|
8 |
|
-import(mongoose_graphql_helper, [make_error/2]). |
9 |
|
|
10 |
|
-ignore_xref([execute/4]). |
11 |
|
|
12 |
|
-include("../mongoose_graphql_types.hrl"). |
13 |
|
-include("mongoose.hrl"). |
14 |
|
-include("jlib.hrl"). |
15 |
|
|
16 |
|
execute(_Ctx, vcard, <<"setVcard">>, #{<<"user">> := CallerJID, <<"vcard">> := VcardInput}) -> |
17 |
8 |
case mod_vcard_api:set_vcard(CallerJID, VcardInput) of |
18 |
4 |
{ok, _} = Vcard -> Vcard; |
19 |
4 |
Error -> make_error(Error, #{user => jid:to_binary(CallerJID)}) |
20 |
|
end. |