Commit 938a1950 by 罗长华

修复转移群主时可能报NPE的问题

parent 33c63d9d
...@@ -366,15 +366,15 @@ public class ImGroupServiceImpl implements ImGroupService { ...@@ -366,15 +366,15 @@ public class ImGroupServiceImpl implements ImGroupService {
ImConversationMembers oldGroupOwner = ImConversationMembers oldGroupOwner =
conversationMembersService.getOne(Wrappers.<ImConversationMembers>lambdaQuery().eq(ImConversationMembers::getFkConversationId, conversationMembersService.getOne(Wrappers.<ImConversationMembers>lambdaQuery().eq(ImConversationMembers::getFkConversationId,
conversation.getId()).eq(ImConversationMembers::getRole, GroupRoleEnum.OWNER.getCode())); conversation.getId()).eq(ImConversationMembers::getRole, GroupRoleEnum.OWNER.getCode()));
ImClient oldGroupOwnerClient = clientService.getById(oldGroupOwner.getFkClientId());
// 获取新群主 // 获取新群主
ImConversationMembers newGroupOwner = ImConversationMembers newGroupOwner =
conversationMembersService.getOne(Wrappers.<ImConversationMembers>lambdaQuery().eq(ImConversationMembers::getFkConversationId, conversationMembersService.getOne(Wrappers.<ImConversationMembers>lambdaQuery().eq(ImConversationMembers::getFkConversationId,
conversation.getId()).eq(ImConversationMembers::getClientId, newGroupOwnerUserId)); conversation.getId()).eq(ImConversationMembers::getClientId, newGroupOwnerUserId));
if (newGroupOwner == null) { if (newGroupOwner == null) {
throw new BusinessException("新群主不在该群中"); throw new BusinessException("新群主不在该群中");
} }
ImClient newGroupOwnerClient = clientService.getById(newGroupOwner.getFkClientId());
if (oldGroupOwner != null) { if (oldGroupOwner != null) {
if (oldGroupOwner.getClientId().equals(newGroupOwner.getClientId())) { if (oldGroupOwner.getClientId().equals(newGroupOwner.getClientId())) {
...@@ -393,13 +393,13 @@ public class ImGroupServiceImpl implements ImGroupService { ...@@ -393,13 +393,13 @@ public class ImGroupServiceImpl implements ImGroupService {
// 操作的client ID // 操作的client ID
Map<String, Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
content.put("operator", newGroupOwner.getClientId()); content.put("operator", newGroupOwner.getClientId());
ImMessage imMessage = MessageBuilder.buildEventMessage(MsgTypeEnum.CONVERSATION_NEW_CREATOR, imApplication, oldGroupOwnerClient, conversation, JsonUtils.encodeJson(content)); ImMessage imMessage = MessageBuilder.buildEventMessage(MsgTypeEnum.CONVERSATION_NEW_CREATOR, imApplication, newGroupOwnerClient, conversation, JsonUtils.encodeJson(content));
imMessageService.save(imMessage); imMessageService.save(imMessage);
// 发送给在群内的成员 // 发送给在群内的成员
List<ImConversationMembers> existMemberList = List<ImConversationMembers> existMemberList =
conversationMembersService.list(Wrappers.<ImConversationMembers>lambdaQuery() conversationMembersService.list(Wrappers.<ImConversationMembers>lambdaQuery()
.eq(ImConversationMembers::getFkConversationId, conversation.getId())); .eq(ImConversationMembers::getFkConversationId, conversation.getId()));
conversationService.sendMsgToMembers(conversation, existMemberList, oldGroupOwnerClient, imMessage, content); conversationService.sendMsgToMembers(conversation, existMemberList, newGroupOwnerClient, imMessage, content);
return true; return true;
} }
......
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