From 9d943614668b0e88e4b28958cef165bdee165e9a Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Mon, 8 Jan 2018 11:29:17 +0300 Subject: Process 'name' option for all route-registering modules The option allows to set arbitrary text for disco#info identity name. Previously, option 'name' was supported by mod_proxy65 and mod_http_upload only. Now, all the following modules support this option as well: - mod_disco - mod_irc - mod_muc - mod_multicast - mod_pubsub - mod_vcard Example: ``` modules: ... mod_disco: name: "Cool XMPP Server" ... ``` --- src/mod_pubsub.erl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/mod_pubsub.erl') diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index 0c39bbbe..47ee8fa3 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -44,6 +44,7 @@ -include("xmpp.hrl"). -include("pubsub.hrl"). -include("mod_roster.hrl"). +-include("translate.hrl"). -define(STDTREE, <<"tree">>). -define(STDNODE, <<"flat">>). @@ -829,7 +830,7 @@ process_disco_info(#iq{from = From, to = To, lang = Lang, type = get, Info = ejabberd_hooks:run_fold(disco_info, ServerHost, [], [ServerHost, ?MODULE, <<>>, <<>>]), - case iq_disco_info(Host, Node, From, Lang) of + case iq_disco_info(ServerHost, Host, Node, From, Lang) of {result, IQRes} -> XData = IQRes#disco_info.xdata ++ Info, xmpp:make_iq_result(IQ, IQRes#disco_info{node = Node, xdata = XData}); @@ -970,22 +971,23 @@ node_disco_info(Host, Node, _From, _Identity, _Features) -> Other -> Other end. --spec iq_disco_info(binary(), binary(), jid(), binary()) +-spec iq_disco_info(binary(), binary(), binary(), jid(), binary()) -> {result, disco_info()} | {error, stanza_error()}. -iq_disco_info(Host, SNode, From, Lang) -> +iq_disco_info(ServerHost, Host, SNode, From, Lang) -> [Node | _] = case SNode of <<>> -> [<<>>]; _ -> str:tokens(SNode, <<"!">>) end, case Node of <<>> -> + Name = gen_mod:get_module_opt(ServerHost, ?MODULE, name, + ?T("Publish-Subscribe")), {result, #disco_info{ identities = [#identity{ category = <<"pubsub">>, type = <<"service">>, - name = translate:translate( - Lang, <<"Publish-Subscribe">>)}], + name = translate:translate(Lang, Name)}], features = [?NS_DISCO_INFO, ?NS_DISCO_ITEMS, ?NS_PUBSUB, @@ -3853,6 +3855,7 @@ purge_offline(Host, LJID, Node) -> mod_opt_type(access_createnode) -> fun acl:access_rules_validator/1; mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end; +mod_opt_type(name) -> fun iolist_to_binary/1; mod_opt_type(host) -> fun iolist_to_binary/1; mod_opt_type(hosts) -> fun (L) -> lists:map(fun iolist_to_binary/1, L) end; @@ -3874,7 +3877,7 @@ mod_opt_type(pep_mapping) -> mod_opt_type(plugins) -> fun (A) when is_list(A) -> A end; mod_opt_type(_) -> - [access_createnode, db_type, host, hosts, + [access_createnode, db_type, host, hosts, name, ignore_pep_from_offline, iqdisc, last_item_cache, max_items_node, nodetree, pep_mapping, plugins, max_subscriptions_node, default_node_config]. -- cgit v1.2.3