mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
parent
909a505d65
commit
9f3ccd604e
@ -468,18 +468,24 @@ announce_commands(From, To,
|
|||||||
sid = SID,
|
sid = SID,
|
||||||
xdata = XData,
|
xdata = XData,
|
||||||
action = Action} = Request) ->
|
action = Action} = Request) ->
|
||||||
ActionIsExecute = Action == execute orelse Action == complete,
|
|
||||||
if Action == cancel ->
|
if Action == cancel ->
|
||||||
%% User cancels request
|
%% User cancels request
|
||||||
#adhoc_command{status = canceled, lang = Lang, node = Node,
|
#adhoc_command{status = canceled, lang = Lang, node = Node,
|
||||||
sid = SID};
|
sid = SID};
|
||||||
XData == undefined, ActionIsExecute ->
|
XData == undefined andalso Action == execute ->
|
||||||
%% User requests form
|
%% User requests form
|
||||||
Form = generate_adhoc_form(Lang, Node, To#jid.lserver),
|
Form = generate_adhoc_form(Lang, Node, To#jid.lserver),
|
||||||
|
xmpp_util:make_adhoc_response(
|
||||||
#adhoc_command{status = executing, lang = Lang, node = Node,
|
#adhoc_command{status = executing, lang = Lang, node = Node,
|
||||||
sid = SID, xdata = Form};
|
sid = SID, xdata = Form});
|
||||||
XData /= undefined, ActionIsExecute ->
|
XData /= undefined andalso (Action == execute orelse Action == complete) ->
|
||||||
handle_adhoc_form(From, To, Request);
|
case handle_adhoc_form(From, To, Request) of
|
||||||
|
ok ->
|
||||||
|
#adhoc_command{lang = Lang, node = Node, sid = SID,
|
||||||
|
status = completed};
|
||||||
|
{error, _} = Err ->
|
||||||
|
Err
|
||||||
|
end;
|
||||||
true ->
|
true ->
|
||||||
Txt = <<"Unexpected action">>,
|
Txt = <<"Unexpected action">>,
|
||||||
{error, xmpp:err_bad_request(Txt, Lang)}
|
{error, xmpp:err_bad_request(Txt, Lang)}
|
||||||
@ -536,7 +542,7 @@ join_lines([], Acc) ->
|
|||||||
|
|
||||||
handle_adhoc_form(From, #jid{lserver = LServer} = To,
|
handle_adhoc_form(From, #jid{lserver = LServer} = To,
|
||||||
#adhoc_command{lang = Lang, node = Node,
|
#adhoc_command{lang = Lang, node = Node,
|
||||||
sid = SessionID, xdata = XData}) ->
|
xdata = XData}) ->
|
||||||
Confirm = case xmpp_util:get_xdata_values(<<"confirm">>, XData) of
|
Confirm = case xmpp_util:get_xdata_values(<<"confirm">>, XData) of
|
||||||
[<<"true">>] -> true;
|
[<<"true">>] -> true;
|
||||||
[<<"1">>] -> true;
|
[<<"1">>] -> true;
|
||||||
@ -544,8 +550,6 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
|
|||||||
end,
|
end,
|
||||||
Subject = join_lines(xmpp_util:get_xdata_values(<<"subject">>, XData)),
|
Subject = join_lines(xmpp_util:get_xdata_values(<<"subject">>, XData)),
|
||||||
Body = join_lines(xmpp_util:get_xdata_values(<<"body">>, XData)),
|
Body = join_lines(xmpp_util:get_xdata_values(<<"body">>, XData)),
|
||||||
Response = #adhoc_command{lang = Lang, node = Node, sid = SessionID,
|
|
||||||
status = completed},
|
|
||||||
Packet = #message{from = From,
|
Packet = #message{from = From,
|
||||||
to = To,
|
to = To,
|
||||||
type = headline,
|
type = headline,
|
||||||
@ -555,17 +559,15 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
|
|||||||
case {Node, Body} of
|
case {Node, Body} of
|
||||||
{?NS_ADMIN_DELETE_MOTD, _} ->
|
{?NS_ADMIN_DELETE_MOTD, _} ->
|
||||||
if Confirm ->
|
if Confirm ->
|
||||||
gen_server:cast(Proc, {announce_motd_delete, Packet}),
|
gen_server:cast(Proc, {announce_motd_delete, Packet});
|
||||||
Response;
|
|
||||||
true ->
|
true ->
|
||||||
Response
|
ok
|
||||||
end;
|
end;
|
||||||
{?NS_ADMIN_DELETE_MOTD_ALLHOSTS, _} ->
|
{?NS_ADMIN_DELETE_MOTD_ALLHOSTS, _} ->
|
||||||
if Confirm ->
|
if Confirm ->
|
||||||
gen_server:cast(Proc, {announce_all_hosts_motd_delete, Packet}),
|
gen_server:cast(Proc, {announce_all_hosts_motd_delete, Packet});
|
||||||
Response;
|
|
||||||
true ->
|
true ->
|
||||||
Response
|
ok
|
||||||
end;
|
end;
|
||||||
{_, <<>>} ->
|
{_, <<>>} ->
|
||||||
%% An announce message with no body is definitely an operator error.
|
%% An announce message with no body is definitely an operator error.
|
||||||
@ -576,29 +578,21 @@ handle_adhoc_form(From, #jid{lserver = LServer} = To,
|
|||||||
%% 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
|
||||||
{?NS_ADMIN_ANNOUNCE, _} ->
|
{?NS_ADMIN_ANNOUNCE, _} ->
|
||||||
gen_server:cast(Proc, {announce_online, Packet}),
|
gen_server:cast(Proc, {announce_online, Packet});
|
||||||
Response;
|
|
||||||
{?NS_ADMIN_ANNOUNCE_ALLHOSTS, _} ->
|
{?NS_ADMIN_ANNOUNCE_ALLHOSTS, _} ->
|
||||||
gen_server:cast(Proc, {announce_all_hosts_online, Packet}),
|
gen_server:cast(Proc, {announce_all_hosts_online, Packet});
|
||||||
Response;
|
|
||||||
{?NS_ADMIN_ANNOUNCE_ALL, _} ->
|
{?NS_ADMIN_ANNOUNCE_ALL, _} ->
|
||||||
gen_server:cast(Proc, {announce_all, Packet}),
|
gen_server:cast(Proc, {announce_all, Packet});
|
||||||
Response;
|
|
||||||
{?NS_ADMIN_ANNOUNCE_ALL_ALLHOSTS, _} ->
|
{?NS_ADMIN_ANNOUNCE_ALL_ALLHOSTS, _} ->
|
||||||
gen_server:cast(Proc, {announce_all_hosts_all, Packet}),
|
gen_server:cast(Proc, {announce_all_hosts_all, Packet});
|
||||||
Response;
|
|
||||||
{?NS_ADMIN_SET_MOTD, _} ->
|
{?NS_ADMIN_SET_MOTD, _} ->
|
||||||
gen_server:cast(Proc, {announce_motd, Packet}),
|
gen_server:cast(Proc, {announce_motd, Packet});
|
||||||
Response;
|
|
||||||
{?NS_ADMIN_SET_MOTD_ALLHOSTS, _} ->
|
{?NS_ADMIN_SET_MOTD_ALLHOSTS, _} ->
|
||||||
gen_server:cast(Proc, {announce_all_hosts_motd, Packet}),
|
gen_server:cast(Proc, {announce_all_hosts_motd, Packet});
|
||||||
Response;
|
|
||||||
{?NS_ADMIN_EDIT_MOTD, _} ->
|
{?NS_ADMIN_EDIT_MOTD, _} ->
|
||||||
gen_server:cast(Proc, {announce_motd_update, Packet}),
|
gen_server:cast(Proc, {announce_motd_update, Packet});
|
||||||
Response;
|
|
||||||
{?NS_ADMIN_EDIT_MOTD_ALLHOSTS, _} ->
|
{?NS_ADMIN_EDIT_MOTD_ALLHOSTS, _} ->
|
||||||
gen_server:cast(Proc, {announce_all_hosts_motd_update, Packet}),
|
gen_server:cast(Proc, {announce_all_hosts_motd_update, Packet});
|
||||||
Response;
|
|
||||||
Junk ->
|
Junk ->
|
||||||
%% This can't happen, as we haven't registered any other
|
%% This can't happen, as we haven't registered any other
|
||||||
%% command nodes.
|
%% command nodes.
|
||||||
|
Loading…
Reference in New Issue
Block a user