fix send-message-chat and send-message-headline commands to work on ejabberd 13
This commit is contained in:
parent
1ae6491e75
commit
f5805ce43e
|
@ -510,13 +510,13 @@ commands() ->
|
||||||
#ejabberd_commands{name = send_message_chat, tags = [stanza],
|
#ejabberd_commands{name = send_message_chat, tags = [stanza],
|
||||||
desc = "Send a chat message to a local or remote bare of full JID",
|
desc = "Send a chat message to a local or remote bare of full JID",
|
||||||
module = ?MODULE, function = send_message_chat,
|
module = ?MODULE, function = send_message_chat,
|
||||||
args = [{from, string}, {to, string}, {body, string}],
|
args = [{from, binary}, {to, binary}, {body, binary}],
|
||||||
result = {res, rescode}},
|
result = {res, rescode}},
|
||||||
#ejabberd_commands{name = send_message_headline, tags = [stanza],
|
#ejabberd_commands{name = send_message_headline, tags = [stanza],
|
||||||
desc = "Send a headline message to a local or remote bare of full JID",
|
desc = "Send a headline message to a local or remote bare of full JID",
|
||||||
module = ?MODULE, function = send_message_headline,
|
module = ?MODULE, function = send_message_headline,
|
||||||
args = [{from, string}, {to, string},
|
args = [{from, binary}, {to, binary},
|
||||||
{subject, string}, {body, string}],
|
{subject, binary}, {body, binary}],
|
||||||
result = {res, rescode}},
|
result = {res, rescode}},
|
||||||
#ejabberd_commands{name = send_stanza_c2s, tags = [stanza],
|
#ejabberd_commands{name = send_stanza_c2s, tags = [stanza],
|
||||||
desc = "Send a stanza as if sent from a c2s session",
|
desc = "Send a stanza as if sent from a c2s session",
|
||||||
|
@ -1408,18 +1408,27 @@ send_packet_all_resources(FromJID, ToU, ToS, ToR, Packet) ->
|
||||||
|
|
||||||
|
|
||||||
build_packet(message_chat, [Body]) ->
|
build_packet(message_chat, [Body]) ->
|
||||||
{xmlelement, "message",
|
#xmlel{name = <<"message">>,
|
||||||
[{"type", "chat"}, {"id", randoms:get_string()}],
|
attrs = [{<<"type">>, <<"chat">>},{<<"id">>, randoms:get_string()}],
|
||||||
[{xmlelement, "body", [], [{xmlcdata, Body}]}]
|
children =
|
||||||
};
|
[#xmlel{name = <<"body">>,
|
||||||
build_packet(message_headline, [Subject, Body]) ->
|
attrs = [],
|
||||||
{xmlelement, "message",
|
children =
|
||||||
[{"type", "headline"}, {"id", randoms:get_string()}],
|
[{xmlcdata, Body}]}]};
|
||||||
[{xmlelement, "subject", [], [{xmlcdata, Subject}]},
|
|
||||||
{xmlelement, "body", [], [{xmlcdata, Body}]}
|
|
||||||
]
|
|
||||||
}.
|
|
||||||
|
|
||||||
|
build_packet(message_headline, [Subject, Body]) ->
|
||||||
|
#xmlel{name = <<"message">>,
|
||||||
|
attrs = [{<<"type">>, <<"headline">>},{<<"id">>, randoms:get_string()}],
|
||||||
|
children =
|
||||||
|
[#xmlel{name = <<"subject">>,
|
||||||
|
attrs = [],
|
||||||
|
children =
|
||||||
|
[{xmlcdata, Subject}]},
|
||||||
|
#xmlel{name = <<"body">>,
|
||||||
|
attrs = [],
|
||||||
|
children =
|
||||||
|
[{xmlcdata, Body}]}]}.
|
||||||
|
|
||||||
send_stanza_c2s(Username, Host, Resource, Stanza) ->
|
send_stanza_c2s(Username, Host, Resource, Stanza) ->
|
||||||
C2sPid = ejabberd_sm:get_session_pid(Username, Host, Resource),
|
C2sPid = ejabberd_sm:get_session_pid(Username, Host, Resource),
|
||||||
XmlEl = xml_stream:parse_element(Stanza),
|
XmlEl = xml_stream:parse_element(Stanza),
|
||||||
|
|
Loading…
Reference in New Issue