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 |
:-( |
UserJID2 = null_to_default(UserJID, CallerJID), |
16 |
:-( |
case mod_vcard_api:get_vcard(UserJID2) of |
17 |
:-( |
{ok, _} = Vcard -> Vcard; |
18 |
:-( |
Error -> make_error(Error, #{<<"user">> => jid:to_binary(UserJID2)}) |
19 |
|
end. |