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
7bf40747
Commit
7bf40747
authored
May 31, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加密聊天
parent
800059ef
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
65 additions
and
5 deletions
+65
-5
core/src/main/java/com/wecloud/im/entity/ImConversation.java
+4
-0
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
+1
-1
core/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
+2
-1
core/src/main/java/com/wecloud/im/param/add/ImConversationCreate.java
+3
-0
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+47
-2
core/src/main/java/com/wecloud/im/service/impl/ImRtcRecordServiceImpl.java
+3
-0
core/src/main/resources/mapper/ImConversationMapper.xml
+1
-0
docs/db/feature-cluster增量.sql
+4
-1
No files found.
core/src/main/java/com/wecloud/im/entity/ImConversation.java
View file @
7bf40747
...
@@ -90,4 +90,8 @@ public class ImConversation extends BaseEntity {
...
@@ -90,4 +90,8 @@ public class ImConversation extends BaseEntity {
@TableField
(
"is_forbid_send_link"
)
@TableField
(
"is_forbid_send_link"
)
@ApiModelProperty
(
"禁止发链接"
)
@ApiModelProperty
(
"禁止发链接"
)
private
Boolean
forbidSendLink
;
private
Boolean
forbidSendLink
;
@ApiModelProperty
(
"是否为加密聊天 0-否 1-是"
)
private
Integer
isEncrypt
;
}
}
core/src/main/java/com/wecloud/im/friend/service/ImFriendService.java
View file @
7bf40747
...
@@ -175,7 +175,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
...
@@ -175,7 +175,7 @@ public class ImFriendService extends BaseServiceImpl<ImFriendMapper, ImFriend> {
this
.
updateByKey
(
friend
);
this
.
updateByKey
(
friend
);
}
}
// 检查是否存在会话,如果存在 将会话类型修改为1 单聊 双方都显示
// 检查是否存在会话,如果存在 将会话类型修改为1 单聊 双方都显示
ImConversation
existConversation
=
imConversationMapper
.
getRepetitionConversationSingle
(
currentClient
.
getId
(),
friendClient
.
getId
());
ImConversation
existConversation
=
imConversationMapper
.
getRepetitionConversationSingle
(
currentClient
.
getId
(),
friendClient
.
getId
()
,
0
);
if
(
existConversation
!=
null
&&
ChatTypeEnum
.
TEMP
.
getCode
().
equals
(
existConversation
.
getChatType
()))
{
if
(
existConversation
!=
null
&&
ChatTypeEnum
.
TEMP
.
getCode
().
equals
(
existConversation
.
getChatType
()))
{
existConversation
.
setChatType
(
ChatTypeEnum
.
SINGLE
.
getCode
());
existConversation
.
setChatType
(
ChatTypeEnum
.
SINGLE
.
getCode
());
imConversationMapper
.
updateById
(
existConversation
);
imConversationMapper
.
updateById
(
existConversation
);
...
...
core/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
View file @
7bf40747
...
@@ -63,9 +63,10 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
...
@@ -63,9 +63,10 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
*
*
* @param clientId1
* @param clientId1
* @param clientId2
* @param clientId2
* @param isEncrypt 是否加密会话 1-是 0-否
* @return
* @return
*/
*/
ImConversation
getRepetitionConversationSingle
(
@Param
(
"clientId1"
)
Long
clientId1
,
@Param
(
"clientId2"
)
Long
clientId2
);
ImConversation
getRepetitionConversationSingle
(
@Param
(
"clientId1"
)
Long
clientId1
,
@Param
(
"clientId2"
)
Long
clientId2
,
@Param
(
"isEncrypt"
)
Integer
isEncrypt
);
/**
/**
* 判断重复会话中的Attributes是否一样
* 判断重复会话中的Attributes是否一样
...
...
core/src/main/java/com/wecloud/im/param/add/ImConversationCreate.java
View file @
7bf40747
...
@@ -44,4 +44,7 @@ public class ImConversationCreate extends BaseEntity {
...
@@ -44,4 +44,7 @@ public class ImConversationCreate extends BaseEntity {
@ApiModelProperty
(
"客户端平台: 1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs, 需与生成sign时的值一致"
)
@ApiModelProperty
(
"客户端平台: 1 web, 2 安卓, 3 ios, 4 pc-win, 5 pc-macOs, 需与生成sign时的值一致"
)
private
Integer
platform
;
private
Integer
platform
;
@ApiModelProperty
(
"是否加密聊天: 1-是 0-否"
)
private
Integer
isEncrypt
;
}
}
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
7bf40747
...
@@ -168,6 +168,12 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -168,6 +168,12 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
String
name
=
imConversationCreate
.
getName
();
String
name
=
imConversationCreate
.
getName
();
Map
<
String
,
Object
>
attributes
=
imConversationCreate
.
getAttributes
();
Map
<
String
,
Object
>
attributes
=
imConversationCreate
.
getAttributes
();
List
<
String
>
memberClientIds
=
imConversationCreate
.
getClientIds
();
List
<
String
>
memberClientIds
=
imConversationCreate
.
getClientIds
();
if
(
imConversationCreate
.
getIsEncrypt
()
!=
null
&&
imConversationCreate
.
getIsEncrypt
()
==
1
)
{
ImConversation
conversation
=
this
.
createEncryptedChat
(
createClient
,
memberClientIds
.
get
(
0
),
name
,
attributes
);
ImConversationCreateVo
imConversationCreateVo
=
new
ImConversationCreateVo
();
imConversationCreateVo
.
setId
(
conversation
.
getId
());
}
if
(
ChatTypeEnum
.
CHAT_ROOM
.
getCode
().
equals
(
chatType
))
{
if
(
ChatTypeEnum
.
CHAT_ROOM
.
getCode
().
equals
(
chatType
))
{
// 聊天室
// 聊天室
return
this
.
createChatRoom
(
imConversationCreate
,
createClient
);
return
this
.
createChatRoom
(
imConversationCreate
,
createClient
);
...
@@ -1241,6 +1247,45 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1241,6 +1247,45 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
/**
/**
* 创建加密会话
*
*/
private
ImConversation
createEncryptedChat
(
ImClient
creator
,
String
memberUserId
,
String
name
,
Map
<
String
,
Object
>
attributes
)
{
Long
appId
=
creator
.
getFkAppid
();
ImClient
memberClient
=
imClientService
.
getOne
(
Wrappers
.<
ImClient
>
lambdaQuery
().
eq
(
ImClient:
:
getClientId
,
memberUserId
).
eq
(
ImClient:
:
getFkAppid
,
appId
));
if
(
memberClient
==
null
)
{
log
.
info
(
"成员不存在,不能创建加密会话 clientId:{}"
,
memberUserId
);
throw
new
BusinessException
(
ApiCode
.
CLIENT_NOT_FOUNT
);
}
// 如果存在重复单聊类型会话,则不会为空
ImConversation
existConversation
=
imConversationMapper
.
getRepetitionConversationSingle
(
creator
.
getId
(),
memberClient
.
getId
(),
1
);
if
(
existConversation
!=
null
)
{
// 双方可见
List
<
ImConversationMembers
>
memberList
=
imConversationMembersService
.
list
(
Wrappers
.<
ImConversationMembers
>
lambdaQuery
().
eq
(
ImConversationMembers:
:
getFkConversationId
,
existConversation
.
getId
()));
for
(
ImConversationMembers
members
:
memberList
)
{
members
.
setDisplayStatus
(
1L
);
}
imConversationMembersService
.
updateBatchById
(
memberList
);
log
.
info
(
"存在重复的单聊会话,返回已存在的单聊类型会话id: {}"
,
existConversation
.
getId
());
// 返回已存在的单聊类型会话id
return
existConversation
;
}
// 创建会话
ImConversation
conversation
=
buildConversation
(
creator
,
ChatTypeEnum
.
SINGLE
,
name
,
2
,
attributes
);
conversation
.
setIsEncrypt
(
1
);
// 创建成员
List
<
ImConversationMembers
>
conversationMemberList
=
buildPrivateChatMembers
(
conversation
,
creator
,
memberClient
);
this
.
save
(
conversation
);
this
.
imConversationMembersService
.
saveBatch
(
conversationMemberList
);
return
conversation
;
}
/**
* 创建私聊会话
* 创建私聊会话
* @Author luozh
* @Author luozh
* @Date 2022年05月20日 01:36:33
* @Date 2022年05月20日 01:36:33
...
@@ -1264,7 +1309,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1264,7 +1309,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
// 如果存在重复单聊类型会话,则不会为空
// 如果存在重复单聊类型会话,则不会为空
ImConversation
existConversation
=
imConversationMapper
.
getRepetitionConversationSingle
(
creator
.
getId
(),
memberClient
.
getId
());
ImConversation
existConversation
=
imConversationMapper
.
getRepetitionConversationSingle
(
creator
.
getId
(),
memberClient
.
getId
()
,
0
);
if
(
existConversation
!=
null
)
{
if
(
existConversation
!=
null
)
{
// 双方可见
// 双方可见
List
<
ImConversationMembers
>
memberList
=
List
<
ImConversationMembers
>
memberList
=
...
@@ -1313,7 +1358,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -1313,7 +1358,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
// 如果存在重复单聊类型会话,则不会为空
// 如果存在重复单聊类型会话,则不会为空
ImConversation
existConversation
=
imConversationMapper
.
getRepetitionConversationSingle
(
creator
.
getId
(),
memberClient
.
getId
());
ImConversation
existConversation
=
imConversationMapper
.
getRepetitionConversationSingle
(
creator
.
getId
(),
memberClient
.
getId
()
,
0
);
if
(
existConversation
!=
null
)
{
if
(
existConversation
!=
null
)
{
// 双方可见
// 双方可见
List
<
ImConversationMembers
>
memberList
=
List
<
ImConversationMembers
>
memberList
=
...
...
core/src/main/java/com/wecloud/im/service/impl/ImRtcRecordServiceImpl.java
View file @
7bf40747
...
@@ -16,6 +16,7 @@ import com.wecloud.utils.SnowflakeUtil;
...
@@ -16,6 +16,7 @@ import com.wecloud.utils.SnowflakeUtil;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -34,6 +35,7 @@ public class ImRtcRecordServiceImpl extends BaseServiceImpl<ImRtcRecordMapper, I
...
@@ -34,6 +35,7 @@ public class ImRtcRecordServiceImpl extends BaseServiceImpl<ImRtcRecordMapper, I
private
ImClientService
imClientService
;
private
ImClientService
imClientService
;
@Async
@Override
@Override
public
void
createRtcRecord
(
CreateRtcChannelParam
param
,
Long
channelId
)
{
public
void
createRtcRecord
(
CreateRtcChannelParam
param
,
Long
channelId
)
{
try
{
try
{
...
@@ -59,6 +61,7 @@ public class ImRtcRecordServiceImpl extends BaseServiceImpl<ImRtcRecordMapper, I
...
@@ -59,6 +61,7 @@ public class ImRtcRecordServiceImpl extends BaseServiceImpl<ImRtcRecordMapper, I
* @param channelId
* @param channelId
* @param type 1-同意进入频道 2-拒接进入频道 3-主动挂断(离开频道)
* @param type 1-同意进入频道 2-拒接进入频道 3-主动挂断(离开频道)
*/
*/
@Async
@Override
@Override
public
void
updateRtcRecord
(
Long
channelId
,
Integer
type
)
{
public
void
updateRtcRecord
(
Long
channelId
,
Integer
type
)
{
try
{
try
{
...
...
core/src/main/resources/mapper/ImConversationMapper.xml
View file @
7bf40747
...
@@ -89,6 +89,7 @@
...
@@ -89,6 +89,7 @@
on con.id = mem2.fk_conversation_id and mem2.fk_client_id = #{clientId2}
on con.id = mem2.fk_conversation_id and mem2.fk_client_id = #{clientId2}
where con.chat_type in (1, 5, 6)
where con.chat_type in (1, 5, 6)
and con.member_count = 2
and con.member_count = 2
and con.is_encrypt = #{isEncrypt}
order by con.id asc
order by con.id asc
LIMIT 1
LIMIT 1
</select>
</select>
...
...
docs/db/feature-cluster增量.sql
View file @
7bf40747
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
...
@@ -185,4 +185,7 @@ CREATE TABLE `im_rtc_record`
...
@@ -185,4 +185,7 @@ CREATE TABLE `im_rtc_record`
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'单人音视频聊天记录表'
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'单人音视频聊天记录表'
;
ALTER
TABLE
im_conversation
ADD
COLUMN
`is_encrypt`
tinyint
(
1
)
unsigned
DEFAULT
'0'
COMMENT
'是否加密聊天: 1-是 0-否'
;
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