25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

* src/mod_register.erl: update ejabberd commands to support XEP-0133 (initial patch by Badlop) (EJAB-325).

* src/mod_configure.erl: Likewise.
* src/mod_announce.erl: Likewise.
* src/jlib.hrl: Likewise.
* src/ejabberd.cfg.example: Likewise.
* doc/guide.tex: Likewise.

SVN Revision: 918
This commit is contained in:
Mickaël Rémond 2007-09-04 07:55:41 +00:00
parent f803d88de0
commit dcc05ac8d0
7 changed files with 899 additions and 421 deletions

View File

@ -2034,6 +2034,11 @@ Register a new account on the server.
rules to restrict registration. If a rule returns `deny' on the requested rules to restrict registration. If a rule returns `deny' on the requested
user name, registration for that user name is dennied. (there are no user name, registration for that user name is dennied. (there are no
restrictions by default). restrictions by default).
</DD><DT CLASS="dt-description"><B><TT>welcome_message</TT></B></DT><DD CLASS="dd-description"> Set a welcome message that
is sent to each newly registered account. The first string is the subject, and
the second string is the message body.
</DD><DT CLASS="dt-description"><B><TT>registration_watchers</TT></B></DT><DD CLASS="dd-description"> This option defines a
list of JIDs which will be notified each time a new account is registered.
</DD><DT CLASS="dt-description"><B><TT>iqdisc</TT></B></DT><DD CLASS="dd-description"> This specifies </DD><DT CLASS="dt-description"><B><TT>iqdisc</TT></B></DT><DD CLASS="dd-description"> This specifies
the processing discipline for In-Band Registration (<TT>jabber:iq:register</TT>) IQ queries (see section&#XA0;<A HREF="#modiqdiscoption">3.3.2</A>). the processing discipline for In-Band Registration (<TT>jabber:iq:register</TT>) IQ queries (see section&#XA0;<A HREF="#modiqdiscoption">3.3.2</A>).
</DD></DL><P>Examples: </DD></DL><P>Examples:
@ -2066,6 +2071,16 @@ example all In-Band Registration functionality is disabled:
% {mod_register, [{access, register}]}, % {mod_register, [{access, register}]},
... ...
]}. ]}.
</PRE></LI><LI CLASS="li-itemize">Define the welcome message and three registration watchers:
<PRE CLASS="verbatim"> {modules,
[
...
{mod_register, [
{welcome_message, {"Welcome!", "Welcome to this Jabber server. For information about Jabber visit http://www.jabber.org"}},
{registration_watchers, ["admin1@example.org", "admin2@example.org", "boss@example.net"]}
]},
...
]}.
</PRE></LI></UL><!--TOC subsection <TT>mod_roster</TT>--> </PRE></LI></UL><!--TOC subsection <TT>mod_roster</TT>-->
<H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc45">3.3.16</A>&#XA0;&#XA0;<TT>mod_roster</TT></H3><!--SEC END --><P> <H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc45">3.3.16</A>&#XA0;&#XA0;<TT>mod_roster</TT></H3><!--SEC END --><P>
<A NAME="modroster"></A> <A NAME="modroster"></A>

View File

@ -2490,6 +2490,11 @@ Options:
rules to restrict registration. If a rule returns `deny' on the requested rules to restrict registration. If a rule returns `deny' on the requested
user name, registration for that user name is dennied. (there are no user name, registration for that user name is dennied. (there are no
restrictions by default). restrictions by default).
\titem{welcome\_message} \ind{options!welcomem}Set a welcome message that
is sent to each newly registered account. The first string is the subject, and
the second string is the message body.
\titem{registration\_watchers} \ind{options!rwatchers}This option defines a
list of JIDs which will be notified each time a new account is registered.
\iqdiscitem{In-Band Registration (\ns{jabber:iq:register})} \iqdiscitem{In-Band Registration (\ns{jabber:iq:register})}
\end{description} \end{description}
@ -2527,6 +2532,18 @@ Examples:
... ...
]}. ]}.
\end{verbatim} \end{verbatim}
\item Define the welcome message and three registration watchers:
\begin{verbatim}
{modules,
[
...
{mod_register, [
{welcome_message, {"Welcome!", "Welcome to this Jabber server. For information about Jabber visit http://www.jabber.org"}},
{registration_watchers, ["admin1@example.org", "admin2@example.org", "boss@example.net"]}
]},
...
]}.
\end{verbatim}
\end{itemize} \end{itemize}
\subsection{\modroster{}} \subsection{\modroster{}}

