从房间配置MUC中删除一些选项

时间:2018-10-23 14:00:40

标签: ejabberd

当所有者加入并且房间和打开房间的配置面板出现很少的配置选项时。

我想从配置面板中删除一些选项,例如

  1. 最大用户数>最大限制为200,但我想将最大限制设置为30,并且该字段不可编辑。 (没有人可以更改30个限制)

    1. 将实际Jid按下-(默认为主持人) 我想将默认值设置为“所有人和字段隐藏”。

    2. 广播存在的角色 (默认选择全部)。只想隐藏此字段。没什么变化。

    3. 让房间主持(只是想隐藏此字段。未选中。)

    4. 默认用户为参与者(只是想隐藏此字段。默认选中)

    5. 允许访问者通过状态广播发送状态文本(只需隐藏此字段即可。未选中)

    6. 允许访问者更改昵称(只是想隐藏此字段。未选中)

    7. 允许访问者发送语音请求(只需取消选中并隐藏此字段)

    8. 允许订阅(只需取消选中并隐藏此字段)

我知道所有这些修改都将在.erl文件中完成,并且我尝试这样做,但是没有任何反应。谁能知道该怎么做。

请帮助。

1 个答案:

答案 0 :(得分:0)

作为服务器管理员,您可以使用以下mod_muc选项在ejabberd.yml中设置默认房间值:default_room_options,请参见https://docs.ejabberd.im/admin/configuration/#mod-muc

然后,您必须修改mod_muc_room.erl以隐藏该字段,并且如果聪明的房间所有者手动添加这些选项,则也不要使用这些选项。稍后,您编译该文件(或所有ejabberd),并安装修改后的mod_muc_room.beam,覆盖旧文件,最后重新启动ejabberd。如果看不到更改,则可能是将梁文件复制到了另一个地方(也许您安装了两个ejabberd,一个正在运行,而另一个又旧又使您感到困惑?)。

我认为此更改包括您想要的所有选项,但最好您进行验证,也许我忘记了一些。我在ejabberd 18.09中尝试了此更改,它在房间配置公式中隐藏了几个选项:

diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 267514b20..a6fc0e73f 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -58,7 +58,7 @@
 -include("mod_muc_room.hrl").

 -define(MAX_USERS_DEFAULT_LIST,
-   [5, 10, 20, 30, 50, 100, 200, 500, 1000, 2000, 5000]).
+   [30]).

 -define(DEFAULT_MAX_USERS_PRESENCE,1000).

@@ -3363,23 +3363,23 @@ get_config(Lang, StateData, From) ->
                     MaxUsersRoom
                     | ?MAX_USERS_DEFAULT_LIST]),
               N =< ServiceMaxUsers]},
