mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Create room on configuration request as per XEP-0045, 10.1.3
This commit is contained in:
parent
6a3691ef7c
commit
a915fd161e
@ -385,8 +385,8 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
{Room, _, Nick} = jid:tolower(To),
|
||||
case mnesia:dirty_read(muc_online_room, {Room, Host}) of
|
||||
[] ->
|
||||
case Packet of
|
||||
#presence{type = available, lang = Lang} ->
|
||||
case is_create_request(Packet) of
|
||||
true ->
|
||||
case check_user_can_create_room(
|
||||
ServerHost, AccessCreate, From, Room) and
|
||||
check_create_roomid(ServerHost, Room) of
|
||||
@ -399,12 +399,13 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
mod_muc_room:route(Pid, From, Nick, Packet),
|
||||
ok;
|
||||
false ->
|
||||
Lang = xmpp:get_lang(Packet),
|
||||
ErrText = <<"Room creation is denied by service policy">>,
|
||||
Err = xmpp:make_error(
|
||||
Packet, xmpp:err_forbidden(ErrText, Lang)),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end;
|
||||
_ ->
|
||||
false ->
|
||||
Lang = xmpp:get_lang(Packet),
|
||||
ErrText = <<"Conference room does not exist">>,
|
||||
Err = xmpp:err_item_not_found(ErrText, Lang),
|
||||
@ -501,6 +502,16 @@ process_mucsub(#iq{type = get, from = From, to = To} = IQ) ->
|
||||
RoomJIDs = get_subscribed_rooms(ServerHost, Host, From),
|
||||
xmpp:make_iq_result(IQ, #muc_subscriptions{list = RoomJIDs}).
|
||||
|
||||
-spec is_create_request(stanza()) -> boolean().
|
||||
is_create_request(#presence{type = available}) ->
|
||||
true;
|
||||
is_create_request(#iq{type = set} = IQ) ->
|
||||
xmpp:has_subtag(IQ, #muc_subscribe{});
|
||||
is_create_request(#iq{type = get} = IQ) ->
|
||||
#muc_owner{} == xmpp:get_subtag(IQ, #muc_owner{});
|
||||
is_create_request(_) ->
|
||||
false.
|
||||
|
||||
check_user_can_create_room(ServerHost, AccessCreate,
|
||||
From, _RoomID) ->
|
||||
case acl:match_rule(ServerHost, AccessCreate, From) of
|
||||
|
Loading…
Reference in New Issue
Block a user