View File

@ -32,19 +32,6 @@
% in-band registration % in-band registration
{access, register, [{allow, all}]}. {access, register, [{allow, all}]}.
% After successful registration user will get message with following subject
% and body:
{welcome_message,
{"Welcome!",
"Welcome to Jabber Service. "
"For information about Jabber visit http://jabber.org"}}.
% Replace them with 'none' if you don't want to send such message:
%{welcome_message, none}.
% List of people who will get notifications about registered users
%{registration_watchers, ["admin1@localhost",
% "admin2@localhost"]}.
% Debug: % Debug:
% watchdog admins receive live notifications on ejabberd process consuming too % watchdog admins receive live notifications on ejabberd process consuming too
% much memory % much memory
@ -164,7 +151,13 @@
% Used modules: % Used modules:
{modules, {modules,
[ [
{mod_register, [{access, register}]}, {mod_register, [
%% After successful registration user will get message with following subject and body:
%{welcome_message, {"Welcome!", "Welcome to this Jabber server."}},
%% List of people who will get notifications when users register
%{registration_watchers, ["admin1@example.org", "admin2@example.org"]},
{access, register}
]},
{mod_roster, []}, {mod_roster, []},
{mod_privacy, []}, {mod_privacy, []},
{mod_adhoc, []}, {mod_adhoc, []},

View File

@ -35,6 +35,7 @@
-define(NS_PUBSUB_NMI, "http://jabber.org/protocol/pubsub#node-meta-info"). -define(NS_PUBSUB_NMI, "http://jabber.org/protocol/pubsub#node-meta-info").
-define(NS_COMMANDS, "http://jabber.org/protocol/commands"). -define(NS_COMMANDS, "http://jabber.org/protocol/commands").
-define(NS_BYTESTREAMS, "http://jabber.org/protocol/bytestreams"). -define(NS_BYTESTREAMS, "http://jabber.org/protocol/bytestreams").
-define(NS_ADMIN, "http://jabber.org/protocol/admin").
-define(NS_EJABBERD_CONFIG, "ejabberd:config"). -define(NS_EJABBERD_CONFIG, "ejabberd:config").

View File

@ -6,6 +6,8 @@
%%% Id : $Id$ %%% Id : $Id$
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Implements a small subset of XEP-0133: Service Administration Version 1.1 (2005-08-19)
-module(mod_announce). -module(mod_announce).
-author('alexey@sevcom.net'). -author('alexey@sevcom.net').
@ -31,6 +33,9 @@
-define(PROCNAME, ejabberd_announce). -define(PROCNAME, ejabberd_announce).
-define(NS_ADMINL(Sub), ["http:","jabber.org","protocol","admin", Sub]).
tokenize(Node) -> string:tokens(Node, "/#").
start(Host, _Opts) -> start(Host, _Opts) ->
mnesia:create_table(motd, [{disc_copies, [node()]}, mnesia:create_table(motd, [{disc_copies, [node()]},
{attributes, record_info(fields, motd)}]), {attributes, record_info(fields, motd)}]),
@ -102,7 +107,7 @@ stop(Host) ->
exit(whereis(Proc), stop), exit(whereis(Proc), stop),
{wait, Proc}. {wait, Proc}.
% Announcing via messages to a custom resource %% Announcing via messages to a custom resource
announce(From, To, Packet) -> announce(From, To, Packet) ->
case To of case To of
#jid{luser = "", lresource = Res} -> #jid{luser = "", lresource = Res} ->
@ -146,8 +151,8 @@ announce(From, To, Packet) ->
ok ok
end. end.
%------------------------------------------------------------------------- %%-------------------------------------------------------------------------
% Announcing via ad-hoc commands %% Announcing via ad-hoc commands
-define(INFO_COMMAND(Lang, Node), -define(INFO_COMMAND(Lang, Node),
[{xmlelement, "identity", [{xmlelement, "identity",
[{"category", "automation"}, [{"category", "automation"},
@ -155,32 +160,33 @@ announce(From, To, Packet) ->
{"name", get_title(Lang, Node)}], []}]). {"name", get_title(Lang, Node)}], []}]).
disco_identity(Acc, _From, _To, Node, Lang) -> disco_identity(Acc, _From, _To, Node, Lang) ->
case Node of LNode = tokenize(Node),
"announce/all" -> case LNode of
?NS_ADMINL("announce-all") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/all-hosts/all" -> ?NS_ADMINL("announce-all-allhosts") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/online" -> ?NS_ADMINL("announce") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/all-hosts/online" -> ?NS_ADMINL("announce-online-allhosts") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/motd" -> ?NS_ADMINL("set-motd") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/all-hosts/motd" -> ?NS_ADMINL("motd-allhosts") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/motd/delete" -> ?NS_ADMINL("delete-motd") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/all-hosts/motd/delete" -> ?NS_ADMINL("delete-motd-allhosts") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/motd/update" -> ?NS_ADMINL("edit-motd") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
"announce/all-hosts/motd/update" -> ?NS_ADMINL("edit-motd-allhosts") ->
?INFO_COMMAND(Lang, Node); ?INFO_COMMAND(Lang, Node);
_ -> _ ->
Acc Acc
end. end.
%------------------------------------------------------------------------- %%-------------------------------------------------------------------------
-define(INFO_RESULT(Allow, Feats), -define(INFO_RESULT(Allow, Feats),
case Allow of case Allow of
@ -209,11 +215,11 @@ disco_features(Acc, From, #jid{lserver = LServer} = _To,
disco_features(Acc, From, #jid{lserver = LServer} = _To, disco_features(Acc, From, #jid{lserver = LServer} = _To,
Node, _Lang) Node, _Lang)
when (Node == "announce/all-hosts/online") when (Node == [?NS_ADMIN | "#announce-online-allhosts"])
or (Node == "announce/all-hosts/all") or (Node == [?NS_ADMIN | "#announce-all-allhosts"])
or (Node == "announce/all-hosts/motd") or (Node == [?NS_ADMIN | "#motd-allhosts"])
or (Node == "announce/all-hosts/motd/update") or (Node == [?NS_ADMIN | "#edit-motd-allhosts"])
or (Node == "announce/all-hosts/motd/delete") -> or (Node == [?NS_ADMIN | "#delete-motd-allhosts"]) ->
case gen_mod:is_loaded(LServer, mod_adhoc) of case gen_mod:is_loaded(LServer, mod_adhoc) of
false -> false ->
Acc; Acc;
@ -232,22 +238,22 @@ disco_features(Acc, From, #jid{lserver = LServer} = _To,
Access = gen_mod:get_module_opt(LServer, ?MODULE, access, none), Access = gen_mod:get_module_opt(LServer, ?MODULE, access, none),
Allow = acl:match_rule(LServer, Access, From), Allow = acl:match_rule(LServer, Access, From),
case Node of case Node of
"announce/all" -> ?NS_ADMIN ++ "#announce-all" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]); ?INFO_RESULT(Allow, [?NS_COMMANDS]);
"announce/online" -> ?NS_ADMIN ++ "#announce" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]); ?INFO_RESULT(Allow, [?NS_COMMANDS]);
"announce/motd" -> ?NS_ADMIN ++ "#set-motd" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]); ?INFO_RESULT(Allow, [?NS_COMMANDS]);
"announce/motd/delete" -> ?NS_ADMIN ++ "#delete-motd" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]); ?INFO_RESULT(Allow, [?NS_COMMANDS]);
"announce/motd/update" -> ?NS_ADMIN ++ "#edit-motd" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]); ?INFO_RESULT(Allow, [?NS_COMMANDS]);
_ -> _ ->
Acc Acc
end end
end. end.
%------------------------------------------------------------------------- %%-------------------------------------------------------------------------
-define(NODE_TO_ITEM(Lang, Server, Node), -define(NODE_TO_ITEM(Lang, Server, Node),
{xmlelement, "item", {xmlelement, "item",
@ -295,11 +301,11 @@ disco_items(Acc, From, #jid{lserver = LServer} = To, "announce", Lang) ->
end; end;
disco_items(Acc, From, #jid{lserver = LServer} = _To, Node, _Lang) disco_items(Acc, From, #jid{lserver = LServer} = _To, Node, _Lang)
when (Node == "announce/all-hosts/online") when (Node == [?NS_ADMIN | "#announce-online-allhosts"])
or (Node == "announce/all-hosts/all") or (Node == [?NS_ADMIN | "#announce-all-allhosts"])
or (Node == "announce/all-hosts/motd") or (Node == [?NS_ADMIN | "#motd-allhosts"])
or (Node == "announce/all-hosts/motd/update") or (Node == [?NS_ADMIN | "#edit-motd-allhosts"])
or (Node == "announce/all-hosts/motd/delete") -> or (Node == [?NS_ADMIN | "#delete-motd-allhosts"]) ->
case gen_mod:is_loaded(LServer, mod_adhoc) of case gen_mod:is_loaded(LServer, mod_adhoc) of
false -> false ->
Acc; Acc;
@ -317,43 +323,43 @@ disco_items(Acc, From, #jid{lserver = LServer} = _To, Node, _Lang) ->
Access = gen_mod:get_module_opt(LServer, ?MODULE, access, none), Access = gen_mod:get_module_opt(LServer, ?MODULE, access, none),
Allow = acl:match_rule(LServer, Access, From), Allow = acl:match_rule(LServer, Access, From),
case Node of case Node of
"announce/all" -> ?NS_ADMIN ++ "#announce-all" ->
?ITEMS_RESULT(Allow, []); ?ITEMS_RESULT(Allow, []);
"announce/online" -> ?NS_ADMIN ++ "#announce" ->
?ITEMS_RESULT(Allow, []); ?ITEMS_RESULT(Allow, []);
"announce/motd" -> ?NS_ADMIN ++ "#set-motd" ->
?ITEMS_RESULT(Allow, []); ?ITEMS_RESULT(Allow, []);
"announce/motd/delete" -> ?NS_ADMIN ++ "#delete-motd" ->
?ITEMS_RESULT(Allow, []); ?ITEMS_RESULT(Allow, []);
"announce/motd/update" -> ?NS_ADMIN ++ "#edit-motd" ->
?ITEMS_RESULT(Allow, []); ?ITEMS_RESULT(Allow, []);
_ -> _ ->
Acc Acc
end end
end. end.
%------------------------------------------------------------------------- %%-------------------------------------------------------------------------
announce_items(Acc, From, #jid{lserver = LServer, server = Server} = _To, Lang) -> announce_items(Acc, From, #jid{lserver = LServer, server = Server} = _To, Lang) ->
Access1 = gen_mod:get_module_opt(LServer, ?MODULE, access, none), Access1 = gen_mod:get_module_opt(LServer, ?MODULE, access, none),
Nodes1 = case acl:match_rule(LServer, Access1, From) of Nodes1 = case acl:match_rule(LServer, Access1, From) of
allow -> allow ->
[?NODE_TO_ITEM(Lang, Server, "announce/all"), [?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce-all"),
?NODE_TO_ITEM(Lang, Server, "announce/online"), ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce"),
?NODE_TO_ITEM(Lang, Server, "announce/motd"), ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#set-motd"),
?NODE_TO_ITEM(Lang, Server, "announce/motd/delete"), ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#delete-motd"),
?NODE_TO_ITEM(Lang, Server, "announce/motd/update")]; ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#edit-motd")];
deny -> deny ->
[] []
end, end,
Access2 = gen_mod:get_module_opt(global, ?MODULE, access, none), Access2 = gen_mod:get_module_opt(global, ?MODULE, access, none),
Nodes2 = case acl:match_rule(global, Access2, From) of Nodes2 = case acl:match_rule(global, Access2, From) of
allow -> allow ->
[?NODE_TO_ITEM(Lang, Server, "announce/all-hosts/all"), [?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce-all-allhosts"),
?NODE_TO_ITEM(Lang, Server, "announce/all-hosts/online"), ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce-online-allhosts"),
?NODE_TO_ITEM(Lang, Server, "announce/all-hosts/motd"), ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#motd-allhosts"),
?NODE_TO_ITEM(Lang, Server, "announce/all-hosts/motd/update"), ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#edit-motd-allhosts"),
?NODE_TO_ITEM(Lang, Server, "announce/all-hosts/motd/delete")]; ?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#delete-motd-allhosts")];
deny -> deny ->
[] []
end, end,
@ -368,48 +374,55 @@ announce_items(Acc, From, #jid{lserver = LServer, server = Server} = _To, Lang)
{result, Items ++ Nodes1 ++ Nodes2} {result, Items ++ Nodes1 ++ Nodes2}
end. end.
%------------------------------------------------------------------------- %%-------------------------------------------------------------------------
-define(COMMANDS_RESULT(Allow, From, To, Request), commands_result(Allow, From, To, Request) ->
case Allow of case Allow of
deny -> deny ->
{error, ?ERR_FORBIDDEN}; {error, ?ERR_FORBIDDEN};
allow -> allow ->
announce_commands(From, To, Request) announce_commands(From, To, Request)
end).
announce_commands(_Acc, From, To,
#adhoc_request{
node = Node} = Request)
when (Node == "announce/all-hosts/online")
or (Node == "announce/all-hosts/all")
or (Node == "announce/all-hosts/motd")
or (Node == "announce/all-hosts/motd/update")
or (Node == "announce/all-hosts/motd/delete") ->
Access = gen_mod:get_module_opt(global, ?MODULE, access, none),
Allow = acl:match_rule(global, Access, From),
?COMMANDS_RESULT(Allow, From, To, Request);
announce_commands(Acc, From, #jid{lserver = LServer} = To,
#adhoc_request{node = Node} = Request) ->
Access = gen_mod:get_module_opt(LServer, ?MODULE, access, none),
Allow = acl:match_rule(LServer, Access, From),
case Node of
"announce/all" ->
?COMMANDS_RESULT(Allow, From, To, Request);
"announce/online" ->
?COMMANDS_RESULT(Allow, From, To, Request);
"announce/motd" ->
?COMMANDS_RESULT(Allow, From, To, Request);
"announce/motd/delete" ->
?COMMANDS_RESULT(Allow, From, To, Request);
"announce/motd/update" ->
?COMMANDS_RESULT(Allow, From, To, Request);
_ ->
Acc
end. end.
%-------------------------------------------------------------------------
announce_commands(Acc, From, #jid{lserver = LServer} = To,
#adhoc_request{ node = Node} = Request) ->
LNode = tokenize(Node),
F = fun() ->
Access = gen_mod:get_module_opt(global, ?MODULE, access, none),
Allow = acl:match_rule(global, Access, From),
commands_result(Allow, From, To, Request)
end,
R = case LNode of
?NS_ADMINL("announce-online-allhosts") -> F();
?NS_ADMINL("announce-all-allhosts") -> F();
?NS_ADMINL("motd-allhosts") -> F();
?NS_ADMINL("edit-motd-allhosts") -> F();
?NS_ADMINL("delete-motd-allhosts") -> F();
_ ->
Access = gen_mod:get_module_opt(LServer, ?MODULE, access, none),
Allow = acl:match_rule(LServer, Access, From),
case LNode of
?NS_ADMINL("announce-all") ->
commands_result(Allow, From, To, Request);
?NS_ADMINL("announce") ->
commands_result(Allow, From, To, Request);
?NS_ADMINL("set-motd") ->
commands_result(Allow, From, To, Request);
?NS_ADMINL("delete-motd") ->
commands_result(Allow, From, To, Request);
?NS_ADMINL("edit-motd") ->
commands_result(Allow, From, To, Request);
_ ->
unknown
end
end,
case R of
unknown -> Acc;
_ -> {stop, R}
end.
%%-------------------------------------------------------------------------
announce_commands(From, To, announce_commands(From, To,
#adhoc_request{lang = Lang, #adhoc_request{lang = Lang,
@ -428,10 +441,11 @@ announce_commands(From, To,
#adhoc_response{status = canceled}); #adhoc_response{status = canceled});
XData == false, ActionIsExecute -> XData == false, ActionIsExecute ->
%% User requests form %% User requests form
Elements = generate_adhoc_form(Lang, Node),
adhoc:produce_response( adhoc:produce_response(
Request, Request,
#adhoc_response{status = executing, #adhoc_response{status = executing,
elements = [generate_adhoc_form(Lang, Node)]}); elements = [Elements]});
XData /= false, ActionIsExecute -> XData /= false, ActionIsExecute ->
%% User returns form. %% User returns form.
case jlib:parse_xdata_submit(XData) of case jlib:parse_xdata_submit(XData) of
@ -444,14 +458,22 @@ announce_commands(From, To,
{error, ?ERR_BAD_REQUEST} {error, ?ERR_BAD_REQUEST}
end. end.
-define(TVFIELD(Type, Var, Val),
{xmlelement, "field", [{"type", Type},
{"var", Var}],
[{xmlelement, "value", [], [{xmlcdata, Val}]}]}).
-define(HFIELD(), ?TVFIELD("hidden", "FORM_TYPE", ?NS_ADMIN)).
generate_adhoc_form(Lang, Node) -> generate_adhoc_form(Lang, Node) ->
LNode = tokenize(Node),
{xmlelement, "x", {xmlelement, "x",
[{"xmlns", ?NS_XDATA}, [{"xmlns", ?NS_XDATA},
{"type", "form"}], {"type", "form"}],
[{xmlelement, "title", [], [{xmlcdata, get_title(Lang, Node)}]}] [?HFIELD(),
{xmlelement, "title", [], [{xmlcdata, get_title(Lang, Node)}]}]
++ ++
if (Node == "announce/motd/delete") if (LNode == ?NS_ADMINL("delete-motd"))
or (Node == "announce/all-hosts/motd/delete") -> or (LNode == ?NS_ADMINL("delete-motd-allhosts")) ->
[{xmlelement, "field", [{xmlelement, "field",
[{"var", "confirm"}, [{"var", "confirm"},
{"type", "boolean"}, {"type", "boolean"},
@ -529,14 +551,14 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
Proc = gen_mod:get_module_proc(LServer, ?PROCNAME), Proc = gen_mod:get_module_proc(LServer, ?PROCNAME),
case {Node, Body} of case {Node, Body} of
{"announce/motd/delete", _} -> {?NS_ADMIN ++ "#delete-motd", _} ->
if Confirm -> if Confirm ->
Proc ! {announce_motd_delete, From, To, Packet}, Proc ! {announce_motd_delete, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
true -> true ->
adhoc:produce_response(Response) adhoc:produce_response(Response)
end; end;
{"announce/all-hosts/motd/delete", _} -> {?NS_ADMIN ++ "#delete-motd-allhosts", _} ->
if Confirm -> if Confirm ->
Proc ! {announce_all_hosts_motd_delete, From, To, Packet}, Proc ! {announce_all_hosts_motd_delete, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
@ -552,28 +574,28 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
%% Now send the packet to ?PROCNAME. %% Now send the packet to ?PROCNAME.
%% We don't use direct announce_* functions because it %% We don't use direct announce_* functions because it
%% leads to large delay in response and <iq/> queries processing %% leads to large delay in response and <iq/> queries processing
{"announce/all", _} -> {?NS_ADMIN ++ "#announce-all", _} ->
Proc ! {announce_all, From, To, Packet}, Proc ! {announce_all, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
{"announce/all-hosts/all", _} -> {?NS_ADMIN ++ "#announce-all-allhosts", _} ->
Proc ! {announce_all_hosts_all, From, To, Packet}, Proc ! {announce_all_hosts_all, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
{"announce/online", _} -> {?NS_ADMIN ++ "#announce", _} ->
Proc ! {announce_online, From, To, Packet}, Proc ! {announce_online, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
{"announce/all-hosts/online", _} -> {?NS_ADMIN ++ "#announce-online-allhosts", _} ->
Proc ! {announce_all_hosts_online, From, To, Packet}, Proc ! {announce_all_hosts_online, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
{"announce/motd", _} -> {?NS_ADMIN ++ "#set-motd", _} ->
Proc ! {announce_motd, From, To, Packet}, Proc ! {announce_motd, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
{"announce/all-hosts/motd", _} -> {?NS_ADMIN ++ "#motd-allhosts", _} ->
Proc ! {announce_all_hosts_motd, From, To, Packet}, Proc ! {announce_all_hosts_motd, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
{"announce/motd/update", _} -> {?NS_ADMIN ++ "#edit-motd", _} ->
Proc ! {announce_motd_update, From, To, Packet}, Proc ! {announce_motd_update, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
{"announce/all-hosts/motd/update", _} -> {?NS_ADMIN ++ "#edit-motd-allhosts", _} ->
Proc ! {announce_all_hosts_motd_update, From, To, Packet}, Proc ! {announce_all_hosts_motd_update, From, To, Packet},
adhoc:produce_response(Response); adhoc:produce_response(Response);
_ -> _ ->
@ -584,28 +606,28 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
get_title(Lang, "announce") -> get_title(Lang, "announce") ->
translate:translate(Lang, "Announcements"); translate:translate(Lang, "Announcements");
get_title(Lang, "announce/all") -> get_title(Lang, ?NS_ADMIN ++ "#announce-all") ->
translate:translate(Lang, "Send announcement to all users"); translate:translate(Lang, "Send announcement to all users");
get_title(Lang, "announce/all-hosts/all") -> get_title(Lang, ?NS_ADMIN ++ "#announce-all-allhosts") ->
translate:translate(Lang, "Send announcement to all users on all hosts"); translate:translate(Lang, "Send announcement to all users on all hosts");
get_title(Lang, "announce/online") -> get_title(Lang, ?NS_ADMIN ++ "#announce") ->
translate:translate(Lang, "Send announcement to all online users"); translate:translate(Lang, "Send announcement to all online users");
get_title(Lang, "announce/all-hosts/online") -> get_title(Lang, ?NS_ADMIN ++ "#announce-online-allhosts") ->
translate:translate(Lang, "Send announcement to all online users on all hosts"); translate:translate(Lang, "Send announcement to all online users on all hosts");
get_title(Lang, "announce/motd") -> get_title(Lang, ?NS_ADMIN ++ "#set-motd") ->
translate:translate(Lang, "Set message of the day and send to online users"); translate:translate(Lang, "Set message of the day and send to online users");
get_title(Lang, "announce/all-hosts/motd") -> get_title(Lang, ?NS_ADMIN ++ "#motd-allhosts") ->
translate:translate(Lang, "Set message of the day on all hosts and send to online users"); translate:translate(Lang, "Set message of the day on all hosts and send to online users");
get_title(Lang, "announce/motd/update") -> get_title(Lang, ?NS_ADMIN ++ "#edit-motd") ->
translate:translate(Lang, "Update message of the day (don't send)"); translate:translate(Lang, "Update message of the day (don't send)");
get_title(Lang, "announce/all-hosts/motd/update") -> get_title(Lang, ?NS_ADMIN ++ "#edit-motd-allhosts") ->
translate:translate(Lang, "Update message of the day on all hosts (don't send)"); translate:translate(Lang, "Update message of the day on all hosts (don't send)");
get_title(Lang, "announce/motd/delete") -> get_title(Lang, ?NS_ADMIN ++ "#delete-motd") ->
translate:translate(Lang, "Delete message of the day"); translate:translate(Lang, "Delete message of the day");
get_title(Lang, "announce/all-hosts/motd/delete") -> get_title(Lang, ?NS_ADMIN ++ "#delete-motd-allhosts") ->
translate:translate(Lang, "Delete message of the day on all hosts"). translate:translate(Lang, "Delete message of the day on all hosts").
%------------------------------------------------------------------------- %%-------------------------------------------------------------------------
announce_all(From, To, Packet) -> announce_all(From, To, Packet) ->
Host = To#jid.lserver, Host = To#jid.lserver,
@ -790,7 +812,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID) ->
ok ok
end. end.
%------------------------------------------------------------------------- %%-------------------------------------------------------------------------
update_tables() -> update_tables() ->
update_motd_table(), update_motd_table(),

File diff suppressed because it is too large Load Diff

View File

@ -192,7 +192,7 @@ try_register(User, Server, Password) ->
send_welcome_message(JID) -> send_welcome_message(JID) ->
Host = JID#jid.lserver, Host = JID#jid.lserver,
case ejabberd_config:get_local_option({welcome_message, Host}) of case gen_mod:get_module_opt(Host, ?MODULE, welcome_message, {"", ""}) of
{"", ""} -> {"", ""} ->
ok; ok;
{Subj, Body} -> {Subj, Body} ->
@ -208,7 +208,7 @@ send_welcome_message(JID) ->
send_registration_notifications(UJID) -> send_registration_notifications(UJID) ->
Host = UJID#jid.lserver, Host = UJID#jid.lserver,
case ejabberd_config:get_local_option({registration_watchers, Host}) of case gen_mod:get_module_opt(Host, ?MODULE, registration_watchers, []) of
[] -> ok; [] -> ok;
JIDs when is_list(JIDs) -> JIDs when is_list(JIDs) ->
Body = lists:flatten( Body = lists:flatten(
@ -231,4 +231,3 @@ send_registration_notifications(UJID) ->
_ -> _ ->
ok ok
end. end.