add send_message_normal command
This commit is contained in:
parent
f0b54e1e1a
commit
feac3b1d61
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
|
-include("logger.hrl").
|
||||||
|
|
||||||
-export([start/2, stop/1,
|
-export([start/2, stop/1,
|
||||||
%% Node
|
%% Node
|
||||||
compile/1,
|
compile/1,
|
||||||
|
@ -84,6 +86,7 @@
|
||||||
srg_user_del/4,
|
srg_user_del/4,
|
||||||
%% Stanza
|
%% Stanza
|
||||||
send_message_headline/4,
|
send_message_headline/4,
|
||||||
|
send_message_normal/4,
|
||||||
send_message_chat/3,
|
send_message_chat/3,
|
||||||
send_stanza_c2s/4,
|
send_stanza_c2s/4,
|
||||||
privacy_set/3,
|
privacy_set/3,
|
||||||
|
@ -518,6 +521,12 @@ commands() ->
|
||||||
args = [{from, binary}, {to, binary},
|
args = [{from, binary}, {to, binary},
|
||||||
{subject, binary}, {body, binary}],
|
{subject, binary}, {body, binary}],
|
||||||
result = {res, rescode}},
|
result = {res, rescode}},
|
||||||
|
#ejabberd_commands{name = send_message_normal, tags = [stanza],
|
||||||
|
desc = "Send a normal message to a local or remote bare of full JID",
|
||||||
|
module = ?MODULE, function = send_message_normal,
|
||||||
|
args = [{from, binary}, {to, binary},
|
||||||
|
{subject, binary}, {body, binary}],
|
||||||
|
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",
|
||||||
module = ?MODULE, function = send_stanza_c2s,
|
module = ?MODULE, function = send_stanza_c2s,
|
||||||
|
@ -1348,6 +1357,12 @@ send_message_headline(From, To, Subject, Body) ->
|
||||||
Packet = build_packet(message_headline, [Subject, Body]),
|
Packet = build_packet(message_headline, [Subject, Body]),
|
||||||
send_packet_all_resources(From, To, Packet).
|
send_packet_all_resources(From, To, Packet).
|
||||||
|
|
||||||
|
%% @doc Send a normal message to a Jabber account.
|
||||||
|
%% @spec (From::binary(), To::binary(), Subject::binary(), Body::binary()) -> ok
|
||||||
|
send_message_normal(From, To, Subject, Body) ->
|
||||||
|
Packet = build_packet(message_normal, [Subject, Body]),
|
||||||
|
send_packet_all_resources(From, To, Packet).
|
||||||
|
|
||||||
%% @doc Send a packet to a Jabber account.
|
%% @doc Send a packet to a Jabber account.
|
||||||
%% If a resource was specified in the JID,
|
%% If a resource was specified in the JID,
|
||||||
%% the packet is sent only to that specific resource.
|
%% the packet is sent only to that specific resource.
|
||||||
|
@ -1397,6 +1412,13 @@ build_packet(message_headline, [Subject, Body]) ->
|
||||||
[{xmlel, <<"subject">>, [], [{xmlcdata, Subject}]},
|
[{xmlel, <<"subject">>, [], [{xmlcdata, Subject}]},
|
||||||
{xmlel, <<"body">>, [], [{xmlcdata, Body}]}
|
{xmlel, <<"body">>, [], [{xmlcdata, Body}]}
|
||||||
]
|
]
|
||||||
|
};
|
||||||
|
build_packet(message_normal, [Subject, Body]) ->
|
||||||
|
{xmlel, <<"message">>,
|
||||||
|
[{<<"type">>, <<"normal">>}, {<<"id">>, randoms:get_string()}],
|
||||||
|
[{xmlel, <<"subject">>, [], [{xmlcdata, Subject}]},
|
||||||
|
{xmlel, <<"body">>, [], [{xmlcdata, Body}]}
|
||||||
|
]
|
||||||
}.
|
}.
|
||||||
|
|
||||||
send_stanza_c2s(Username, Host, Resource, Stanza) ->
|
send_stanza_c2s(Username, Host, Resource, Stanza) ->
|
||||||
|
|
Loading…
Reference in New Issue