Deny messages from non-roster users in Openfire

前提是你 提交于 2019-12-23 02:40:47

问题


How do I only allow contacts who are on my roster list to send me messages? Is there any XEP responsible to do that? Or will I need to do this client-side?


回答1:


Yes, OpenFire supports XEP-0016: Privacy Lists (see this question), which can be used to block stanzas according to various criteria.

You can't explicitly block stanzas for contacts not in your roster, but you can block by subscription status none, which can more or less accomplish the same goal. You could send something like this:

<iq from='romeo@example.net/orchard' type='set' id='msg3'>
<query xmlns='jabber:iq:privacy'>
  <list name='message-sub-example'>
    <item type='subscription'
          value='none'
          action='deny'
          order='5'>
      <message/>
    </item>
  </list>
</query>
</iq>

This creates a privacy list called message-sub-example, containing a rule to block any messages from contacts with subscription type none, including contacts not in the roster. For this list to take effect, you need to make it the active list:

<iq from='romeo@example.net/orchard' type='set' id='active1'>
<query xmlns='jabber:iq:privacy'>
  <active name='message-sub-example'/>
</query>
</iq>


来源:https://stackoverflow.com/questions/35487781/deny-messages-from-non-roster-users-in-openfire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!