2015-12-15 16:11:29 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
2016-04-20 11:27:32 +02:00
|
|
|
%%% File : pubsub_subscription_sql.erl
|
2015-12-15 16:11:29 +01:00
|
|
|
%%% Author : Pablo Polvorin <pablo.polvorin@process-one.net>
|
|
|
|
%%% Purpose : Handle pubsub subscriptions options with ODBC backend
|
|
|
|
%%% based on pubsub_subscription.erl by Brian Cully <bjc@kublai.com>
|
|
|
|
%%% Created : 7 Aug 2009 by Pablo Polvorin <pablo.polvorin@process-one.net>
|
2009-08-07 10:26:47 +02:00
|
|
|
%%%
|
|
|
|
%%%
|
2019-01-08 22:53:27 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2019 ProcessOne
|
2009-08-07 10:26:47 +02:00
|
|
|
%%%
|
2015-12-15 16:11:29 +01:00
|
|
|
%%% This program is free software; you can redistribute it and/or
|
|
|
|
%%% modify it under the terms of the GNU General Public License as
|
|
|
|
%%% published by the Free Software Foundation; either version 2 of the
|
|
|
|
%%% License, or (at your option) any later version.
|
|
|
|
%%%
|
|
|
|
%%% This program is distributed in the hope that it will be useful,
|
|
|
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
%%% General Public License for more details.
|
|
|
|
%%%
|
|
|
|
%%% You should have received a copy of the GNU General Public License along
|
|
|
|
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
%%%
|
|
|
|
%%%----------------------------------------------------------------------
|
2009-08-07 10:26:47 +02:00
|
|
|
|
2016-04-20 11:27:32 +02:00
|
|
|
-module(pubsub_subscription_sql).
|
2009-08-17 22:25:31 +02:00
|
|
|
-author("pablo.polvorin@process-one.net").
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
%% API
|
2016-11-15 18:35:20 +01:00
|
|
|
-export([init/3, subscribe_node/3, unsubscribe_node/3,
|
2015-04-08 17:12:05 +02:00
|
|
|
get_subscription/3, set_subscription/4,
|
2015-12-09 16:57:43 +01:00
|
|
|
make_subid/0,
|
2015-04-08 17:12:05 +02:00
|
|
|
get_options_xform/2, parse_options_xform/1]).
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
-include("pubsub.hrl").
|
2016-09-08 14:49:27 +02:00
|
|
|
-include("xmpp.hrl").
|
2019-06-22 16:08:45 +02:00
|
|
|
-include("translate.hrl").
|
2009-08-07 10:26:47 +02:00
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(PUBSUB_DELIVER, <<"pubsub#deliver">>).
|
|
|
|
-define(PUBSUB_DIGEST, <<"pubsub#digest">>).
|
2015-04-08 17:12:05 +02:00
|
|
|
-define(PUBSUB_DIGEST_FREQUENCY, <<"pubsub#digest_frequency">>).
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(PUBSUB_EXPIRE, <<"pubsub#expire">>).
|
|
|
|
-define(PUBSUB_INCLUDE_BODY, <<"pubsub#include_body">>).
|
|
|
|
-define(PUBSUB_SHOW_VALUES, <<"pubsub#show-values">>).
|
2015-04-08 17:12:05 +02:00
|
|
|
-define(PUBSUB_SUBSCRIPTION_TYPE, <<"pubsub#subscription_type">>).
|
|
|
|
-define(PUBSUB_SUBSCRIPTION_DEPTH, <<"pubsub#subscription_depth">>).
|
|
|
|
-define(DELIVER_LABEL, <<"Whether an entity wants to receive or disable notifications">>).
|
|
|
|
-define(DIGEST_LABEL, <<"Whether an entity wants to receive digests "
|
|
|
|
"(aggregations) of notifications or all notifications individually">>).
|
|
|
|
-define(DIGEST_FREQUENCY_LABEL, <<"The minimum number of milliseconds between "
|
|
|
|
"sending any two notification digests">>).
|
|
|
|
-define(EXPIRE_LABEL, <<"The DateTime at which a leased subscription will end or has ended">>).
|
|
|
|
-define(INCLUDE_BODY_LABEL, <<"Whether an entity wants to receive an "
|
|
|
|
"XMPP message body in addition to the payload format">>).
|
|
|
|
-define(SHOW_VALUES_LABEL, <<"The presence states for which an entity wants to receive notifications">>).
|
|
|
|
-define(SUBSCRIPTION_TYPE_LABEL, <<"Type of notification to receive">>).
|
|
|
|
-define(SUBSCRIPTION_DEPTH_LABEL, <<"Depth from subscription for which to receive notifications">>).
|
|
|
|
-define(SHOW_VALUE_AWAY_LABEL, <<"XMPP Show Value of Away">>).
|
|
|
|
-define(SHOW_VALUE_CHAT_LABEL, <<"XMPP Show Value of Chat">>).
|
|
|
|
-define(SHOW_VALUE_DND_LABEL, <<"XMPP Show Value of DND (Do Not Disturb)">>).
|
|
|
|
-define(SHOW_VALUE_ONLINE_LABEL, <<"Mere Availability in XMPP (No Show Value)">>).
|
|
|
|
-define(SHOW_VALUE_XA_LABEL, <<"XMPP Show Value of XA (Extended Away)">>).
|
|
|
|
-define(SUBSCRIPTION_TYPE_VALUE_ITEMS_LABEL, <<"Receive notification of new items only">>).
|
|
|
|
-define(SUBSCRIPTION_TYPE_VALUE_NODES_LABEL, <<"Receive notification of new nodes only">>).
|
|
|
|
-define(SUBSCRIPTION_DEPTH_VALUE_ONE_LABEL, <<"Receive notification from direct child nodes only">>).
|
|
|
|
-define(SUBSCRIPTION_DEPTH_VALUE_ALL_LABEL, <<"Receive notification from all descendent nodes">>).
|
2009-08-07 10:26:47 +02:00
|
|
|
|
2016-04-20 11:27:32 +02:00
|
|
|
-define(DB_MOD, pubsub_db_sql).
|
2009-08-07 10:26:47 +02:00
|
|
|
%%====================================================================
|
|
|
|
%% API
|
|
|
|
%%====================================================================
|
|
|
|
|
2016-11-15 18:35:20 +01:00
|
|
|
init(_Host, _ServerHost, _Opts) -> ok = create_table().
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2016-07-01 21:18:55 +02:00
|
|
|
-spec subscribe_node(_JID :: _, _NodeId :: _, Options :: [] | mod_pubsub:subOptions()) ->
|
|
|
|
{result, mod_pubsub:subId()}.
|
|
|
|
|
2015-04-08 17:12:05 +02:00
|
|
|
subscribe_node(_JID, _NodeId, Options) ->
|
2009-08-28 00:14:48 +02:00
|
|
|
SubID = make_subid(),
|
2015-04-08 17:12:05 +02:00
|
|
|
(?DB_MOD):add_subscription(#pubsub_subscription{subid = SubID, options = Options}),
|
2009-08-28 00:14:48 +02:00
|
|
|
{result, SubID}.
|
2009-08-17 22:25:31 +02:00
|
|
|
|
2016-07-01 21:18:55 +02:00
|
|
|
-spec unsubscribe_node(_JID :: _, _NodeId :: _, SubID :: mod_pubsub:subId()) ->
|
|
|
|
{result, mod_pubsub:subscription()} | {error, notfound}.
|
|
|
|
|
2015-04-08 17:12:05 +02:00
|
|
|
unsubscribe_node(_JID, _NodeId, SubID) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
case (?DB_MOD):read_subscription(SubID) of
|
2015-04-08 17:12:05 +02:00
|
|
|
{ok, Sub} -> (?DB_MOD):delete_subscription(SubID), {result, Sub};
|
|
|
|
notfound -> {error, notfound}
|
2009-08-27 23:38:23 +02:00
|
|
|
end.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
2016-07-01 21:18:55 +02:00
|
|
|
-spec get_subscription(_JID :: _, _NodeId :: _, SubId :: mod_pubsub:subId()) ->
|
|
|
|
{result, mod_pubsub:subscription()} | {error, notfound}.
|
|
|
|
|
2015-04-08 17:12:05 +02:00
|
|
|
get_subscription(_JID, _NodeId, SubID) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
case (?DB_MOD):read_subscription(SubID) of
|
2015-04-08 17:12:05 +02:00
|
|
|
{ok, Sub} -> {result, Sub};
|
|
|
|
notfound -> {error, notfound}
|
2009-08-07 10:26:47 +02:00
|
|
|
end.
|
2009-08-17 22:25:31 +02:00
|
|
|
|
2016-07-01 21:18:55 +02:00
|
|
|
-spec set_subscription(_JID :: _, _NodeId :: _, SubId :: mod_pubsub:subId(),
|
|
|
|
Options :: mod_pubsub:subOptions()) -> {result, ok}.
|
2015-04-08 17:12:05 +02:00
|
|
|
set_subscription(_JID, _NodeId, SubID, Options) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
case (?DB_MOD):read_subscription(SubID) of
|
2015-04-08 17:12:05 +02:00
|
|
|
{ok, _} ->
|
|
|
|
(?DB_MOD):update_subscription(#pubsub_subscription{subid = SubID,
|
|
|
|
options = Options}),
|
|
|
|
{result, ok};
|
|
|
|
notfound ->
|
|
|
|
(?DB_MOD):add_subscription(#pubsub_subscription{subid = SubID,
|
|
|
|
options = Options}),
|
|
|
|
{result, ok}
|
2009-08-07 10:26:47 +02:00
|
|
|
end.
|
2009-08-17 22:25:31 +02:00
|
|
|
|
2009-08-07 10:26:47 +02:00
|
|
|
get_options_xform(Lang, Options) ->
|
|
|
|
Keys = [deliver, show_values, subscription_type, subscription_depth],
|
2015-04-08 17:12:05 +02:00
|
|
|
XFields = [get_option_xfield(Lang, Key, Options) || Key <- Keys],
|
2013-03-14 10:33:02 +01:00
|
|
|
{result,
|
2016-09-08 14:49:27 +02:00
|
|
|
#xdata{type = form,
|
|
|
|
fields = [#xdata_field{type = hidden,
|
|
|
|
var = <<"FORM_TYPE">>,
|
|
|
|
values = [?NS_PUBSUB_SUB_OPTIONS]}|
|
|
|
|
XFields]}}.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
parse_options_xform(XFields) ->
|
2016-09-08 14:49:27 +02:00
|
|
|
Opts = set_xoption(XFields, []),
|
|
|
|
{result, Opts}.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
%%====================================================================
|
|
|
|
%% Internal functions
|
|
|
|
%%====================================================================
|
2013-03-14 10:33:02 +01:00
|
|
|
create_table() -> ok.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
2016-07-01 21:18:55 +02:00
|
|
|
-spec make_subid() -> mod_pubsub:subId().
|
2009-08-07 10:26:47 +02:00
|
|
|
make_subid() ->
|
2019-02-27 09:56:20 +01:00
|
|
|
{T1, T2, T3} = erlang:timestamp(),
|
2016-11-24 13:06:06 +01:00
|
|
|
(str:format("~.16B~.16B~.16B", [T1, T2, T3])).
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
%%
|
|
|
|
%% Subscription XForm processing.
|
|
|
|
%%
|
|
|
|
|
|
|
|
%% Return processed options, with types converted and so forth, using
|
|
|
|
%% Opts as defaults.
|
2013-03-14 10:33:02 +01:00
|
|
|
set_xoption([], Opts) -> Opts;
|
2009-08-07 10:26:47 +02:00
|
|
|
set_xoption([{Var, Value} | T], Opts) ->
|
|
|
|
NewOpts = case var_xfield(Var) of
|
2015-04-08 17:12:05 +02:00
|
|
|
{error, _} -> Opts;
|
|
|
|
Key ->
|
|
|
|
Val = val_xfield(Key, Value),
|
|
|
|
lists:keystore(Key, 1, Opts, {Key, Val})
|
|
|
|
end,
|
2009-08-07 10:26:47 +02:00
|
|
|
set_xoption(T, NewOpts).
|
|
|
|
|
|
|
|
%% Return the options list's key for an XForm var.
|
|
|
|
%% Convert Values for option list's Key.
|
2013-03-14 10:33:02 +01:00
|
|
|
var_xfield(?PUBSUB_DELIVER) -> deliver;
|
2015-04-08 17:12:05 +02:00
|
|
|
var_xfield(?PUBSUB_DIGEST) -> digest;
|
|
|
|
var_xfield(?PUBSUB_DIGEST_FREQUENCY) -> digest_frequency;
|
|
|
|
var_xfield(?PUBSUB_EXPIRE) -> expire;
|
|
|
|
var_xfield(?PUBSUB_INCLUDE_BODY) -> include_body;
|
2013-03-14 10:33:02 +01:00
|
|
|
var_xfield(?PUBSUB_SHOW_VALUES) -> show_values;
|
2015-04-08 17:12:05 +02:00
|
|
|
var_xfield(?PUBSUB_SUBSCRIPTION_TYPE) -> subscription_type;
|
|
|
|
var_xfield(?PUBSUB_SUBSCRIPTION_DEPTH) -> subscription_depth;
|
2013-03-14 10:33:02 +01:00
|
|
|
var_xfield(_) -> {error, badarg}.
|
|
|
|
|
2016-03-31 10:00:29 +02:00
|
|
|
val_xfield(deliver = Opt, [Val]) -> xopt_to_bool(Opt, Val);
|
|
|
|
val_xfield(digest = Opt, [Val]) -> xopt_to_bool(Opt, Val);
|
|
|
|
val_xfield(digest_frequency = Opt, [Val]) ->
|
2016-09-24 22:34:28 +02:00
|
|
|
case catch binary_to_integer(Val) of
|
2015-04-08 17:12:05 +02:00
|
|
|
N when is_integer(N) -> N;
|
2016-03-31 10:00:29 +02:00
|
|
|
_ ->
|
2019-06-22 16:08:45 +02:00
|
|
|
Txt = {?T("Value of '~s' should be integer"), [Opt]},
|
2019-06-14 11:33:26 +02:00
|
|
|
{error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())}
|
2016-09-08 14:49:27 +02:00
|
|
|
end;
|
|
|
|
val_xfield(expire = Opt, [Val]) ->
|
2016-11-13 08:44:53 +01:00
|
|
|
try xmpp_util:decode_timestamp(Val)
|
|
|
|
catch _:{bad_timestamp, _} ->
|
2019-06-22 16:08:45 +02:00
|
|
|
Txt = {?T("Value of '~s' should be datetime string"), [Opt]},
|
2019-06-14 11:33:26 +02:00
|
|
|
{error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())}
|
2015-04-08 17:12:05 +02:00
|
|
|
end;
|
2016-03-31 10:00:29 +02:00
|
|
|
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
|
2013-03-14 10:33:02 +01:00
|
|
|
val_xfield(show_values, Vals) -> Vals;
|
|
|
|
val_xfield(subscription_type, [<<"items">>]) -> items;
|
|
|
|
val_xfield(subscription_type, [<<"nodes">>]) -> nodes;
|
|
|
|
val_xfield(subscription_depth, [<<"all">>]) -> all;
|
2016-03-31 10:00:29 +02:00
|
|
|
val_xfield(subscription_depth = Opt, [Depth]) ->
|
2016-09-24 22:34:28 +02:00
|
|
|
case catch binary_to_integer(Depth) of
|
2015-04-08 17:12:05 +02:00
|
|
|
N when is_integer(N) -> N;
|
2016-03-31 10:00:29 +02:00
|
|
|
_ ->
|
2019-06-22 16:08:45 +02:00
|
|
|
Txt = {?T("Value of '~s' should be integer"), [Opt]},
|
2019-06-14 11:33:26 +02:00
|
|
|
{error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())}
|
2009-08-07 10:26:47 +02:00
|
|
|
end.
|
|
|
|
|
|
|
|
%% Convert XForm booleans to Erlang booleans.
|
2016-03-31 10:00:29 +02:00
|
|
|
xopt_to_bool(_, <<"0">>) -> false;
|
|
|
|
xopt_to_bool(_, <<"1">>) -> true;
|
|
|
|
xopt_to_bool(_, <<"false">>) -> false;
|
|
|
|
xopt_to_bool(_, <<"true">>) -> true;
|
|
|
|
xopt_to_bool(Option, _) ->
|
2019-06-22 16:08:45 +02:00
|
|
|
Txt = {?T("Value of '~s' should be boolean"), [Option]},
|
2019-06-14 11:33:26 +02:00
|
|
|
{error, xmpp:err_not_acceptable(Txt, ejabberd_option:language())}.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
%% Return a field for an XForm for Key, with data filled in, if
|
|
|
|
%% applicable, from Options.
|
|
|
|
get_option_xfield(Lang, Key, Options) ->
|
|
|
|
Var = xfield_var(Key),
|
|
|
|
Label = xfield_label(Key),
|
2015-04-08 17:12:05 +02:00
|
|
|
{Type, OptEls} = type_and_options(xfield_type(Key), Lang),
|
2009-08-07 10:26:47 +02:00
|
|
|
Vals = case lists:keysearch(Key, 1, Options) of
|
2016-09-08 14:49:27 +02:00
|
|
|
{value, {_, Val}} ->
|
|
|
|
[xfield_val(Key, Val)];
|
|
|
|
false ->
|
|
|
|
[]
|
|
|
|
end,
|
|
|
|
#xdata_field{type = Type, var = Var,
|
|
|
|
label = translate:translate(Lang, Label),
|
|
|
|
values = Vals,
|
|
|
|
options = OptEls}.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
type_and_options({Type, Options}, Lang) ->
|
|
|
|
{Type, [tr_xfield_options(O, Lang) || O <- Options]};
|
2013-03-14 10:33:02 +01:00
|
|
|
type_and_options(Type, _Lang) -> {Type, []}.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
tr_xfield_options({Value, Label}, Lang) ->
|
2016-09-08 14:49:27 +02:00
|
|
|
#xdata_option{label = translate:translate(Lang, Label),
|
|
|
|
value = Value}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
xfield_var(deliver) -> ?PUBSUB_DELIVER;
|
|
|
|
%xfield_var(digest) -> ?PUBSUB_DIGEST;
|
2015-04-08 17:12:05 +02:00
|
|
|
%xfield_var(digest_frequency) -> ?PUBSUB_DIGEST_FREQUENCY;
|
2013-03-14 10:33:02 +01:00
|
|
|
%xfield_var(expire) -> ?PUBSUB_EXPIRE;
|
|
|
|
%xfield_var(include_body) -> ?PUBSUB_INCLUDE_BODY;
|
|
|
|
xfield_var(show_values) -> ?PUBSUB_SHOW_VALUES;
|
2015-04-08 17:12:05 +02:00
|
|
|
xfield_var(subscription_type) -> ?PUBSUB_SUBSCRIPTION_TYPE;
|
|
|
|
xfield_var(subscription_depth) -> ?PUBSUB_SUBSCRIPTION_DEPTH.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2016-09-08 14:49:27 +02:00
|
|
|
xfield_type(deliver) -> boolean;
|
|
|
|
%xfield_type(digest) -> boolean;
|
|
|
|
%xfield_type(digest_frequency) -> 'text-single';
|
|
|
|
%xfield_type(expire) -> 'text-single';
|
|
|
|
%xfield_type(include_body) -> boolean;
|
2013-03-14 10:33:02 +01:00
|
|
|
xfield_type(show_values) ->
|
2016-09-08 14:49:27 +02:00
|
|
|
{'list-multi',
|
|
|
|
[{<<"away">>, ?SHOW_VALUE_AWAY_LABEL},
|
|
|
|
{<<"chat">>, ?SHOW_VALUE_CHAT_LABEL},
|
|
|
|
{<<"dnd">>, ?SHOW_VALUE_DND_LABEL},
|
|
|
|
{<<"online">>, ?SHOW_VALUE_ONLINE_LABEL},
|
|
|
|
{<<"xa">>, ?SHOW_VALUE_XA_LABEL}]};
|
2013-03-14 10:33:02 +01:00
|
|
|
xfield_type(subscription_type) ->
|
2016-09-08 14:49:27 +02:00
|
|
|
{'list-single',
|
|
|
|
[{<<"items">>, ?SUBSCRIPTION_TYPE_VALUE_ITEMS_LABEL},
|
|
|
|
{<<"nodes">>, ?SUBSCRIPTION_TYPE_VALUE_NODES_LABEL}]};
|
2009-08-07 10:26:47 +02:00
|
|
|
xfield_type(subscription_depth) ->
|
2016-09-08 14:49:27 +02:00
|
|
|
{'list-single',
|
|
|
|
[{<<"1">>, ?SUBSCRIPTION_DEPTH_VALUE_ONE_LABEL},
|
|
|
|
{<<"all">>, ?SUBSCRIPTION_DEPTH_VALUE_ALL_LABEL}]}.
|
2009-08-07 10:26:47 +02:00
|
|
|
|
|
|
|
%% Return the XForm variable label for a subscription option key.
|
|
|
|
xfield_label(deliver) -> ?DELIVER_LABEL;
|
2013-03-14 10:33:02 +01:00
|
|
|
%xfield_label(digest) -> ?DIGEST_LABEL;
|
2015-04-08 17:12:05 +02:00
|
|
|
%xfield_label(digest_frequency) -> ?DIGEST_FREQUENCY_LABEL;
|
2013-03-14 10:33:02 +01:00
|
|
|
%xfield_label(expire) -> ?EXPIRE_LABEL;
|
|
|
|
%xfield_label(include_body) -> ?INCLUDE_BODY_LABEL;
|
2009-08-07 10:26:47 +02:00
|
|
|
xfield_label(show_values) -> ?SHOW_VALUES_LABEL;
|
|
|
|
%% Return the XForm value for a subscription option key.
|
|
|
|
%% Convert erlang booleans to XForms.
|
2015-04-08 17:12:05 +02:00
|
|
|
xfield_label(subscription_type) -> ?SUBSCRIPTION_TYPE_LABEL;
|
|
|
|
xfield_label(subscription_depth) -> ?SUBSCRIPTION_DEPTH_LABEL.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
|
|
|
|
%xfield_val(digest, Val) -> [bool_to_xopt(Val)];
|
|
|
|
%xfield_val(digest_frequency, Val) ->
|
2016-11-24 13:06:06 +01:00
|
|
|
% [integer_to_binary(Val))];
|
2013-03-14 10:33:02 +01:00
|
|
|
%xfield_val(expire, Val) ->
|
|
|
|
% [jlib:now_to_utc_string(Val)];
|
|
|
|
%xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
|
|
|
|
xfield_val(show_values, Val) -> Val;
|
|
|
|
xfield_val(subscription_type, items) -> [<<"items">>];
|
|
|
|
xfield_val(subscription_type, nodes) -> [<<"nodes">>];
|
|
|
|
xfield_val(subscription_depth, all) -> [<<"all">>];
|
|
|
|
xfield_val(subscription_depth, N) ->
|
2016-11-24 13:06:06 +01:00
|
|
|
[integer_to_binary(N)].
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
bool_to_xopt(false) -> <<"false">>;
|
|
|
|
bool_to_xopt(true) -> <<"true">>.
|