敏感词

野火IM内置有敏感词过滤功能,对文本消息的内容进行过滤。为了不影响性能,请保持敏感词在1000个以内。

1. 添加敏感词

1.0.1. 地址

http://domain:18080/admin/sensitive/add

1.0.2. body

参数 类型 必需 描述
words list 敏感词数组

1.0.3. 响应

N/A

1.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"words\":[\"a\",\"b\",\"c\"]}" http://localhost:18080/admin/sensitive/add

{
  "code":0,
  "msg":"success"
}

2. 删除敏感词

2.0.1. 地址

http://domain:18080/admin/sensitive/del

2.0.2. body

参数 类型 必需 描述
words list 敏感词数组

2.0.3. 响应

N/A

2.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"words\":[\"a\",\"b\",\"c\"]}" http://localhost:18080/admin/sensitive/del

{
  "code":0,
  "msg":"success"
}

3. 获取敏感词列表

3.0.1. 地址

http://domain:18080/admin/sensitive/query

3.0.2. body

参数 类型 必需 描述
words list 敏感词数组

3.0.3. 响应

N/A

3.0.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json"  http://localhost:18080/admin/sensitive/query

{
  "code":0,
  "msg":"success"
  "result": {
    "words":[\"a\",\"b\",\"c"]
  }
}

4. 独立敏感词过滤服务

内置敏感词过滤功能只能对文本消息进行敏感词匹配。如果您有高级需求,比如对图片消息/语音消息或其它消息进行过滤。就需要独立的敏感词过滤服务了。这时有两种方法可以处理:

  1. 配置敏感词服务器,在IM服务的配置文件wildfirechat.conf中,配置如下内容

    ## 消息内容审查服务。
    sensitive.remote_server_url http://192.168.3.202:8888/message/censor
    ## 需要进行审查的消息类型
    sensitive.remote_sensitive_message_type 1,2,3
    ## 是否进行等待审核之后才返回客户端
    sensitive.remote_fail_when_matched false
    

    注意处理延时,当remote_fail_when_matched为true时,如果延时过长会导致客户端发送失败。

  2. 使用消息转发功能,把需要过滤类型的消息转发过去,异步处理,如果命中敏感词,再调用撤回方法对消息进行撤回。

2018 © wildfirechat.net 京ICP备18060403号-1 all right reserved,powered by Gitbook该文件修订时间: 2022-08-29 09:42:41

results matching ""

    No results matching ""