mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Create room on configuration request as per XEP-0045, 10.1.3
This commit is contained in:
parent
3803a8de3c
commit
f304149615
@ -488,9 +488,8 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
_ ->
|
||||
case mnesia:dirty_read(muc_online_room, {Room, Host}) of
|
||||
[] ->
|
||||
Type = fxml:get_attr_s(<<"type">>, Attrs),
|
||||
case {Name, Type} of
|
||||
{<<"presence">>, <<"">>} ->
|
||||
case is_create_request(Packet) of
|
||||
true ->
|
||||
case check_user_can_create_room(ServerHost,
|
||||
AccessCreate, From, Room) and
|
||||
check_create_roomid(ServerHost, Room) of
|
||||
@ -508,7 +507,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
Packet, ?ERRT_FORBIDDEN(Lang, ErrText)),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end;
|
||||
_ ->
|
||||
false ->
|
||||
Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
|
||||
ErrText = <<"Conference room does not exist">>,
|
||||
Err = jlib:make_error_reply(Packet,
|
||||
@ -523,6 +522,22 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
end
|
||||
end.
|
||||
|
||||
-spec is_create_request(xmlel()) -> boolean().
|
||||
is_create_request(#xmlel{name = <<"presence">>} = Packet) ->
|
||||
<<"">> == fxml:get_tag_attr_s(<<"type">>, Packet);
|
||||
is_create_request(#xmlel{name = <<"iq">>} = Packet) ->
|
||||
case jlib:iq_query_info(Packet) of
|
||||
#iq{type = set, xmlns = ?NS_MUCSUB,
|
||||
sub_el = #xmlel{name = <<"subscribe">>}} ->
|
||||
true;
|
||||
#iq{type = get, xmlns = ?NS_MUC_OWNER, sub_el = SubEl} ->
|
||||
[] == fxml:remove_cdata(SubEl#xmlel.children);
|
||||
_ ->
|
||||
false
|
||||
end;
|
||||
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