Commit 9277964a by 罗长华

群主转移后下发事件

parent 5a7afa22
...@@ -354,6 +354,9 @@ public class ImGroupServiceImpl implements ImGroupService { ...@@ -354,6 +354,9 @@ public class ImGroupServiceImpl implements ImGroupService {
@Override @Override
public Boolean groupOwnerTransfer(String groupId, String newGroupOwnerUserId) { public Boolean groupOwnerTransfer(String groupId, String newGroupOwnerUserId) {
Long appId = SecurityUtils.getCurrentAppId();
ImApplication imApplication = applicationService.getCacheById(appId);
ImConversation conversation = imConversationMapper.selectOne(Wrappers.<ImConversation>lambdaQuery().eq(ImConversation::getFkAppid, ImConversation conversation = imConversationMapper.selectOne(Wrappers.<ImConversation>lambdaQuery().eq(ImConversation::getFkAppid,
SecurityUtils.getCurrentAppId()).eq(ImConversation::getId, groupId)); SecurityUtils.getCurrentAppId()).eq(ImConversation::getId, groupId));
if (conversation == null) { if (conversation == null) {
...@@ -363,6 +366,7 @@ public class ImGroupServiceImpl implements ImGroupService { ...@@ -363,6 +366,7 @@ 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,
...@@ -385,6 +389,18 @@ public class ImGroupServiceImpl implements ImGroupService { ...@@ -385,6 +389,18 @@ public class ImGroupServiceImpl implements ImGroupService {
newGroupOwner.setRole(GroupRoleEnum.OWNER.getCode()); newGroupOwner.setRole(GroupRoleEnum.OWNER.getCode());
conversationMembersService.updateById(newGroupOwner); conversationMembersService.updateById(newGroupOwner);
} }
// 操作的client ID
Map<String, Object> content = new HashMap<>();
content.put("operator", newGroupOwner.getClientId());
ImMessage imMessage = MessageBuilder.buildEventMessage(MsgTypeEnum.REMOVE_CLIENT_CONVERSATION, imApplication, oldGroupOwnerClient, conversation, JsonUtils.encodeJson(content));
imMessageService.save(imMessage);
// 发送给在群内的成员
List<ImConversationMembers> existMemberList =
conversationMembersService.list(Wrappers.<ImConversationMembers>lambdaQuery()
.eq(ImConversationMembers::getFkConversationId, conversation.getId()));
conversationService.sendMsgToMembers(conversation, existMemberList, oldGroupOwnerClient, 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