Commit 417a65ce by Shadow

Merge remote-tracking branch 'origin/xiaohudou_20220427' into xiaohudou_20220427

parents cc02bc27 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;
} }
...@@ -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);
......
...@@ -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是否一样
......
...@@ -50,4 +50,7 @@ public class ImConversationCreate extends BaseEntity { ...@@ -50,4 +50,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;
} }
...@@ -174,6 +174,12 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -174,6 +174,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);
...@@ -1283,6 +1289,45 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1283,6 +1289,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
...@@ -1306,7 +1351,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1306,7 +1351,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 =
...@@ -1355,7 +1400,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1355,7 +1400,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) {
log.info("存在重复的系统类型会话,返回已存在的系统类型会话id: {}", existConversation.getId()); log.info("存在重复的系统类型会话,返回已存在的系统类型会话id: {}", existConversation.getId());
// 返回已存在的单聊类型会话id // 返回已存在的单聊类型会话id
......
...@@ -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 {
......
...@@ -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>
......
-- 在feature-cluster 2021年12月22日之后,需要执行的的sql增量脚本 -- 在feature-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-否';
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