-    {whois, if Config#config.anonymous -> moderators;
-           true -> anyone
-        end},
-    {presencebroadcast, Config#config.presence_broadcast},
+    %{whois, if Config#config.anonymous -> moderators;
+   %       true -> anyone
+   %    end},
+    %{presencebroadcast, Config#config.presence_broadcast},
     {membersonly, Config#config.members_only},
-    {moderatedroom, Config#config.moderated},
-    {members_by_default, Config#config.members_by_default},
+    %{moderatedroom, Config#config.moderated},
+    %{members_by_default, Config#config.members_by_default},
     {changesubject, Config#config.allow_change_subj},
     {allow_private_messages, Config#config.allow_private_messages},
     {allow_private_messages_from_visitors,
      Config#config.allow_private_messages_from_visitors},
     {allow_query_users, Config#config.allow_query_users},
     {allowinvites, Config#config.allow_user_invites},
-    {allow_visitor_status, Config#config.allow_visitor_status},
-    {allow_visitor_nickchange, Config#config.allow_visitor_nickchange},
-    {allow_voice_requests, Config#config.allow_voice_requests},
-    {allow_subscription, Config#config.allow_subscription},
+    %{allow_visitor_status, Config#config.allow_visitor_status},
+    %{allow_visitor_nickchange, Config#config.allow_visitor_nickchange},
+    %{allow_voice_requests, Config#config.allow_voice_requests},
+    %{allow_subscription, Config#config.allow_subscription},
     {voice_request_min_interval, Config#config.voice_request_min_interval},
     {pubsub, Config#config.pubsub}]
    ++
@@ -3440,27 +3440,27 @@ set_config(Opts, Config, ServerHost, Lang) ->
          C#config{allow_private_messages = V};
     ({allow_private_messages_from_visitors, V}, C) ->
          C#config{allow_private_messages_from_visitors = V};
-    ({allow_visitor_status, V}, C) -> C#config{allow_visitor_status = V};
-    ({allow_visitor_nickchange, V}, C) ->
-         C#config{allow_visitor_nickchange = V};
+    %({allow_visitor_status, V}, C) -> C#config{allow_visitor_status = V};
+    %({allow_visitor_nickchange, V}, C) ->
+         %C#config{allow_visitor_nickchange = V};
     ({publicroom, V}, C) -> C#config{public = V};
     ({public_list, V}, C) -> C#config{public_list = V};
     ({persistentroom, V}, C) -> C#config{persistent = V};
-    ({moderatedroom, V}, C) -> C#config{moderated = V};
-    ({members_by_default, V}, C) -> C#config{members_by_default = V};
+    %({moderatedroom, V}, C) -> C#config{moderated = V};
+    %({members_by_default, V}, C) -> C#config{members_by_default = V};
     ({membersonly, V}, C) -> C#config{members_only = V};
     ({captcha_protected, V}, C) -> C#config{captcha_protected = V};
     ({allowinvites, V}, C) -> C#config{allow_user_invites = V};
-    ({allow_subscription, V}, C) -> C#config{allow_subscription = V};
+    %({allow_subscription, V}, C) -> C#config{allow_subscription = V};
     ({passwordprotectedroom, V}, C) -> C#config{password_protected = V};
     ({roomsecret, V}, C) -> C#config{password = V};
     ({anonymous, V}, C) -> C#config{anonymous = V};
     ({presencebroadcast, V}, C) -> C#config{presence_broadcast = V};
-    ({allow_voice_requests, V}, C) -> C#config{allow_voice_requests = V};
+    %({allow_voice_requests, V}, C) -> C#config{allow_voice_requests = V};
     ({voice_request_min_interval, V}, C) ->
          C#config{voice_request_min_interval = V};
-    ({whois, moderators}, C) -> C#config{anonymous = true};
-    ({whois, anyone}, C) -> C#config{anonymous = false};
+    %({whois, moderators}, C) -> C#config{anonymous = true};
+    %({whois, anyone}, C) -> C#config{anonymous = false};
     ({maxusers, V}, C) -> C#config{max_users = V};
     ({enablelogging, V}, C) -> C#config{logging = V};
     ({pubsub, V}, C) -> C#config{pubsub = V};

有一个选项禁止访问者更改昵称。如果您希望此选项也禁止参与者,请应用以下更改:

diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 267514b20..16ce21ba1 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -1031,7 +1031,7 @@ do_process_presence(Nick, #presence{from = From, type = available, lang = Lang}
                           StateData#state.host,
                           From, Nick),
              {(StateData#state.config)#config.allow_visitor_nickchange,
-              is_visitor(From, StateData)}} of
+              is_visitor_or_participant(From, StateData)}} of
            {_, _, {false, true}} ->
                Packet1 = Packet#presence{sub_els = [#muc{}]},
                ErrText = <<"Visitors are not allowed to change their "
@@ -1501,6 +1501,11 @@ get_default_role(Affiliation, StateData) ->
 is_visitor(Jid, StateData) ->
     get_role(Jid, StateData) =:= visitor.

+is_visitor_or_participant(Jid, StateData) ->
+    (get_role(Jid, StateData) =:= visitor)
+    or
+    (get_role(Jid, StateData) =:= participant).
+
 -spec is_moderator(jid(), state()) -> boolean().
 is_moderator(Jid, StateData) ->
     get_role(Jid, StateData) =:= moderator.

另一方面,如果要禁止所有角色更改昵称,则更改较小:

diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 267514b20..2ef75e6ed 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -1032,7 +1032,7 @@ do_process_presence(Nick, #presence{from = From, type = available, lang = Lang}
                       From, Nick),
              {(StateData#state.config)#config.allow_visitor_nickchange,
               is_visitor(From, StateData)}} of
-           {_, _, {false, true}} ->
+           {_, _, {false, _}} ->
            Packet1 = Packet#presence{sub_els = [#muc{}]},
            ErrText = <<"Visitors are not allowed to change their "
                    "nicknames in this room">>,