Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
c242ddc7
Commit
c242ddc7
authored
Apr 27, 2022
by
罗长华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加发送消息前检测消息内容是否符合要求
parent
95d3766c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
19 deletions
+99
-19
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+46
-1
core/src/main/java/com/wecloud/im/param/ImConversationQueryVo.java
+12
-0
core/src/main/java/com/wecloud/im/vo/ConversationVo.java
+12
-0
core/src/main/resources/mapper/ImConversationMapper.xml
+24
-18
framework/src/main/java/io/geekidea/springbootplus/framework/common/api/ApiCode.java
+5
-0
No files found.
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
c242ddc7
...
@@ -12,6 +12,8 @@ import java.util.Date;
...
@@ -12,6 +12,8 @@ import java.util.Date;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
...
@@ -140,6 +142,11 @@ public class NormalChatAction {
...
@@ -140,6 +142,11 @@ public class NormalChatAction {
if
(
muted
(
conversation
,
reqId
,
imClientSender
,
membersList
,
request
.
getSenderChannel
()))
{
if
(
muted
(
conversation
,
reqId
,
imClientSender
,
membersList
,
request
.
getSenderChannel
()))
{
return
;
return
;
}
}
// 消息内容校验
if
(
checkMsg
(
conversation
,
reqId
,
data
.
getText
(),
request
.
getSenderChannel
()))
{
return
;
}
ImMessageOnlineSend
imMessageOnlineSend
=
assembleImMessageOnlineSend
(
data
,
imClientSender
,
imApplication
.
getId
());
ImMessageOnlineSend
imMessageOnlineSend
=
assembleImMessageOnlineSend
(
data
,
imClientSender
,
imApplication
.
getId
());
// 再给所有人发 todo 需要改成批量
// 再给所有人发 todo 需要改成批量
...
@@ -378,9 +385,47 @@ public class NormalChatAction {
...
@@ -378,9 +385,47 @@ public class NormalChatAction {
responseModel
.
setCode
(
apiResult
.
getCode
());
responseModel
.
setCode
(
apiResult
.
getCode
());
responseModel
.
setMsg
(
apiResult
.
getMessage
());
responseModel
.
setMsg
(
apiResult
.
getMessage
());
responseModel
.
setReqId
(
reqId
);
responseModel
.
setReqId
(
reqId
);
channelSender
.
sendMsgLocal
((
NioSocketChannel
)
channel
,
responseModel
);
channelSender
.
sendMsgLocal
((
NioSocketChannel
)
channel
,
responseModel
);
}
}
return
result
;
return
result
;
}
}
/**
* 是否禁止发送链接
* @Author luozh
* @Date 2022年04月27日 04:39:04
* @Return
*/
private
boolean
checkMsg
(
ImConversationQueryVo
conversation
,
String
reqId
,
String
msgContent
,
Channel
channel
)
{
boolean
result
=
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
(
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
;
}
}
}
core/src/main/java/com/wecloud/im/param/ImConversationQueryVo.java
View file @
c242ddc7
...
@@ -61,4 +61,16 @@ public class ImConversationQueryVo implements Serializable {
...
@@ -61,4 +61,16 @@ public class ImConversationQueryVo implements Serializable {
*/
*/
@ApiModelProperty
(
"禁言开关 1-未禁言 2-禁言"
)
@ApiModelProperty
(
"禁言开关 1-未禁言 2-禁言"
)
private
Integer
muted
;
private
Integer
muted
;
@ApiModelProperty
(
"禁止互加好友"
)
private
Boolean
forbidAddFriend
;
@ApiModelProperty
(
"禁止发红包"
)
private
Boolean
forbidSendRedPackets
;
@ApiModelProperty
(
"禁止发图片"
)
private
Boolean
forbidSendPic
;
@ApiModelProperty
(
"禁止发链接"
)
private
Boolean
forbidSendLink
;
}
}
core/src/main/java/com/wecloud/im/vo/ConversationVo.java
View file @
c242ddc7
...
@@ -76,4 +76,16 @@ public class ConversationVo implements Serializable {
...
@@ -76,4 +76,16 @@ public class ConversationVo implements Serializable {
@ApiModelProperty
(
"禁言开关 1-未禁言 2-禁言"
)
@ApiModelProperty
(
"禁言开关 1-未禁言 2-禁言"
)
private
Integer
beAtCount
;
private
Integer
beAtCount
;
@ApiModelProperty
(
"禁止互加好友"
)
private
Boolean
forbidAddFriend
;
@ApiModelProperty
(
"禁止发红包"
)
private
Boolean
forbidSendRedPackets
;
@ApiModelProperty
(
"禁止发图片"
)
private
Boolean
forbidSendPic
;
@ApiModelProperty
(
"禁止发链接"
)
private
Boolean
forbidSendLink
;
}
}
core/src/main/resources/mapper/ImConversationMapper.xml
View file @
c242ddc7
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
<!-- 通用查询结果列 -->
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id
id
, create_time, update_time, last_message, member_count, chat_type, fk_appid, creator, name, attributes, system_flag,muted
, create_time, update_time, last_message, member_count, chat_type, fk_appid, creator, name, attributes,
system_flag,muted, is_forbid_add_friend as forbid_add_friend, is_forbid_send_red_packets as forbid_send_red_packets,
is_forbid_send_pic as forbid_send_pic, is_forbid_send_link as forbid_send_link
</sql>
</sql>
<select
id=
"getImConversationById"
resultType=
"com.wecloud.im.param.ImConversationQueryVo"
>
<select
id=
"getImConversationById"
resultType=
"com.wecloud.im.param.ImConversationQueryVo"
>
...
@@ -23,23 +25,27 @@
...
@@ -23,23 +25,27 @@
<select
id=
"getMyImConversationListAndMsgCount"
resultType=
"com.wecloud.im.vo.ConversationVo"
>
<select
id=
"getMyImConversationListAndMsgCount"
resultType=
"com.wecloud.im.vo.ConversationVo"
>
SELECT imConversation.id as id,
SELECT imConversation.id as id,
imConversation.create_time,
imConversation.create_time,
imConversation.`name`,
imConversation.`name`,
imConversation.chat_type,
imConversation.chat_type,
imConversation.member_count,
imConversation.member_count,
imConversation.attributes as attribute,
imConversation.attributes as attribute,
imConversation.system_flag,
imConversation.system_flag,
imConversation.muted as muted,
imConversation.muted as muted,
im_client.client_id AS creator,
imConversation.is_forbid_add_friend as forbid_add_friend,
(SELECT COUNT(im_inbox.id)
imConversation.is_forbid_send_red_packets as forbid_send_red_packets,
FROM im_inbox
imConversation.is_forbid_send_pic as forbid_send_pic,
WHERE im_inbox.fk_conversation_id = imConversation.id
imConversation.is_forbid_send_link as forbid_send_link,
AND im_inbox.receiver = #{currentClientId}
im_client.client_id AS creator,
AND im_inbox.read_msg_status = 0) AS msg_not_read_count,
(SELECT COUNT(im_inbox.id)
(SELECT COUNT(*)
FROM im_inbox
FROM im_inbox INNER JOIN im_message ON im_inbox.fk_msg_id = im_message.id
WHERE im_inbox.fk_conversation_id = imConversation.id
WHERE im_inbox.fk_conversation_id = imConversation.id
AND im_inbox.receiver = #{currentClientId}
AND im_inbox.receiver = #{currentClientId}
AND im_inbox.read_msg_status = 0) AS msg_not_read_count,
(SELECT COUNT(*)
FROM im_inbox INNER JOIN im_message ON im_inbox.fk_msg_id = im_message.id
WHERE im_inbox.fk_conversation_id = imConversation.id
AND im_inbox.receiver = #{currentClientId}
AND im_inbox.read_msg_status = 0
AND im_inbox.read_msg_status = 0
AND (FIND_IN_SET(#{clientId},im_message.`at`) > 0 or FIND_IN_SET('-1',im_message.`at`) > 0)) AS beAtCount,
AND (FIND_IN_SET(#{clientId},im_message.`at`) > 0 or FIND_IN_SET('-1',im_message.`at`) > 0)) AS beAtCount,
(
(
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/common/api/ApiCode.java
View file @
c242ddc7
...
@@ -142,6 +142,11 @@ public enum ApiCode {
...
@@ -142,6 +142,11 @@ public enum ApiCode {
*/
*/
IS_BE_DISBAND
(
6016
,
"api.response.code.IS_BE_DISBAND"
),
IS_BE_DISBAND
(
6016
,
"api.response.code.IS_BE_DISBAND"
),
/**
* 群已禁止发链接
*/
IS_BE_FORBID_SEND_LINK
(
6017
,
"api.response.code.IS_BE_FORBID_SEND_LINK"
),
;
;
private
final
int
code
;
private
final
int
code
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment