AccessCreate = gen_mod:get_opt(access_create, Opts),
AccessAdmin = gen_mod:get_opt(access_admin, Opts),
AccessPersistent = gen_mod:get_opt(access_persistent, Opts),
+ AccessMam = gen_mod:get_opt(access_mam, Opts),
HistorySize = gen_mod:get_opt(history_size, Opts),
MaxRoomsDiscoItems = gen_mod:get_opt(max_rooms_discoitems, Opts),
DefRoomOpts = gen_mod:get_opt(default_room_options, Opts),
RoomShaper = gen_mod:get_opt(room_shaper, Opts),
#state{hosts = MyHosts,
server_host = Host,
- access = {Access, AccessCreate, AccessAdmin, AccessPersistent},
+ access = {Access, AccessCreate, AccessAdmin, AccessPersistent, AccessMam},
default_room_opts = DefRoomOpts,
queue_type = QueueType,
history_size = HistorySize,
do_route(Host, ServerHost, Access, HistorySize, RoomShaper,
From, To, Packet, DefRoomOpts, _MaxRoomsDiscoItems, QueueType) ->
- {AccessRoute, _AccessCreate, _AccessAdmin, _AccessPersistent} = Access,
+ {AccessRoute, _AccessCreate, _AccessAdmin, _AccessPersistent, _AccessMam} = Access,
case acl:match_rule(ServerHost, AccessRoute, From) of
allow ->
do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
do_route1(Host, ServerHost, Access, _HistorySize, _RoomShaper,
From, #jid{luser = <<"">>, lresource = <<"">>} = _To,
#message{lang = Lang, body = Body, type = Type} = Packet, _, _) ->
- {_AccessRoute, _AccessCreate, AccessAdmin, _AccessPersistent} = Access,
+ {_AccessRoute, _AccessCreate, AccessAdmin, _AccessPersistent, _AccessMam} = Access,
if Type == error ->
ok;
true ->
ejabberd_router:route_error(Packet, Err);
do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
From, To, Packet, DefRoomOpts, QueueType) ->
- {_AccessRoute, AccessCreate, _AccessAdmin, _AccessPersistent} = Access,
+ {_AccessRoute, AccessCreate, _AccessAdmin, _AccessPersistent, _AccessMam} = Access,
{Room, _, Nick} = jid:tolower(To),
RMod = gen_mod:ram_db_mod(ServerHost, ?MODULE),
case RMod:find_online_room(ServerHost, Room, Host) of
fun acl:access_rules_validator/1;
mod_opt_type(access_persistent) ->
fun acl:access_rules_validator/1;
+mod_opt_type(access_mam) ->
+ fun acl:access_rules_validator/1;
mod_opt_type(access_register) ->
fun acl:access_rules_validator/1;
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
{access_admin, none},
{access_create, all},
{access_persistent, all},
+ {access_mam, all},
{access_register, all},
{db_type, ejabberd_config:default_db(Host, ?MODULE)},
{ram_db_type, ejabberd_config:default_ram_db(Host, ?MODULE)},
AcCreate = gen_mod:get_module_opt(ServerHost, mod_muc, access_create),
AcAdmin = gen_mod:get_module_opt(ServerHost, mod_muc, access_admin),
AcPer = gen_mod:get_module_opt(ServerHost, mod_muc, access_persistent),
+ AcMam = gen_mod:get_module_opt(ServerHost, mod_muc, access_mam),
HistorySize = gen_mod:get_module_opt(ServerHost, mod_muc, history_size),
RoomShaper = gen_mod:get_module_opt(ServerHost, mod_muc, room_shaper),
QueueType = gen_mod:get_module_opt(ServerHost, mod_muc, queue_type),
{ok, Pid} = mod_muc_room:start(
Host,
ServerHost,
- {Access, AcCreate, AcAdmin, AcPer},
+ {Access, AcCreate, AcAdmin, AcPer, AcMam},
Name,
HistorySize,
RoomShaper,
-spec get_service_affiliation(jid(), state()) -> owner | none.
get_service_affiliation(JID, StateData) ->
{_AccessRoute, _AccessCreate, AccessAdmin,
- _AccessPersistent} =
+ _AccessPersistent, _AccessMam} =
StateData#state.access,
case acl:match_rule(StateData#state.server_host,
AccessAdmin, JID)
Options ->
case is_allowed_log_change(Options, StateData, From) andalso
is_allowed_persistent_change(Options, StateData, From) andalso
+ is_allowed_mam_change(Options, StateData, From) andalso
is_allowed_room_name_desc_limits(Options, StateData) andalso
is_password_settings_correct(Options, StateData) of
true ->
false -> true;
true ->
{_AccessRoute, _AccessCreate, _AccessAdmin,
- AccessPersistent} =
+ AccessPersistent, _AccessMam} =
StateData#state.access,
allow ==
acl:match_rule(StateData#state.server_host,
AccessPersistent, From)
end.
+-spec is_allowed_mam_change(muc_roomconfig:result(), state(), jid()) -> boolean().
+is_allowed_mam_change(Options, StateData, From) ->
+ case proplists:is_defined(mam, Options) of
+ false -> true;
+ true ->
+ {_AccessRoute, _AccessCreate, _AccessAdmin,
+ _AccessPersistent, AccessMam} =
+ StateData#state.access,
+ allow ==
+ acl:match_rule(StateData#state.server_host,
+ AccessMam, From)
+ end.
+
%% Check if the Room Name and Room Description defined in the Data Form
%% are conformant to the configured limits
-spec is_allowed_room_name_desc_limits(muc_roomconfig:result(), state()) -> boolean().
-spec get_config(binary(), state(), jid()) -> xdata().
get_config(Lang, StateData, From) ->
- {_AccessRoute, _AccessCreate, _AccessAdmin, AccessPersistent} =
+ {_AccessRoute, _AccessCreate, _AccessAdmin, AccessPersistent, _AccessMam} =
StateData#state.access,
ServiceMaxUsers = get_service_max_users(StateData),
DefaultRoomMaxUsers = get_default_room_maxusers(StateData),