1 |
|
-module(mongoose_graphql_stanza_user_query). |
2 |
|
-behaviour(mongoose_graphql). |
3 |
|
|
4 |
|
-import(mongoose_graphql_helper, [format_result/2]). |
5 |
|
|
6 |
|
-export([execute/4]). |
7 |
|
|
8 |
|
-ignore_xref([execute/4]). |
9 |
|
|
10 |
|
-include("../mongoose_graphql_types.hrl"). |
11 |
|
|
12 |
|
execute(#{user := User}, _Obj, <<"getLastMessages">>, Args) -> |
13 |
2 |
get_last_messages(Args, User). |
14 |
|
|
15 |
|
get_last_messages(#{<<"limit">> := Limit, |
16 |
|
<<"with">> := With, <<"before">> := Before}, Caller) |
17 |
|
when is_integer(Limit) -> |
18 |
2 |
Res = mongoose_graphql_stanza_helper:get_last_messages(Caller, Limit, With, Before, false), |
19 |
2 |
format_result(Res, #{user => jid:to_binary(Caller)}). |