add room_id_regexp option
This commit is contained in:
parent
942072cf9d
commit
268f0b30ec
|
@ -597,7 +597,8 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||||
case {Name, Type} of
|
case {Name, Type} of
|
||||||
{<<"presence">>, <<"">>} ->
|
{<<"presence">>, <<"">>} ->
|
||||||
case check_user_can_create_room(ServerHost,
|
case check_user_can_create_room(ServerHost,
|
||||||
AccessCreate, From, Room) of
|
AccessCreate, From, Room) and
|
||||||
|
check_create_roomid(ServerHost, Room) of
|
||||||
true ->
|
true ->
|
||||||
{ok, Pid} = start_new_room(Host, ServerHost, Access,
|
{ok, Pid} = start_new_room(Host, ServerHost, Access,
|
||||||
Room, HistorySize,
|
Room, HistorySize,
|
||||||
|
@ -628,17 +629,22 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||||
end.
|
end.
|
||||||
|
|
||||||
check_user_can_create_room(ServerHost, AccessCreate,
|
check_user_can_create_room(ServerHost, AccessCreate,
|
||||||
From, RoomID) ->
|
From, _RoomID) ->
|
||||||
case acl:match_rule(ServerHost, AccessCreate, From) of
|
case acl:match_rule(ServerHost, AccessCreate, From) of
|
||||||
allow ->
|
allow -> true;
|
||||||
byte_size(RoomID) =<
|
|
||||||
gen_mod:get_module_opt(ServerHost, ?MODULE, max_room_id,
|
|
||||||
fun(infinity) -> infinity;
|
|
||||||
(I) when is_integer(I), I>0 -> I
|
|
||||||
end, infinity);
|
|
||||||
_ -> false
|
_ -> false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
check_create_roomid(ServerHost, RoomID) ->
|
||||||
|
Max = gen_mod:get_module_opt(ServerHost, ?MODULE, max_room_id,
|
||||||
|
fun(infinity) -> infinity;
|
||||||
|
(I) when is_integer(I), I>0 -> I
|
||||||
|
end, infinity),
|
||||||
|
Regexp = gen_mod:get_module_opt(ServerHost, ?MODULE, room_id_regexp,
|
||||||
|
fun iolist_to_binary/1, ""),
|
||||||
|
(byte_size(RoomID) =< Max) and
|
||||||
|
(re:run(RoomID, Regexp, [unicode, {capture, none}]) == match).
|
||||||
|
|
||||||
get_rooms(ServerHost, Host) ->
|
get_rooms(ServerHost, Host) ->
|
||||||
LServer = jid:nameprep(ServerHost),
|
LServer = jid:nameprep(ServerHost),
|
||||||
get_rooms(LServer, Host,
|
get_rooms(LServer, Host,
|
||||||
|
@ -1317,6 +1323,8 @@ mod_opt_type(max_room_id) ->
|
||||||
fun (infinity) -> infinity;
|
fun (infinity) -> infinity;
|
||||||
(I) when is_integer(I), I > 0 -> I
|
(I) when is_integer(I), I > 0 -> I
|
||||||
end;
|
end;
|
||||||
|
mod_opt_type(room_id_regexp) ->
|
||||||
|
fun iolist_to_binary/1;
|
||||||
mod_opt_type(max_room_name) ->
|
mod_opt_type(max_room_name) ->
|
||||||
fun (infinity) -> infinity;
|
fun (infinity) -> infinity;
|
||||||
(I) when is_integer(I), I > 0 -> I
|
(I) when is_integer(I), I > 0 -> I
|
||||||
|
@ -1342,7 +1350,7 @@ mod_opt_type(user_presence_shaper) ->
|
||||||
mod_opt_type(_) ->
|
mod_opt_type(_) ->
|
||||||
[access, access_admin, access_create, access_persistent,
|
[access, access_admin, access_create, access_persistent,
|
||||||
db_type, default_room_options, history_size, host,
|
db_type, default_room_options, history_size, host,
|
||||||
max_room_desc, max_room_id, max_room_name,
|
max_room_desc, max_room_id, max_room_name, room_id_regexp,
|
||||||
max_user_conferences, max_users,
|
max_user_conferences, max_users,
|
||||||
max_users_admin_threshold, max_users_presence,
|
max_users_admin_threshold, max_users_presence,
|
||||||
min_message_interval, min_presence_interval,
|
min_message_interval, min_presence_interval,
|
||||||
|
|
Loading…
Reference in New Issue