diff options
author | HAMANO Tsukasa <code@cuspy.org> | 2015-02-11 01:09:03 +0900 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2015-03-26 14:00:34 +0100 |
commit | 9a64bfe605d770e04aee960005ea15d797ea2f89 (patch) | |
tree | 480d70d7426b887afadf2269baa61f44b9fcfc2f /src | |
parent | fix mod_admin_extra stats command (diff) |
add send_message_normal command
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_admin_extra.erl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index 5d69d664b..238bf274b 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -29,6 +29,8 @@ -behaviour(gen_mod). +-include("logger.hrl"). + -export([start/2, stop/1, %% Node compile/1, @@ -84,6 +86,7 @@ srg_user_del/4, %% Stanza send_message_headline/4, + send_message_normal/4, send_message_chat/3, send_stanza_c2s/4, privacy_set/3, @@ -518,6 +521,12 @@ commands() -> args = [{from, binary}, {to, binary}, {subject, binary}, {body, binary}], 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], desc = "Send a stanza as if sent from a c2s session", module = ?MODULE, function = send_stanza_c2s, @@ -1348,6 +1357,12 @@ send_message_headline(From, To, Subject, Body) -> Packet = build_packet(message_headline, [Subject, Body]), 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. %% If a resource was specified in the JID, %% the packet is sent only to that specific resource. @@ -1397,6 +1412,13 @@ build_packet(message_headline, [Subject, Body]) -> [{xmlel, <<"subject">>, [], [{xmlcdata, Subject}]}, {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) -> |