diff --git a/mod_default_contacts/README.md b/mod_default_contacts/README.md index 11f57b4..e56084c 100644 --- a/mod_default_contacts/README.md +++ b/mod_default_contacts/README.md @@ -26,10 +26,10 @@ modules: contacts: - name: "Bob Virding" - jid: "bob@example.com" + jid: bob@example.com - name: "Alice Armstrong" - jid: "alice@example.com" + jid: alice@example.com ``` The configurable `mod_default_contacts` options are: diff --git a/mod_default_contacts/src/mod_default_contacts.erl b/mod_default_contacts/src/mod_default_contacts.erl index c78ead2..1f27b97 100644 --- a/mod_default_contacts/src/mod_default_contacts.erl +++ b/mod_default_contacts/src/mod_default_contacts.erl @@ -52,18 +52,19 @@ stop(Host) -> reload(_Host, _NewOpts, _OldOpts) -> ok. --spec mod_opt_type(atom()) -> fun((term()) -> term()). +-spec mod_opt_type(atom()) -> econf:validator(). mod_opt_type(contacts) -> - fun (L) -> - lists:map(fun (Opts) -> - JID1 = proplists:get_value(jid, Opts), - JID2 = iolist_to_binary(JID1), - JID3 = jid:decode(JID2), - Name1 = proplists:get_value(name, Opts, <<>>), - Name2 = iolist_to_binary(Name1), - #roster_item{jid = JID3, name = Name2} - end, L) - end. + econf:list( + econf:and_then( + econf:options( + #{jid => econf:jid(), + name => econf:binary()}, + [{required, [jid]}]), + fun(Opts) -> + Jid = proplists:get_value(jid, Opts), + Name = proplists:get_value(name, Opts, <<>>), + #roster_item{jid = Jid, name = Name} + end)). -spec mod_options(binary()) -> [{atom(), any()}]. mod_options(_Host) ->