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