mirror of
https://github.com/processone/ejabberd.git
synced 2024-08-14 01:38:09 +02:00
Remove custom ON command: send_notification/6
This commit is contained in:
parent
5cd3de9cd7
commit
babff870a8
@ -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, _} ->
|
||||
|
Loading…
Reference in New Issue
Block a user