1 |
|
-module(mongoose_graphql_stanza_admin_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(_Ctx, _Obj, <<"getLastMessages">>, Args) -> |
13 |
27 |
get_last_messages(Args). |
14 |
|
|
15 |
|
get_last_messages(#{<<"caller">> := Caller, <<"limit">> := Limit, |
16 |
|
<<"with">> := With, <<"before">> := Before}) |
17 |
|
when is_integer(Limit) -> |
18 |
27 |
Res = mongoose_graphql_stanza_helper:get_last_messages(Caller, Limit, With, Before, true), |
19 |
27 |
format_result(Res, #{user => jid:to_binary(Caller)}). |