24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-07-14 23:44:18 +02:00

Remove custom ON command: send_notification/6

This commit is contained in:
Badlop 2010-10-19 17:17:55 +02:00
parent 5cd3de9cd7
commit babff870a8

View File

@ -107,7 +107,6 @@
%% Stanza
send_chat/3,
send_message/4,
send_notification/6, %% ON
send_stanza/3
]).
@ -433,14 +432,6 @@ commands() ->
{subject, string}, {body, string}],
result = {res, integer}},
#ejabberd_commands{name = send_notification, tags = [stanza],
desc = "Send ON notification to XMPP client sessions",
module = ?MODULE, function = send_notification,
args = [{send_from, string}, {send_to, string}, {host, string},
{unread_items, string}, {message, string},
{type, string}],
result = {res, integer}},
#ejabberd_commands{name = send_stanza, tags = [stanza],
desc = "Send stanza to a given user",
longdesc = "If Stanza contains a \"from\" field, "
@ -776,35 +767,6 @@ send_message(FromJID, ToJID, Sub, Msg) ->
ejabberd_router:route(From, To, Stanza),
0.
send_notification(SendFromUsername, SendToUsername, Host, UnreadItemsInteger, MessageBody, Type) ->
case get_resources(SendToUsername, Host) of
404 ->
-1;
[] ->
-2;
[A|_] when is_list(A) ->
send_notification_really(SendFromUsername, SendToUsername, Host, UnreadItemsInteger, MessageBody, Type),
0
end.
send_notification_really(SendFromUsername, SendToUsername, Host, UnreadItemsInteger, MessageBody, Type) ->
FromString = Host ++ "/voicemail-notifier",
ToString = SendToUsername ++ "@" ++ Host,
XAttrs = [{"type", Type},
{"send_from", SendFromUsername},
{"unread_items", UnreadItemsInteger}],
XChildren = [{xmlelement, "text", [], [{xmlcdata, MessageBody}]}],
XEl = {xmlelement, "x", XAttrs, XChildren},
Attrs = [{"from", FromString}, {"to", ToString}, {"type", "chat"}],
Children = [XEl],
Stanza = {xmlelement, "message", Attrs, Children},
From = jlib:string_to_jid(FromString),
To = jlib:string_to_jid(ToString),
ejabberd_router:route(From, To, Stanza).
send_stanza(FromJID, ToJID, StanzaStr) ->
case xml_stream:parse_element(StanzaStr) of
{error, _} ->