25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Copy recent make_opts function from mod_muc_room.erl

This commit is contained in:
Badlop 2016-12-09 13:07:48 +01:00
parent bcc04d93e1
commit 1a4f63f058

View File

@ -993,38 +993,50 @@ get_subscribers(Name, Host) ->
throw({error, "The room does not exist"}) throw({error, "The room does not exist"})
end. end.
%% Copied from mod_muc_room.erl
get_config_opt_name(Pos) ->
Fs = [config|record_info(fields, config)],
lists:nth(Pos, Fs).
-define(MAKE_CONFIG_OPT(Opt),
{get_config_opt_name(Opt), element(Opt, Config)}).
make_opts(StateData) -> make_opts(StateData) ->
Config = StateData#state.config, Config = StateData#state.config,
[ Subscribers = (?DICT):fold(
{title, Config#config.title}, fun(_LJID, Sub, Acc) ->
{vcard, Config#config.vcard}, [{Sub#subscriber.jid,
{voice_request_min_interval, Config#config.voice_request_min_interval}, Sub#subscriber.nick,
{allow_change_subj, Config#config.allow_change_subj}, Sub#subscriber.nodes}|Acc]
{allow_query_users, Config#config.allow_query_users}, end, [], StateData#state.subscribers),
{allow_private_messages, Config#config.allow_private_messages}, [?MAKE_CONFIG_OPT(#config.title), ?MAKE_CONFIG_OPT(#config.description),
{allow_private_messages_from_visitors, Config#config.allow_private_messages_from_visitors}, ?MAKE_CONFIG_OPT(#config.allow_change_subj),
{allow_visitor_status, Config#config.allow_visitor_status}, ?MAKE_CONFIG_OPT(#config.allow_query_users),
{allow_visitor_nickchange, Config#config.allow_visitor_nickchange}, ?MAKE_CONFIG_OPT(#config.allow_private_messages),
{allow_voice_requests, Config#config.allow_voice_requests}, ?MAKE_CONFIG_OPT(#config.allow_private_messages_from_visitors),
{public, Config#config.public}, ?MAKE_CONFIG_OPT(#config.allow_visitor_status),
{public_list, Config#config.public_list}, ?MAKE_CONFIG_OPT(#config.allow_visitor_nickchange),
{persistent, Config#config.persistent}, ?MAKE_CONFIG_OPT(#config.public), ?MAKE_CONFIG_OPT(#config.public_list),
{mam, Config#config.mam}, ?MAKE_CONFIG_OPT(#config.persistent),
{moderated, Config#config.moderated}, ?MAKE_CONFIG_OPT(#config.moderated),
{members_by_default, Config#config.members_by_default}, ?MAKE_CONFIG_OPT(#config.members_by_default),
{members_only, Config#config.members_only}, ?MAKE_CONFIG_OPT(#config.members_only),
{allow_user_invites, Config#config.allow_user_invites}, ?MAKE_CONFIG_OPT(#config.allow_user_invites),
{password_protected, Config#config.password_protected}, ?MAKE_CONFIG_OPT(#config.password_protected),
{password, Config#config.password}, ?MAKE_CONFIG_OPT(#config.captcha_protected),
{anonymous, Config#config.anonymous}, ?MAKE_CONFIG_OPT(#config.password), ?MAKE_CONFIG_OPT(#config.anonymous),
{captcha_protected, Config#config.captcha_protected}, ?MAKE_CONFIG_OPT(#config.logging), ?MAKE_CONFIG_OPT(#config.max_users),
{description, Config#config.description}, ?MAKE_CONFIG_OPT(#config.allow_voice_requests),
{logging, Config#config.logging}, ?MAKE_CONFIG_OPT(#config.allow_subscription),
{max_users, Config#config.max_users}, ?MAKE_CONFIG_OPT(#config.mam),
{affiliations, ?DICT:to_list(StateData#state.affiliations)}, ?MAKE_CONFIG_OPT(#config.presence_broadcast),
?MAKE_CONFIG_OPT(#config.voice_request_min_interval),
?MAKE_CONFIG_OPT(#config.vcard),
{captcha_whitelist,
(?SETS):to_list((StateData#state.config)#config.captcha_whitelist)},
{affiliations,
(?DICT):to_list(StateData#state.affiliations)},
{subject, StateData#state.subject}, {subject, StateData#state.subject},
{subject_author, StateData#state.subject_author} {subject_author, StateData#state.subject_author},
]. {subscribers, Subscribers}].
%%---------------------------- %%----------------------------