diff options
author | Evgeny Khramtsov <ekhramtsov@process-one.net> | 2019-08-02 13:55:48 +0300 |
---|---|---|
committer | Evgeny Khramtsov <ekhramtsov@process-one.net> | 2019-08-02 13:59:42 +0300 |
commit | 5a976719fb821801fd162cde4516085416ef71e6 (patch) | |
tree | 9811d2e4b7da2e4396259a2e1ce7e1c839c5194a /src/mod_multicast.erl | |
parent | Bump pkix version (diff) |
Introduce 'vcard' option for the modules supporting vCards
The mapping between vCard's XML elements and YAML elements
of 'vcard' option is straightforward. For example, if you
want mod_muc to return the following vCard:
```
<vCard xmlns='vcard-temp'>
<FN>Conferences</FN>
<ADR>
<WORK/>
<STREET>Elm Street</STREET>
</ADR>
</vCard>
```
you need to set the configuration as:
```
modules:
...
mod_muc:
vcard:
fn: Conferences
adr:
-
work: true
street: Elm Street
...
```
Diffstat (limited to 'src/mod_multicast.erl')
-rw-r--r-- | src/mod_multicast.erl | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/mod_multicast.erl b/src/mod_multicast.erl index 28048476..8652188a 100644 --- a/src/mod_multicast.erl +++ b/src/mod_multicast.erl @@ -273,8 +273,8 @@ process_iq(#iq{type = get, lang = Lang, from = From, {result, iq_disco_info(From, Lang, State)}; process_iq(#iq{type = get, sub_els = [#disco_items{}]}, _) -> {result, #disco_items{}}; -process_iq(#iq{type = get, lang = Lang, sub_els = [#vcard_temp{}]}, _) -> - {result, iq_vcard(Lang)}; +process_iq(#iq{type = get, lang = Lang, sub_els = [#vcard_temp{}]}, State) -> + {result, iq_vcard(Lang, State)}; process_iq(#iq{type = T}, _) when T == set; T == get -> {error, xmpp:err_service_unavailable()}; process_iq(_, _) -> @@ -291,10 +291,16 @@ iq_disco_info(From, Lang, State) -> features = [?NS_DISCO_INFO, ?NS_DISCO_ITEMS, ?NS_VCARD, ?NS_ADDRESS], xdata = iq_disco_info_extras(From, State)}. -iq_vcard(Lang) -> - #vcard_temp{fn = <<"ejabberd/mod_multicast">>, - url = ejabberd_config:get_uri(), - desc = misc:get_descr(Lang, ?T("ejabberd Multicast service"))}. +-spec iq_vcard(binary(), state()) -> #vcard_temp{}. +iq_vcard(Lang, State) -> + case mod_multicast_opt:vcard(State#state.lserver) of + undefined -> + #vcard_temp{fn = <<"ejabberd/mod_multicast">>, + url = ejabberd_config:get_uri(), + desc = misc:get_descr(Lang, ?T("ejabberd Multicast service"))}; + VCard -> + VCard + end. %%%------------------------- %%% Route @@ -1142,11 +1148,14 @@ mod_opt_type(limits) -> mod_opt_type(host) -> econf:host(); mod_opt_type(hosts) -> - econf:hosts(). + econf:hosts(); +mod_opt_type(vcard) -> + econf:vcard_temp(). mod_options(Host) -> [{access, all}, {host, <<"multicast.", Host/binary>>}, {hosts, []}, {limits, [{local, []}, {remote, []}]}, + {vcard, undefined}, {name, ?T("Multicast")}]. |