Skip to content

Commit

Permalink
Merge pull request #257 from esl/default-node-config
Browse files Browse the repository at this point in the history
Allow to get default pubsub node config
  • Loading branch information
NelsonVides authored Jun 14, 2023
2 parents 1868bd3 + f9414bb commit e780ac7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/escalus_pubsub_stanza.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@

-module(escalus_pubsub_stanza).

-include("escalus.hrl").
-include("escalus_xmlns.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("exml/include/exml.hrl").
-include_lib("exml/include/exml_stream.hrl").

-export([
discover_nodes/3,

create_node/3, create_node/4, delete_node/3,

get_configuration/3, set_configuration/4,
get_default_configuration/3,

get_affiliations/3, set_affiliations/4,

Expand Down Expand Up @@ -99,6 +97,12 @@ set_configuration(User, Id, {NodeAddr, NodeName}, ConfigFields) ->
Elements = configure_node_form(ConfigFields, NodeName),
pubsub_owner_iq(<<"set">>, User, Id, NodeAddr, Elements).

-spec get_default_configuration(escalus_utils:jid_spec(), binary(),
escalus_utils:jid_spec()) -> exml:element().
get_default_configuration(User, Id, NodeAddr) ->
Elements = [default_element()],
pubsub_owner_iq(<<"get">>, User, Id, NodeAddr, Elements).

%% ---------------- affiliations ----------------

-spec get_affiliations(escalus_utils:jid_spec(), binary(), pubsub_node_id()) -> exml:element().
Expand Down Expand Up @@ -413,6 +417,9 @@ set_subscription_options_form(NodeName, User, Children) ->
{<<"type">>, <<"submit">>}],
children = Children}]}.

default_element() ->
#xmlel{name = <<"default">>}.

form_element(FormName, NodeName, FieldElements) ->
#xmlel{name = FormName,
attrs = skip_undefined([{<<"node">>, NodeName}]),
Expand Down

0 comments on commit e780ac7

Please sign in to comment.