From 73dbd34f95f3959b8ffb08cf2699e1bca941af58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Thu, 15 Oct 2020 16:24:50 +0200 Subject: [PATCH] Store room options in create_room_with_opts only if we will start room Previously we could overwrite existing room options and then later return error because room was already started. --- src/mod_muc_admin.erl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index c5b5437f3..8a34f765f 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -640,13 +640,6 @@ create_room_with_opts(Name1, Host1, ServerHost1, CustomRoomOpts) -> lists:keysort(1, FormattedRoomOpts), lists:keysort(1, DefRoomOpts)), - %% Store the room on the server, it is not started yet though at this point - case lists:keyfind(persistent, 1, RoomOpts) of - {persistent, true} -> - mod_muc:store_room(ServerHost, Host, Name, RoomOpts); - _ -> - ok - end, %% Get all remaining mod_muc parameters that might be utilized Access = mod_muc_opt:access(ServerHost), @@ -661,6 +654,13 @@ create_room_with_opts(Name1, Host1, ServerHost1, CustomRoomOpts) -> %% If the room does not exist yet in the muc_online_room case get_room_pid(Name, Host) of room_not_found -> + %% Store the room on the server, it is not started yet though at this point + case lists:keyfind(persistent, 1, RoomOpts) of + {persistent, true} -> + mod_muc:store_room(ServerHost, Host, Name, RoomOpts); + _ -> + ok + end, %% Start the room {ok, Pid} = mod_muc_room:start( Host,