Commit f19303c1 by 罗长华

增加禁止发送图片的判断

parent 54743aa0
......@@ -79,3 +79,5 @@ api.response.code.REPETITION_CONVERSATION=已有会话,不能重复创建会话
api.response.code.CLIENT_NOT_FOUNT=成员不存在,不能创建会话
api.response.code.IS_BE_BLACK=被对方拉黑
api.response.code.IS_TO_BLACK=你把对方拉黑
api.response.code.IS_BE_FORBID_SEND_LINK=????????
api.response.code.IS_BE_FORBID_SEND_PIC=????????
......@@ -144,7 +144,7 @@ public class NormalChatAction {
return;
}
// 消息内容校验
if (checkMsg(conversation, reqId, data, request.getSenderChannel())) {
if (!checkMsg(conversation, reqId, data, request.getSenderChannel())) {
return;
}
......@@ -415,30 +415,34 @@ public class NormalChatAction {
return false;
}
}
// 判断是否开启禁止发送链接
if (conversation.getForbidSendLink()) {
String regex = "((ht|f)tp(s?)\\:\\/\\/)?[0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*." +
"(html|htm|shtml|jsp|asp|php|com|cn|net|com.cn|org|vip)+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\.\\?\\," +
"\\'\\/\\\\&%\\+\\$#_=]*)?";
Pattern pat = Pattern.compile(regex);
Matcher mat = pat.matcher(msgContent.trim());
result = mat.find();
}
if (MsgTypeEnum.MEDIA_TYPE_TEXT.getUriCode() == data.getType()) {
// 判断是否开启禁止发送链接
if (conversation.getForbidSendLink()) {
String regex = "((ht|f)tp(s?)\\:\\/\\/)?[0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*." +
"(html|htm|shtml|jsp|asp|php|com|cn|net|com.cn|org|vip)+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\.\\?\\," +
"\\'\\/\\\\&%\\+\\$#_=]*)?";
Pattern pat = Pattern.compile(regex);
Matcher mat = pat.matcher(msgContent.trim());
result = mat.find();
}
if (result) {
log.info("群: {}, 已被禁止发送链接", conversation.getName());
// 响应发送方
WsResponse<HashMap<String, Long>> responseModel = new WsResponse<>();
ApiResult<Boolean> apiResult = ApiResult.result(ApiCode.IS_BE_FORBID_SEND_LINK);
responseModel.setCmd(WsResponseCmdEnum.RES.getCmdCode());
responseModel.setCode(apiResult.getCode());
responseModel.setMsg(apiResult.getMessage());
responseModel.setReqId(reqId);
channelSender.sendMsgLocal((NioSocketChannel) channel, responseModel);
return false;
}
if (result) {
log.info("群: {}, 已被禁止发送链接", conversation.getName());
// 响应发送方
WsResponse<HashMap<String, Long>> responseModel = new WsResponse<>();
ApiResult<Boolean> apiResult = ApiResult.result(ApiCode.IS_BE_FORBID_SEND_LINK);
responseModel.setCmd(WsResponseCmdEnum.RES.getCmdCode());
responseModel.setCode(apiResult.getCode());
responseModel.setMsg(apiResult.getMessage());
responseModel.setReqId(reqId);
channelSender.sendMsgLocal((NioSocketChannel) channel, responseModel);
}
return result;
return true;
}
......
package com.wecloud.im.param;
import javax.validation.constraints.NotNull;
import com.wecloud.dispatch.common.BaseRequest;
import com.wecloud.im.ws.model.request.PushVO;
import com.wecloud.utils.JsonUtils;
import javax.validation.constraints.NotNull;
/**
* @Description 聊天内容
* @Author lixiaozhong
......@@ -70,7 +70,7 @@ public class ChatContentVo extends BaseRequest {
}
public String getText() {
return this.get("type") + "";
return this.get("text") + "";
}
......
......@@ -150,7 +150,7 @@ public enum ApiCode {
/**
* 群已禁止发图片
*/
IS_BE_FORBID_SEND_PIC(6018, "api.response.code.IS_BE_FORBID_SEND_LINK"),
IS_BE_FORBID_SEND_PIC(6018, "api.response.code.IS_BE_FORBID_SEND_PIC"),
;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment