1 |
|
-module(mongoose_graphql_offline_admin_mutation). |
2 |
|
-behaviour(mongoose_graphql). |
3 |
|
|
4 |
|
-export([execute/4]). |
5 |
|
|
6 |
|
-import(mongoose_graphql_helper, [make_error/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(_Ctx, offline, <<"deleteExpiredMessages">>, #{<<"domain">> := Domain} = Input) -> |
15 |
8 |
case mod_offline_api:delete_expired_messages(Domain) of |
16 |
6 |
{ok, _} = Result -> Result; |
17 |
2 |
Error -> make_error(Error, Input) |
18 |
|
end; |
19 |
|
|
20 |
|
execute(_Ctx, offline, <<"deleteOldMessages">>, #{<<"domain">> := Domain, <<"days">> := Days} = Input) -> |
21 |
8 |
case mod_offline_api:delete_old_messages(Domain, Days) of |
22 |
6 |
{ok, _} = Result -> Result; |
23 |
2 |
Error -> make_error(Error, Input) |
24 |
|
end. |