Update mod_default_contacts option parsing to use econf
This commit is contained in:
parent
2bf5a362ce
commit
f3e03b9729
|
@ -26,10 +26,10 @@ modules:
|
||||||
contacts:
|
contacts:
|
||||||
-
|
-
|
||||||
name: "Bob Virding"
|
name: "Bob Virding"
|
||||||
jid: "bob@example.com"
|
jid: bob@example.com
|
||||||
-
|
-
|
||||||
name: "Alice Armstrong"
|
name: "Alice Armstrong"
|
||||||
jid: "alice@example.com"
|
jid: alice@example.com
|
||||||
```
|
```
|
||||||
|
|
||||||
The configurable `mod_default_contacts` options are:
|
The configurable `mod_default_contacts` options are:
|
||||||
|
|
|
@ -52,18 +52,19 @@ stop(Host) ->
|
||||||
reload(_Host, _NewOpts, _OldOpts) ->
|
reload(_Host, _NewOpts, _OldOpts) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec mod_opt_type(atom()) -> fun((term()) -> term()).
|
-spec mod_opt_type(atom()) -> econf:validator().
|
||||||
mod_opt_type(contacts) ->
|
mod_opt_type(contacts) ->
|
||||||
fun (L) ->
|
econf:list(
|
||||||
lists:map(fun (Opts) ->
|
econf:and_then(
|
||||||
JID1 = proplists:get_value(jid, Opts),
|
econf:options(
|
||||||
JID2 = iolist_to_binary(JID1),
|
#{jid => econf:jid(),
|
||||||
JID3 = jid:decode(JID2),
|
name => econf:binary()},
|
||||||
Name1 = proplists:get_value(name, Opts, <<>>),
|
[{required, [jid]}]),
|
||||||
Name2 = iolist_to_binary(Name1),
|
fun(Opts) ->
|
||||||
#roster_item{jid = JID3, name = Name2}
|
Jid = proplists:get_value(jid, Opts),
|
||||||
end, L)
|
Name = proplists:get_value(name, Opts, <<>>),
|
||||||
end.
|
#roster_item{jid = Jid, name = Name}
|
||||||
|
end)).
|
||||||
|
|
||||||
-spec mod_options(binary()) -> [{atom(), any()}].
|
-spec mod_options(binary()) -> [{atom(), any()}].
|
||||||
mod_options(_Host) ->
|
mod_options(_Host) ->
|
||||||
|
|
Loading…
Reference in New Issue