25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Convert to exmpp.

SVN Revision: 1492
This commit is contained in:
Jean-Sébastien Pédron 2008-07-25 14:26:59 +00:00
parent adaf392156
commit 70956ece12
6 changed files with 739 additions and 728 deletions

View File

@ -1,3 +1,8 @@
2008-07-25 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/adhoc.erl, src/mod_configure.erl, src/mod_announce.erl,
src/mod_adhoc.erl, src/gen_iq_handler.erl: Convert to exmpp.
2008-07-22 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/mod_disco.erl, src/gen_iq_handler.erl: Convert to exmpp.

View File

@ -31,47 +31,53 @@
produce_response/2,
produce_response/1]).
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("jlib.hrl").
-include("adhoc.hrl").
%% Parse an ad-hoc request. Return either an adhoc_request record or
%% an {error, ErrorType} tuple.
parse_request(#iq{type = set, lang = Lang, sub_el = SubEl, xmlns = ?NS_COMMANDS}) ->
?DEBUG("entering parse_request...", []),
Node = xml:get_tag_attr_s("node", SubEl),
SessionID = xml:get_tag_attr_s("sessionid", SubEl),
Action = xml:get_tag_attr_s("action", SubEl),
XData = find_xdata_el(SubEl),
{xmlelement, _, _, AllEls} = SubEl,
if XData ->
Others = lists:delete(XData, AllEls);
true ->
Others = AllEls
end,
parse_request(IQ) ->
try
SubEl = exmpp_iq:get_request(IQ),
case {exmpp_iq:get_type(IQ), SubEl#xmlel.ns} of
{set, ?NS_ADHOC} ->
?DEBUG("entering parse_request...", []),
Lang = exmpp_stanza:get_lang(IQ),
Node = exmpp_xml:get_attribute(SubEl, 'node'),
SessionID = exmpp_xml:get_attribute(SubEl, 'sessionid'),
Action = exmpp_xml:get_attribute(SubEl, 'action'),
XData = find_xdata_el(SubEl),
AllEls = SubEl#xmlel.ns,
if XData ->
Others = lists:delete(XData, AllEls);
true ->
Others = AllEls
end,
#adhoc_request{lang = Lang,
node = Node,
sessionid = SessionID,
action = Action,
xdata = XData,
others = Others};
parse_request(_) ->
{error, ?ERR_BAD_REQUEST}.
#adhoc_request{lang = Lang,
node = Node,
sessionid = SessionID,
action = Action,
xdata = XData,
others = Others};
_ ->
{error, 'bad-request'}
end
catch
_ ->
{error, 'bad-request'}
end.
%% Borrowed from mod_vcard.erl
find_xdata_el({xmlelement, _Name, _Attrs, SubEls}) ->
find_xdata_el(#xmlel{children = SubEls}) ->
find_xdata_el1(SubEls).
find_xdata_el1([]) ->
false;
find_xdata_el1([{xmlelement, Name, Attrs, SubEls} | Els]) ->
case xml:get_attr_s("xmlns", Attrs) of
?NS_XDATA ->
{xmlelement, Name, Attrs, SubEls};
_ ->
find_xdata_el1(Els)
end;
find_xdata_el1([#xmlel{ns = ?NS_DATA_FORMS} = El | _Els]) ->
El;
find_xdata_el1([_ | Els]) ->
find_xdata_el1(Els).
@ -109,20 +115,19 @@ produce_response(#adhoc_response{lang = _Lang,
"" ->
ActionsElAttrs = [];
_ ->
ActionsElAttrs = [{"execute", DefaultAction}]
ActionsElAttrs = [#xmlattr{name = 'execute', value = DefaultAction}]
end,
ActionsEls = [{xmlelement, "actions",
ActionsElAttrs,
[{xmlelement, Action, [], []} || Action <- Actions]}]
ActionsEls = [#xmlel{ns = ?NS_ADHOC, name = 'actions', attrs =
ActionsElAttrs, children =
[#xmlel{ns = ?NS_ADHOC, name = Action} || Action <- Actions]}]
end,
NotesEls = lists:map(fun({Type, Text}) ->
{xmlelement, "note",
[{"type", Type}],
[{xmlcdata, Text}]}
#xmlel{ns = ?NS_ADHOC, name = 'note', attrs =
[#xmlattr{name = 'type', value = Type}],
children = [#xmlcdata{cdata = list_to_binary(Text)}]}
end, Notes),
{xmlelement, "command",
[{"xmlns", ?NS_COMMANDS},
{"sessionid", SessionID},
{"node", Node},
{"status", atom_to_list(Status)}],
#xmlel{ns = ?NS_ADHOC, name = 'command', attrs =
[#xmlattr{name = 'sessionid', value = SessionID},
#xmlattr{name = 'node', value = Node},
#xmlattr{name = 'status', value = atom_to_list(Status)}], children =
ActionsEls ++ NotesEls ++ Elements}.

View File

@ -59,7 +59,10 @@
% XXX OLD FORMAT: modules not in the following list will receive
% old format strudctures.
-define(CONVERTED_MODULES, [
mod_adhoc,
mod_annouce,
mod_caps,
mod_configure,
mod_disco,
mod_roster,
mod_vcard

View File

@ -42,16 +42,17 @@
ping_item/4,
ping_command/4]).
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("jlib.hrl").
-include("adhoc.hrl").
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_COMMANDS,
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_ADHOC_s,
?MODULE, process_local_iq, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_COMMANDS,
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ADHOC_s,
?MODULE, process_sm_iq, IQDisc),
ejabberd_hooks:add(disco_local_identity, Host, ?MODULE, get_local_identity, 99),
@ -73,12 +74,12 @@ stop(Host) ->
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, get_local_features, 99),
ejabberd_hooks:delete(disco_local_identity, Host, ?MODULE, get_local_identity, 99),
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_COMMANDS),
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_COMMANDS).
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ADHOC_s),
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_ADHOC_s).
%-------------------------------------------------------------------------
get_local_commands(Acc, _From, #jid{server = Server, lserver = LServer} = _To, "", Lang) ->
get_local_commands(Acc, _From, #jid{domain = Server, ldomain = LServer} = _To, "", Lang) ->
Display = gen_mod:get_module_opt(LServer, ?MODULE, report_commands_node, false),
case Display of
false ->
@ -88,17 +89,20 @@ get_local_commands(Acc, _From, #jid{server = Server, lserver = LServer} = _To, "
{result, I} -> I;
_ -> []
end,
Nodes = [{xmlelement,
"item",
[{"jid", Server},
{"node", ?NS_COMMANDS},
{"name", translate:translate(Lang, "Commands")}],
[]}],
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS,
name = 'item', attrs =
[#xmlattr{name = 'jid', value = Server},
#xmlattr{name = 'node', value = ?NS_ADHOC_s},
#xmlattr{name = 'name', value = translate:translate(Lang, "Commands")}]
}],
{result, Items ++ Nodes}
end;
get_local_commands(_Acc, From, #jid{lserver = LServer} = To, ?NS_COMMANDS, Lang) ->
ejabberd_hooks:run_fold(adhoc_local_items, LServer, {result, []}, [From, To, Lang]);
get_local_commands(_Acc, From, #jid{ldomain = LServer} = To, ?NS_ADHOC_s, Lang) ->
% XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
ejabberd_hooks:run_fold(adhoc_local_items, LServer, {result, []}, [FromOld, ToOld, Lang]);
get_local_commands(_Acc, _From, _To, "ping", _Lang) ->
{result, []};
@ -108,7 +112,7 @@ get_local_commands(Acc, _From, _To, _Node, _Lang) ->
%-------------------------------------------------------------------------
get_sm_commands(Acc, _From, #jid{lserver = LServer} = To, "", Lang) ->
get_sm_commands(Acc, _From, #jid{ldomain = LServer} = To, "", Lang) ->
Display = gen_mod:get_module_opt(LServer, ?MODULE, report_commands_node, false),
case Display of
false ->
@ -118,17 +122,20 @@ get_sm_commands(Acc, _From, #jid{lserver = LServer} = To, "", Lang) ->
{result, I} -> I;
_ -> []
end,
Nodes = [{xmlelement,
"item",
[{"jid", jlib:jid_to_string(To)},
{"node", ?NS_COMMANDS},
{"name", translate:translate(Lang, "Commands")}],
[]}],
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS,
name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(To)},
#xmlattr{name = 'node', value = ?NS_ADHOC_s},
#xmlattr{name = 'name', value = translate:translate(Lang, "Commands")}]
}],
{result, Items ++ Nodes}
end;
get_sm_commands(_Acc, From, #jid{lserver = LServer} = To, ?NS_COMMANDS, Lang) ->
ejabberd_hooks:run_fold(adhoc_sm_items, LServer, {result, []}, [From, To, Lang]);
get_sm_commands(_Acc, From, #jid{ldomain = LServer} = To, ?NS_ADHOC_s, Lang) ->
% XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
ejabberd_hooks:run_fold(adhoc_sm_items, LServer, {result, []}, [FromOld, ToOld, Lang]);
get_sm_commands(Acc, _From, _To, _Node, _Lang) ->
Acc.
@ -136,17 +143,17 @@ get_sm_commands(Acc, _From, _To, _Node, _Lang) ->
%-------------------------------------------------------------------------
%% On disco info request to the ad-hoc node, return automation/command-list.
get_local_identity(Acc, _From, _To, ?NS_COMMANDS, Lang) ->
[{xmlelement, "identity",
[{"category", "automation"},
{"type", "command-list"},
{"name", translate:translate(Lang, "Commands")}], []} | Acc];
get_local_identity(Acc, _From, _To, ?NS_ADHOC_s, Lang) ->
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
[#xmlattr{name = 'category', value = "automation"},
#xmlattr{name = 'type', value = "command-list"},
#xmlattr{name = 'name', value = translate:translate(Lang, "Commands")}]} | Acc];
get_local_identity(Acc, _From, _To, "ping", Lang) ->
[{xmlelement, "identity",
[{"category", "automation"},
{"type", "command-node"},
{"name", translate:translate(Lang, "Ping")}], []} | Acc];
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
[#xmlattr{name = 'category', value = "automation"},
#xmlattr{name = 'type', value = "command-node"},
#xmlattr{name = 'name', value = translate:translate(Lang, "Ping")}]} | Acc];
get_local_identity(Acc, _From, _To, _Node, _Lang) ->
Acc.
@ -154,11 +161,11 @@ get_local_identity(Acc, _From, _To, _Node, _Lang) ->
%-------------------------------------------------------------------------
%% On disco info request to the ad-hoc node, return automation/command-list.
get_sm_identity(Acc, _From, _To, ?NS_COMMANDS, Lang) ->
[{xmlelement, "identity",
[{"category", "automation"},
{"type", "command-list"},
{"name", translate:translate(Lang, "Commands")}], []} | Acc];
get_sm_identity(Acc, _From, _To, ?NS_ADHOC_s, Lang) ->
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
[#xmlattr{name = 'category', value = "automation"},
#xmlattr{name = 'type', value = "command-list"},
#xmlattr{name = 'name', value = translate:translate(Lang, "Commands")}]} | Acc];
get_sm_identity(Acc, _From, _To, _Node, _Lang) ->
Acc.
@ -170,15 +177,15 @@ get_local_features(Acc, _From, _To, "", _Lang) ->
{result, I} -> I;
_ -> []
end,
{result, Feats ++ [?NS_COMMANDS]};
{result, Feats ++ [?NS_ADHOC_s]};
get_local_features(_Acc, _From, _To, ?NS_COMMANDS, _Lang) ->
get_local_features(_Acc, _From, _To, ?NS_ADHOC_s, _Lang) ->
%% override all lesser features...
{result, []};
get_local_features(_Acc, _From, _To, "ping", _Lang) ->
%% override all lesser features...
{result, [?NS_COMMANDS]};
{result, [?NS_ADHOC_s]};
get_local_features(Acc, _From, _To, _Node, _Lang) ->
Acc.
@ -190,9 +197,9 @@ get_sm_features(Acc, _From, _To, "", _Lang) ->
{result, I} -> I;
_ -> []
end,
{result, Feats ++ [?NS_COMMANDS]};
{result, Feats ++ [?NS_ADHOC_s]};
get_sm_features(_Acc, _From, _To, ?NS_COMMANDS, _Lang) ->
get_sm_features(_Acc, _From, _To, ?NS_ADHOC_s, _Lang) ->
%% override all lesser features...
{result, []};
@ -209,39 +216,41 @@ process_sm_iq(From, To, IQ) ->
process_adhoc_request(From, To, IQ, adhoc_sm_commands).
process_adhoc_request(From, To, #iq{sub_el = SubEl} = IQ, Hook) ->
process_adhoc_request(From, To, IQ, Hook) ->
?DEBUG("About to parse ~p...", [IQ]),
case adhoc:parse_request(IQ) of
{error, Error} ->
IQ#iq{type = error, sub_el = [SubEl, Error]};
exmpp_iq:error(IQ, Error);
#adhoc_request{} = AdhocRequest ->
Host = To#jid.lserver,
Host = To#jid.ldomain,
% XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
case ejabberd_hooks:run_fold(Hook, Host, empty,
[From, To, AdhocRequest]) of
[FromOld, ToOld, AdhocRequest]) of
ignore ->
ignore;
empty ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_ITEM_NOT_FOUND]};
exmpp_iq:error(IQ, 'item-not-found');
{error, Error} ->
IQ#iq{type = error, sub_el = [SubEl, Error]};
exmpp_iq:error(IQ, Error);
Command ->
IQ#iq{type = result, sub_el = [Command]}
exmpp_iq:result(IQ, Command)
end
end.
ping_item(Acc, _From, #jid{server = Server} = _To, Lang) ->
ping_item(Acc, _From, #jid{domain = Server} = _To, Lang) ->
Items = case Acc of
{result, I} ->
I;
_ ->
[]
end,
Nodes = [{xmlelement, "item",
[{"jid", Server},
{"node", "ping"},
{"name", translate:translate(Lang, "Ping")}],
[]}],
Nodes = [#xmlel{ns = ?NS_DISCO_INFO, name = 'item', attrs =
[#xmlattr{name = 'jid', value = Server},
#xmlattr{name = 'node', value = "ping"},
#xmlattr{name = 'name', value = translate:translate(Lang, "Ping")}]}],
{result, Items ++ Nodes}.
@ -259,7 +268,7 @@ ping_command(_Acc, _From, _To,
Lang,
"Pong")}]});
true ->
{error, ?ERR_BAD_REQUEST}
{error, 'bad-request'}
end;
ping_command(Acc, _From, _To, _Request) ->

View File

@ -43,8 +43,9 @@
announce_commands/4,
announce_items/4]).
-include_lib("exmpp/include/exmpp.hrl").
-include("ejabberd.hrl").
-include("jlib.hrl").
-include("adhoc.hrl").
-record(motd, {server, packet}).
@ -52,6 +53,8 @@
-define(PROCNAME, ejabberd_announce).
-define(NS_ADMIN_s, "http://jabber.org/protocol/admin").
-define(NS_ADMINL(Sub), ["http:","jabber.org","protocol","admin", Sub]).
tokenize(Node) -> string:tokens(Node, "/#").
@ -129,38 +132,38 @@ stop(Host) ->
%% Announcing via messages to a custom resource
announce(From, To, Packet) ->
case To of
#jid{luser = "", lresource = Res} ->
{xmlelement, Name, _Attrs, _Els} = Packet,
Proc = gen_mod:get_module_proc(To#jid.lserver, ?PROCNAME),
#jid{lnode = undefined, lresource = Res} ->
Name = Packet#xmlel.name,
Proc = gen_mod:get_module_proc(To#jid.ldomain, ?PROCNAME),
case {Res, Name} of
{"announce/all", "message"} ->
{"announce/all", 'message'} ->
Proc ! {announce_all, From, To, Packet},
stop;
{"announce/all-hosts/all", "message"} ->
{"announce/all-hosts/all", 'message'} ->
Proc ! {announce_all_hosts_all, From, To, Packet},
stop;
{"announce/online", "message"} ->
{"announce/online", 'message'} ->
Proc ! {announce_online, From, To, Packet},
stop;
{"announce/all-hosts/online", "message"} ->
{"announce/all-hosts/online", 'message'} ->
Proc ! {announce_all_hosts_online, From, To, Packet},
stop;
{"announce/motd", "message"} ->
{"announce/motd", 'message'} ->
Proc ! {announce_motd, From, To, Packet},
stop;
{"announce/all-hosts/motd", "message"} ->
{"announce/all-hosts/motd", 'message'} ->
Proc ! {announce_all_hosts_motd, From, To, Packet},
stop;
{"announce/motd/update", "message"} ->
{"announce/motd/update", 'message'} ->
Proc ! {announce_motd_update, From, To, Packet},
stop;
{"announce/all-hosts/motd/update", "message"} ->
{"announce/all-hosts/motd/update", 'message'} ->
Proc ! {announce_all_hosts_motd_update, From, To, Packet},
stop;
{"announce/motd/delete", "message"} ->
{"announce/motd/delete", 'message'} ->
Proc ! {announce_motd_delete, From, To, Packet},
stop;
{"announce/all-hosts/motd/delete", "message"} ->
{"announce/all-hosts/motd/delete", 'message'} ->
Proc ! {announce_all_hosts_motd_delete, From, To, Packet},
stop;
_ ->
@ -173,10 +176,10 @@ announce(From, To, Packet) ->
%%-------------------------------------------------------------------------
%% Announcing via ad-hoc commands
-define(INFO_COMMAND(Lang, Node),
[{xmlelement, "identity",
[{"category", "automation"},
{"type", "command-node"},
{"name", get_title(Lang, Node)}], []}]).
[#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs =
[#xmlattr{name = 'category', value = "automation"},
#xmlattr{name = 'type', value = "command-node"},
#xmlattr{name = 'name', value = get_title(Lang, Node)}]}]).
disco_identity(Acc, _From, _To, Node, Lang) ->
LNode = tokenize(Node),
@ -210,12 +213,12 @@ disco_identity(Acc, _From, _To, Node, Lang) ->
-define(INFO_RESULT(Allow, Feats),
case Allow of
deny ->
{error, ?ERR_FORBIDDEN};
{error, 'forbidden'};
allow ->
{result, Feats}
end).
disco_features(Acc, From, #jid{lserver = LServer} = _To,
disco_features(Acc, From, #jid{ldomain = LServer} = _To,
"announce", _Lang) ->
case gen_mod:is_loaded(LServer, mod_adhoc) of
false ->
@ -226,13 +229,13 @@ disco_features(Acc, From, #jid{lserver = LServer} = _To,
case {acl:match_rule(LServer, Access1, From),
acl:match_rule(global, Access2, From)} of
{deny, deny} ->
{error, ?ERR_FORBIDDEN};
{error, 'forbidden'};
_ ->
{result, []}
end
end;
disco_features(Acc, From, #jid{lserver = LServer} = _To,
disco_features(Acc, From, #jid{ldomain = LServer} = _To,
Node, _Lang) ->
case gen_mod:is_loaded(LServer, mod_adhoc) of
false ->
@ -243,26 +246,26 @@ disco_features(Acc, From, #jid{lserver = LServer} = _To,
AccessGlobal = gen_mod:get_module_opt(global, ?MODULE, access, none),
AllowGlobal = acl:match_rule(global, AccessGlobal, From),
case Node of
?NS_ADMIN ++ "#announce" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]);
?NS_ADMIN ++ "#announce-all" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]);
?NS_ADMIN ++ "#set-motd" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]);
?NS_ADMIN ++ "#edit-motd" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]);
?NS_ADMIN ++ "#delete-motd" ->
?INFO_RESULT(Allow, [?NS_COMMANDS]);
?NS_ADMIN ++ "#announce-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_COMMANDS]);
?NS_ADMIN ++ "#announce-all-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_COMMANDS]);
?NS_ADMIN ++ "#set-motd-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_COMMANDS]);
?NS_ADMIN ++ "#edit-motd-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_COMMANDS]);
?NS_ADMIN ++ "#delete-motd-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_COMMANDS]);
?NS_ADMIN_s ++ "#announce" ->
?INFO_RESULT(Allow, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#announce-all" ->
?INFO_RESULT(Allow, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#set-motd" ->
?INFO_RESULT(Allow, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#edit-motd" ->
?INFO_RESULT(Allow, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#delete-motd" ->
?INFO_RESULT(Allow, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#announce-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#announce-all-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#set-motd-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#edit-motd-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_ADHOC_s]);
?NS_ADMIN_s ++ "#delete-motd-allhosts" ->
?INFO_RESULT(AllowGlobal, [?NS_ADHOC_s]);
_ ->
Acc
end
@ -271,21 +274,20 @@ disco_features(Acc, From, #jid{lserver = LServer} = _To,
%%-------------------------------------------------------------------------
-define(NODE_TO_ITEM(Lang, Server, Node),
{xmlelement, "item",
[{"jid", Server},
{"node", Node},
{"name", get_title(Lang, Node)}],
[]}).
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
[#xmlattr{name = 'jid', value = Server},
#xmlattr{name = 'node', value = Node},
#xmlattr{name = 'name', value = get_title(Lang, Node)}]}).
-define(ITEMS_RESULT(Allow, Items),
case Allow of
deny ->
{error, ?ERR_FORBIDDEN};
{error, 'forbidden'};
allow ->
{result, Items}
end).
disco_items(Acc, From, #jid{lserver = LServer, server = Server} = _To,
disco_items(Acc, From, #jid{ldomain = LServer, domain = Server} = _To,
"", Lang) ->
case gen_mod:is_loaded(LServer, mod_adhoc) of
false ->
@ -307,7 +309,7 @@ disco_items(Acc, From, #jid{lserver = LServer, server = Server} = _To,
end
end;
disco_items(Acc, From, #jid{lserver = LServer} = To, "announce", Lang) ->
disco_items(Acc, From, #jid{ldomain = LServer} = To, "announce", Lang) ->
case gen_mod:is_loaded(LServer, mod_adhoc) of
false ->
Acc;
@ -315,7 +317,7 @@ disco_items(Acc, From, #jid{lserver = LServer} = To, "announce", Lang) ->
announce_items(Acc, From, To, Lang)
end;
disco_items(Acc, From, #jid{lserver = LServer} = _To, Node, _Lang) ->
disco_items(Acc, From, #jid{ldomain = LServer} = _To, Node, _Lang) ->
case gen_mod:is_loaded(LServer, mod_adhoc) of
false ->
Acc;
@ -325,25 +327,25 @@ disco_items(Acc, From, #jid{lserver = LServer} = _To, Node, _Lang) ->
AccessGlobal = gen_mod:get_module_opt(global, ?MODULE, access, none),
AllowGlobal = acl:match_rule(global, AccessGlobal, From),
case Node of
?NS_ADMIN ++ "#announce" ->
?NS_ADMIN_s ++ "#announce" ->
?ITEMS_RESULT(Allow, []);
?NS_ADMIN ++ "#announce-all" ->
?NS_ADMIN_s ++ "#announce-all" ->
?ITEMS_RESULT(Allow, []);
?NS_ADMIN ++ "#set-motd" ->
?NS_ADMIN_s ++ "#set-motd" ->
?ITEMS_RESULT(Allow, []);
?NS_ADMIN ++ "#edit-motd" ->
?NS_ADMIN_s ++ "#edit-motd" ->
?ITEMS_RESULT(Allow, []);
?NS_ADMIN ++ "#delete-motd" ->
?NS_ADMIN_s ++ "#delete-motd" ->
?ITEMS_RESULT(Allow, []);
?NS_ADMIN ++ "#announce-allhosts" ->
?NS_ADMIN_s ++ "#announce-allhosts" ->
?ITEMS_RESULT(AllowGlobal, []);
?NS_ADMIN ++ "#announce-all-allhosts" ->
?NS_ADMIN_s ++ "#announce-all-allhosts" ->
?ITEMS_RESULT(AllowGlobal, []);
?NS_ADMIN ++ "#set-motd-allhosts" ->
?NS_ADMIN_s ++ "#set-motd-allhosts" ->
?ITEMS_RESULT(AllowGlobal, []);
?NS_ADMIN ++ "#edit-motd-allhosts" ->
?NS_ADMIN_s ++ "#edit-motd-allhosts" ->
?ITEMS_RESULT(AllowGlobal, []);
?NS_ADMIN ++ "#delete-motd-allhosts" ->
?NS_ADMIN_s ++ "#delete-motd-allhosts" ->
?ITEMS_RESULT(AllowGlobal, []);
_ ->
Acc
@ -352,26 +354,26 @@ disco_items(Acc, From, #jid{lserver = LServer} = _To, Node, _Lang) ->
%%-------------------------------------------------------------------------
announce_items(Acc, From, #jid{lserver = LServer, server = Server} = _To, Lang) ->
announce_items(Acc, From, #jid{ldomain = LServer, domain = Server} = _To, Lang) ->
Access1 = gen_mod:get_module_opt(LServer, ?MODULE, access, none),
Nodes1 = case acl:match_rule(LServer, Access1, From) of
allow ->
[?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce-all"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#set-motd"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#edit-motd"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#delete-motd")];
[?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#announce"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#announce-all"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#set-motd"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#edit-motd"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#delete-motd")];
deny ->
[]
end,
Access2 = gen_mod:get_module_opt(global, ?MODULE, access, none),
Nodes2 = case acl:match_rule(global, Access2, From) of
allow ->
[?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#announce-all-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#set-motd-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#edit-motd-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN ++ "#delete-motd-allhosts")];
[?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#announce-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#announce-all-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#set-motd-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#edit-motd-allhosts"),
?NODE_TO_ITEM(Lang, Server, ?NS_ADMIN_s ++ "#delete-motd-allhosts")];
deny ->
[]
end,
@ -391,13 +393,13 @@ announce_items(Acc, From, #jid{lserver = LServer, server = Server} = _To, Lang)
commands_result(Allow, From, To, Request) ->
case Allow of
deny ->
{error, ?ERR_FORBIDDEN};
{error, 'forbidden'};
allow ->
announce_commands(From, To, Request)
end.
announce_commands(Acc, From, #jid{lserver = LServer} = To,
announce_commands(Acc, From, #jid{ldomain = LServer} = To,
#adhoc_request{ node = Node} = Request) ->
LNode = tokenize(Node),
F = fun() ->
@ -453,7 +455,7 @@ announce_commands(From, To,
#adhoc_response{status = canceled});
XData == false, ActionIsExecute ->
%% User requests form
Elements = generate_adhoc_form(Lang, Node, To#jid.lserver),
Elements = generate_adhoc_form(Lang, Node, To#jid.ldomain),
adhoc:produce_response(
Request,
#adhoc_response{status = executing,
@ -462,26 +464,26 @@ announce_commands(From, To,
%% User returns form.
case jlib:parse_xdata_submit(XData) of
invalid ->
{error, ?ERR_BAD_REQUEST};
{error, 'bad-request'};
Fields ->
handle_adhoc_form(From, To, Request, Fields)
end;
true ->
{error, ?ERR_BAD_REQUEST}
{error, 'bad-request'}
end.
-define(VVALUE(Val),
{xmlelement, "value", [], [{xmlcdata, Val}]}).
#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]}).
-define(VVALUEL(Val),
case Val of
"" -> [];
_ -> [?VVALUE(Val)]
end).
-define(TVFIELD(Type, Var, Val),
{xmlelement, "field", [{"type", Type},
{"var", Var}],
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [#xmlattr{name = 'type', value = Type},
#xmlattr{name = 'var', value = Var}], children =
?VVALUEL(Val)}).
-define(HFIELD(), ?TVFIELD("hidden", "FORM_TYPE", ?NS_ADMIN)).
-define(HFIELD(), ?TVFIELD("hidden", "FORM_TYPE", ?NS_ADMIN_s)).
generate_adhoc_form(Lang, Node, ServerHost) ->
LNode = tokenize(Node),
@ -491,31 +493,29 @@ generate_adhoc_form(Lang, Node, ServerHost) ->
true ->
{[], []}
end,
{xmlelement, "x",
[{"xmlns", ?NS_XDATA},
{"type", "form"}],
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
[#xmlattr{name = 'type', value = "form"}], children =
[?HFIELD(),
{xmlelement, "title", [], [{xmlcdata, get_title(Lang, Node)}]}]
#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(get_title(Lang, Node))}]}]
++
if (LNode == ?NS_ADMINL("delete-motd"))
or (LNode == ?NS_ADMINL("delete-motd-allhosts")) ->
[{xmlelement, "field",
[{"var", "confirm"},
{"type", "boolean"},
{"label", translate:translate(Lang, "Really delete message of the day?")}],
[{xmlelement, "value",
[],
[{xmlcdata, "true"}]}]}];
[#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
[#xmlattr{name = 'var', value = "confirm"},
#xmlattr{name = 'type', value = "boolean"},
#xmlattr{name = 'label', value = translate:translate(Lang, "Really delete message of the day?")}], children =
[#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =
[#xmlcdata{cdata = <<"true">>}]}]}];
true ->
[{xmlelement, "field",
[{"var", "subject"},
{"type", "text-single"},
{"label", translate:translate(Lang, "Subject")}],
[#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
[#xmlattr{name = 'var', value = "subject"},
#xmlattr{name = 'type', value = "text-single"},
#xmlattr{name = 'label', value = translate:translate(Lang, "Subject")}], children =
?VVALUEL(OldSubject)},
{xmlelement, "field",
[{"var", "body"},
{"type", "text-multi"},
{"label", translate:translate(Lang, "Message body")}],
#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =
[#xmlattr{name = 'var', value = "body"},
#xmlattr{name = 'type', value = "text-multi"},
#xmlattr{name = 'label', value = translate:translate(Lang, "Message body")}], children =
?VVALUEL(OldBody)}]
end}.
@ -529,7 +529,7 @@ join_lines([], Acc) ->
%% Remove last newline
lists:flatten(lists:reverse(tl(Acc))).
handle_adhoc_form(From, #jid{lserver = LServer} = To,
handle_adhoc_form(From, #jid{ldomain = LServer} = To,
#adhoc_request{lang = Lang,
node = Node,
sessionid = SessionID},
@ -560,30 +560,30 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
node = Node,
sessionid = SessionID,
status = completed},
Packet = {xmlelement, "message", [{"type", "normal"}],
Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', attrs = [#xmlattr{name = 'type', value = "normal"}], children =
if Subject /= [] ->
[{xmlelement, "subject", [],
[{xmlcdata, Subject}]}];
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'subject', children =
[#xmlcdata{cdata = list_to_binary(Subject)}]}];
true ->
[]
end ++
if Body /= [] ->
[{xmlelement, "body", [],
[{xmlcdata, Body}]}];
[#xmlel{ns = ?NS_JABBER_CLIENT, name = 'body', children =
[#xmlcdata{cdata = list_to_binary(Body)}]}];
true ->
[]
end},
Proc = gen_mod:get_module_proc(LServer, ?PROCNAME),
case {Node, Body} of
{?NS_ADMIN ++ "#delete-motd", _} ->
{?NS_ADMIN_s ++ "#delete-motd", _} ->
if Confirm ->
Proc ! {announce_motd_delete, From, To, Packet},
adhoc:produce_response(Response);
true ->
adhoc:produce_response(Response)
end;
{?NS_ADMIN ++ "#delete-motd-allhosts", _} ->
{?NS_ADMIN_s ++ "#delete-motd-allhosts", _} ->
if Confirm ->
Proc ! {announce_all_hosts_motd_delete, From, To, Packet},
adhoc:produce_response(Response);
@ -593,79 +593,78 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
{_, []} ->
%% An announce message with no body is definitely an operator error.
%% Throw an error and give him/her a chance to send message again.
{error, ?ERRT_NOT_ACCEPTABLE(
Lang,
"No body provided for announce message")};
{error, exmpp_stanza:error(?NS_JABBER_CLIENT, 'not-acceptable',
{"en", "No body provided for announce message"})};
%% Now send the packet to ?PROCNAME.
%% We don't use direct announce_* functions because it
%% leads to large delay in response and <iq/> queries processing
{?NS_ADMIN ++ "#announce", _} ->
{?NS_ADMIN_s ++ "#announce", _} ->
Proc ! {announce_online, From, To, Packet},
adhoc:produce_response(Response);
{?NS_ADMIN ++ "#announce-allhosts", _} ->
{?NS_ADMIN_s ++ "#announce-allhosts", _} ->
Proc ! {announce_all_hosts_online, From, To, Packet},
adhoc:produce_response(Response);
{?NS_ADMIN ++ "#announce-all", _} ->
{?NS_ADMIN_s ++ "#announce-all", _} ->
Proc ! {announce_all, From, To, Packet},
adhoc:produce_response(Response);
{?NS_ADMIN ++ "#announce-all-allhosts", _} ->
{?NS_ADMIN_s ++ "#announce-all-allhosts", _} ->
Proc ! {announce_all_hosts_all, From, To, Packet},
adhoc:produce_response(Response);
{?NS_ADMIN ++ "#set-motd", _} ->
{?NS_ADMIN_s ++ "#set-motd", _} ->
Proc ! {announce_motd, From, To, Packet},
adhoc:produce_response(Response);
{?NS_ADMIN ++ "#set-motd-allhosts", _} ->
{?NS_ADMIN_s ++ "#set-motd-allhosts", _} ->
Proc ! {announce_all_hosts_motd, From, To, Packet},
adhoc:produce_response(Response);
{?NS_ADMIN ++ "#edit-motd", _} ->
{?NS_ADMIN_s ++ "#edit-motd", _} ->
Proc ! {announce_motd_update, From, To, Packet},
adhoc:produce_response(Response);
{?NS_ADMIN ++ "#edit-motd-allhosts", _} ->
{?NS_ADMIN_s ++ "#edit-motd-allhosts", _} ->
Proc ! {announce_all_hosts_motd_update, From, To, Packet},
adhoc:produce_response(Response);
_ ->
%% This can't happen, as we haven't registered any other
%% command nodes.
{error, ?ERR_INTERNAL_SERVER_ERROR}
{error, 'internal-server-error'}
end.
get_title(Lang, "announce") ->
translate:translate(Lang, "Announcements");
get_title(Lang, ?NS_ADMIN ++ "#announce-all") ->
get_title(Lang, ?NS_ADMIN_s ++ "#announce-all") ->
translate:translate(Lang, "Send announcement to all users");
get_title(Lang, ?NS_ADMIN ++ "#announce-all-allhosts") ->
get_title(Lang, ?NS_ADMIN_s ++ "#announce-all-allhosts") ->
translate:translate(Lang, "Send announcement to all users on all hosts");
get_title(Lang, ?NS_ADMIN ++ "#announce") ->
get_title(Lang, ?NS_ADMIN_s ++ "#announce") ->
translate:translate(Lang, "Send announcement to all online users");
get_title(Lang, ?NS_ADMIN ++ "#announce-allhosts") ->
get_title(Lang, ?NS_ADMIN_s ++ "#announce-allhosts") ->
translate:translate(Lang, "Send announcement to all online users on all hosts");
get_title(Lang, ?NS_ADMIN ++ "#set-motd") ->
get_title(Lang, ?NS_ADMIN_s ++ "#set-motd") ->
translate:translate(Lang, "Set message of the day and send to online users");
get_title(Lang, ?NS_ADMIN ++ "#set-motd-allhosts") ->
get_title(Lang, ?NS_ADMIN_s ++ "#set-motd-allhosts") ->
translate:translate(Lang, "Set message of the day on all hosts and send to online users");
get_title(Lang, ?NS_ADMIN ++ "#edit-motd") ->
get_title(Lang, ?NS_ADMIN_s ++ "#edit-motd") ->
translate:translate(Lang, "Update message of the day (don't send)");
get_title(Lang, ?NS_ADMIN ++ "#edit-motd-allhosts") ->
get_title(Lang, ?NS_ADMIN_s ++ "#edit-motd-allhosts") ->
translate:translate(Lang, "Update message of the day on all hosts (don't send)");
get_title(Lang, ?NS_ADMIN ++ "#delete-motd") ->
get_title(Lang, ?NS_ADMIN_s ++ "#delete-motd") ->
translate:translate(Lang, "Delete message of the day");
get_title(Lang, ?NS_ADMIN ++ "#delete-motd-allhosts") ->
get_title(Lang, ?NS_ADMIN_s ++ "#delete-motd-allhosts") ->
translate:translate(Lang, "Delete message of the day on all hosts").
%%-------------------------------------------------------------------------
announce_all(From, To, Packet) ->
Host = To#jid.lserver,
Host = To#jid.ldomain,
Access = gen_mod:get_module_opt(Host, ?MODULE, access, none),
case acl:match_rule(Host, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
Local = jlib:make_jid("", To#jid.server, ""),
Local = exmpp_jid:make_jid(To#jid.domain),
lists:foreach(
fun({User, Server}) ->
Dest = jlib:make_jid(User, Server, ""),
Dest = exmpp_jid:make_jid(User, Server),
ejabberd_router:route(Local, Dest, Packet)
end, ejabberd_auth:get_vh_registered_users(Host))
end.
@ -674,27 +673,27 @@ announce_all_hosts_all(From, To, Packet) ->
Access = gen_mod:get_module_opt(global, ?MODULE, access, none),
case acl:match_rule(global, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
Local = jlib:make_jid("", To#jid.server, ""),
Local = exmpp_jid:make_jid(To#jid.domain),
lists:foreach(
fun({User, Server}) ->
Dest = jlib:make_jid(User, Server, ""),
Dest = exmpp_jid:make_jid(User, Server),
ejabberd_router:route(Local, Dest, Packet)
end, ejabberd_auth:dirty_get_registered_users())
end.
announce_online(From, To, Packet) ->
Host = To#jid.lserver,
Host = To#jid.ldomain,
Access = gen_mod:get_module_opt(Host, ?MODULE, access, none),
case acl:match_rule(Host, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
announce_online1(ejabberd_sm:get_vh_session_list(Host),
To#jid.server,
To#jid.domain,
Packet)
end.
@ -702,28 +701,28 @@ announce_all_hosts_online(From, To, Packet) ->
Access = gen_mod:get_module_opt(global, ?MODULE, access, none),
case acl:match_rule(global, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
announce_online1(ejabberd_sm:dirty_get_sessions_list(),
To#jid.server,
To#jid.domain,
Packet)
end.
announce_online1(Sessions, Server, Packet) ->
Local = jlib:make_jid("", Server, ""),
Local = exmpp_jid:make_jid(Server),
lists:foreach(
fun({U, S, R}) ->
Dest = jlib:make_jid(U, S, R),
Dest = exmpp_jid:make_jid(U, S, R),
ejabberd_router:route(Local, Dest, Packet)
end, Sessions).
announce_motd(From, To, Packet) ->
Host = To#jid.lserver,
Host = To#jid.ldomain,
Access = gen_mod:get_module_opt(Host, ?MODULE, access, none),
case acl:match_rule(Host, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
announce_motd(Host, Packet)
@ -733,7 +732,7 @@ announce_all_hosts_motd(From, To, Packet) ->
Access = gen_mod:get_module_opt(global, ?MODULE, access, none),
case acl:match_rule(global, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
Hosts = ?MYHOSTS,
@ -753,11 +752,11 @@ announce_motd(Host, Packet) ->
mnesia:transaction(F).
announce_motd_update(From, To, Packet) ->
Host = To#jid.lserver,
Host = To#jid.ldomain,
Access = gen_mod:get_module_opt(Host, ?MODULE, access, none),
case acl:match_rule(Host, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
announce_motd_update(Host, Packet)
@ -767,7 +766,7 @@ announce_all_hosts_motd_update(From, To, Packet) ->
Access = gen_mod:get_module_opt(global, ?MODULE, access, none),
case acl:match_rule(global, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
Hosts = ?MYHOSTS,
@ -782,11 +781,11 @@ announce_motd_update(LServer, Packet) ->
mnesia:transaction(F).
announce_motd_delete(From, To, Packet) ->
Host = To#jid.lserver,
Host = To#jid.ldomain,
Access = gen_mod:get_module_opt(Host, ?MODULE, access, none),
case acl:match_rule(Host, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
announce_motd_delete(Host)
@ -796,7 +795,7 @@ announce_all_hosts_motd_delete(From, To, Packet) ->
Access = gen_mod:get_module_opt(global, ?MODULE, access, none),
case acl:match_rule(global, Access, From) of
deny ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
Err = exmpp_stanza:reply_with_error(Packet, 'forbidden'),
ejabberd_router:route(To, From, Err);
allow ->
Hosts = ?MYHOSTS,
@ -818,7 +817,7 @@ announce_motd_delete(LServer) ->
end,
mnesia:transaction(F).
send_motd(#jid{luser = LUser, lserver = LServer} = JID) ->
send_motd(#jid{lnode = LUser, ldomain = LServer} = JID) ->
case catch mnesia:dirty_read({motd, LServer}) of
[#motd{packet = Packet}] ->
US = {LUser, LServer},
@ -826,7 +825,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID) ->
[#motd_users{}] ->
ok;
_ ->
Local = jlib:make_jid("", LServer, ""),
Local = exmpp_jid:make_jid(LServer),
ejabberd_router:route(Local, JID, Packet),
F = fun() ->
mnesia:write(#motd_users{us = US})
@ -840,8 +839,8 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID) ->
get_stored_motd(LServer) ->
case catch mnesia:dirty_read({motd, LServer}) of
[#motd{packet = Packet}] ->
{xml:get_subtag_cdata(Packet, "subject"),
xml:get_subtag_cdata(Packet, "body")};
{exmpp_xml:get_cdata_as_list(exmpp_xml:get_element_by_name(Packet, 'subject')),
exmpp_xml:get_cdata_as_list(exmpp_xml:get_element_by_name(Packet, 'body'))};
_ ->
{"", ""}
end.

File diff suppressed because it is too large Load Diff