diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-02-16 11:00:26 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-02-16 11:10:24 +0300 |
commit | 8b2d3084986defd6045a0c02706415e0e7ae4b3f (patch) | |
tree | 419b64fc2d07646d221fdfa2f526e057fb34c6d2 /src/mod_muc_admin.erl | |
parent | Merge branch 'master' of github.com:processone/ejabberd (diff) |
Change routing API
Now 'From' and 'To' arguments must be omitted in functions
and structures related to routing.
The commit deprecates the following functions:
ejabberd_router:route/3 in favor of ejabberd_router:route/1
ejabberd_router:route_error/4 in favor of ejabberd_router:route_error/2
ejabberd_local:route_iq/4 in favor of ejabberd_local:route_iq/2
ejabberd_local:route_iq/5 in favor of ejabberd_local:route_iq/3
The format of {route, From, To, Packet} is changed in favor of {route, Packet}
Diffstat (limited to 'src/mod_muc_admin.erl')
-rw-r--r-- | src/mod_muc_admin.erl | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index feaa42b1f..2a6a0bb81 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -730,8 +730,7 @@ get_room_occupants_number(Room, Host) -> send_direct_invitation(RoomName, RoomService, Password, Reason, UsersString) -> RoomJid = jid:make(RoomName, RoomService, <<"">>), - RoomString = jid:to_string(RoomJid), - XmlEl = build_invitation(Password, Reason, RoomString), + XmlEl = build_invitation(Password, Reason, RoomJid), UsersStrings = get_users_to_invite(RoomJid, UsersString), [send_direct_invitation(RoomJid, UserStrings, XmlEl) || UserStrings <- UsersStrings], @@ -759,24 +758,20 @@ get_users_to_invite(RoomJid, UsersString) -> end, UsersStrings). -build_invitation(Password, Reason, RoomString) -> - PasswordAttrList = case Password of - <<"none">> -> []; - _ -> [{<<"password">>, Password}] - end, - ReasonAttrList = case Reason of - <<"none">> -> []; - _ -> [{<<"reason">>, Reason}] - end, - XAttrs = [{<<"xmlns">>, ?NS_XCONFERENCE}, - {<<"jid">>, RoomString}] - ++ PasswordAttrList - ++ ReasonAttrList, - XEl = {xmlel, <<"x">>, XAttrs, []}, - {xmlel, <<"message">>, [], [XEl]}. - -send_direct_invitation(FromJid, UserJid, XmlEl) -> - ejabberd_router:route(FromJid, UserJid, XmlEl). +build_invitation(Password, Reason, RoomJid) -> + Invite = #x_conference{jid = RoomJid, + password = case Password of + <<"none">> -> <<>>; + _ -> Password + end, + reason = case Reason of + <<"none">> -> <<>>; + _ -> Reason + end}, + #message{sub_els = [Invite]}. + +send_direct_invitation(FromJid, UserJid, Msg) -> + ejabberd_router:route(xmpp:set_from_to(Msg, FromJid, UserJid)). %%---------------------------- %% Change Room Option |