Commit 755ec6ea by Future

修改会话属性接口调整

parent 79aed1f7
......@@ -67,6 +67,7 @@ public class ConversationAction {
@ActionMapping("/saveOrUpdateAttr")
@ApiOperation(value = "添加或修改会话拓展字段", notes = "权限:所有client都权限操作")
public WsResponse<Map<String, Boolean>> saveOrUpdateAttr(ImConversationAttrUpdate data) {
log.info("添加或修改会话拓展字段 {}", JSON.toJSONString(data));
imConversationService.saveOrUpdateAttr(data);
return WsResponse.ok();
}
......@@ -212,6 +213,7 @@ public class ConversationAction {
@ActionMapping("/info")
@ApiOperation(value = "根据会话id查询指定会话信息", notes = "根据会话id查询指定会话信息 与每个会话的未读条数")
public WsResponse<ConversationVo> info(@Validated ImConversationQueryParam data) throws Exception {
log.info("根据会话id查询指定会话信息 {}", JSON.toJSONString(data));
ConversationVo conversationVo = imConversationService.infoImConversationAndMsgCount(data);
return WsResponse.ok(conversationVo);
}
......@@ -222,7 +224,7 @@ public class ConversationAction {
@ActionMapping("/displayUpdate")
@ApiOperation(value = "批量修改单向隐藏或显示会话", notes = "拉取会话列表不展示已隐藏状态的会话,云端聊天记录不删除;假设有A和B两个用户,A删会话,B还能发; 如果B发了消息,A这边要重新把会话显示出来,并能显示之前的聊天记录")
public WsResponse<Map<String, Boolean>> updateDisplayConversation(ImConversationDisplayUpdate data) throws Exception {
log.info("批量修改单向隐藏或显示会话 {}", JSON.toJSONString(data));
imConversationService.updateDisplayConversation(data);
return WsResponse.ok();
}
......
......@@ -973,13 +973,10 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdateAttr(ImConversationAttrUpdate imConversationAttrUpdate) {
// shiro线程中获取当前token
JwtToken curentJwtToken = JwtUtil.getCurrentJwtToken();
// 根据appKey查询application
ImApplication imApplication = imApplicationService.getCacheAppByAppKey(curentJwtToken.getAppKey());
ImClient imClientSender = imClientService.getCurrentClient();
// 获取当前client
ImClient currentClient = contextService.getImClientIfNotNullOrThrow();
// 根据appId查询application
ImApplication imApplication = contextService.getImApplicationIfNotNullOrThrow(currentClient.getFkAppid());
ImConversation imConversationById = imConversationService.getById(imConversationAttrUpdate.getConversationId());
// 判断是否为群主
......@@ -992,30 +989,22 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
new QueryWrapper<ImConversationMembers>().lambda()
.eq(ImConversationMembers::getFkAppid, imApplication.getId())
.eq(ImConversationMembers::getFkConversationId, imConversationAttrUpdate.getConversationId())
.ne(ImConversationMembers::getFkClientId, imClientSender.getId())
.ne(ImConversationMembers::getFkClientId, currentClient.getId())
);
String attributes = JsonUtils.encodeJson(imConversationAttrUpdate.getAttributes());
imConversationById.setAttributes(attributes);
boolean b = imConversationService.updateById(imConversationById);
// 删除redis中该会话的缓存
deleteCacheImConversationById(imConversationAttrUpdate.getConversationId());
if (b) {
// ws下发拓展字段变动事件
// 内容
HashMap<String, String> content = new HashMap<>();
HashMap<String, String> content = Maps.newHashMap();
content.put("attributes", imConversationById.getAttributes());
// 遍历发送
for (ImConversationMembers conversationMembers : membersList) {
// 查询接收方
ImClient imClientReceiver = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
.eq(ImClient::getFkAppid, imApplication.getId())
......@@ -1023,7 +1012,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
if (imClientReceiver == null) {
continue;
}
// 封装响应的实体
ImMessageOnlineSend imMessageOnlineSend = new ImMessageOnlineSend();
......@@ -1045,7 +1033,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
responseModel.setData(imMessageOnlineSend);
responseModel.setReqId(null);
channelSender.sendMsg(responseModel, imClientReceiver.getId());
}
} else {
......
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