After create_room, store in DB if it's persistent (#3632)

This commit is contained in:
Badlop 2021-07-07 17:32:55 +02:00
parent 7e3276f3a8
commit 271a9f097d
1 changed files with 10 additions and 1 deletions

View File

@ -696,7 +696,7 @@ create_room_with_opts(Name1, Host1, ServerHost1, CustomRoomOpts) ->
lists:keysort(1, DefRoomOpts)),
case mod_muc:create_room(Host, Name, RoomOpts) of
ok ->
ok;
maybe_store_room(ServerHost, Host, Name, RoomOpts);
{error, _} ->
throw({error, "Unable to start room"})
end;
@ -705,6 +705,15 @@ create_room_with_opts(Name1, Host1, ServerHost1, CustomRoomOpts) ->
end
end.
maybe_store_room(ServerHost, Host, Name, RoomOpts) ->
case proplists:get_bool(persistent, RoomOpts) of
true ->
{atomic, ok} = mod_muc:store_room(ServerHost, Host, Name, RoomOpts),
ok;
false ->
ok
end.
%% Create the room only in the database.
%% It is required to restart the MUC service for the room to appear.
muc_create_room(ServerHost, {Name, Host, _}, DefRoomOpts) ->