Commit f5ad261f by Future

系统通知推送

parent 727aead1
...@@ -37,6 +37,7 @@ import com.wecloud.im.ws.enums.WsResponseCmdEnum; ...@@ -37,6 +37,7 @@ import com.wecloud.im.ws.enums.WsResponseCmdEnum;
import com.wecloud.im.ws.model.WsResponse; import com.wecloud.im.ws.model.WsResponse;
import com.wecloud.im.ws.model.request.PushVO; import com.wecloud.im.ws.model.request.PushVO;
import com.wecloud.im.ws.sender.ChannelSender; import com.wecloud.im.ws.sender.ChannelSender;
import com.wecloud.im.ws.utils.RedisUtils;
import com.wecloud.pushserver.client.model.constant.MqConstant; import com.wecloud.pushserver.client.model.constant.MqConstant;
import com.wecloud.pushserver.client.model.dto.PushDTO; import com.wecloud.pushserver.client.model.dto.PushDTO;
import com.wecloud.utils.JsonUtils; import com.wecloud.utils.JsonUtils;
...@@ -53,6 +54,8 @@ import org.apache.commons.lang3.StringUtils; ...@@ -53,6 +54,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -94,6 +97,8 @@ public class NormalChatAction { ...@@ -94,6 +97,8 @@ public class NormalChatAction {
private MqSender mqSender; private MqSender mqSender;
@Autowired @Autowired
private ImFriendService friendService; private ImFriendService friendService;
@Resource
private RedisUtils redisUtils;
@ActionMapping("/normal/send") @ActionMapping("/normal/send")
@ApiOperation("普通消息发送") @ApiOperation("普通消息发送")
...@@ -186,8 +191,12 @@ public class NormalChatAction { ...@@ -186,8 +191,12 @@ public class NormalChatAction {
} }
// 多线程处理消息下发 // 多线程处理消息下发
for (ImConversationMembers member : membersList) { for (ImConversationMembers member : membersList) {
if (member.getFkClientId().equals(imClientSender.getId())) {
// 不给自己发
return;
}
SendMsgThreadPool.SEND_MSG_THREAD_POOL_EXECUTOR.execute(() -> { SendMsgThreadPool.SEND_MSG_THREAD_POOL_EXECUTOR.execute(() -> {
this.sendMsgToMember(imApplication, member, imClientSender, imMessageOnlineSend, data.getPush()); this.sendMsgToMember(imApplication, member, imMessageOnlineSend, data.getPush());
}); });
} }
...@@ -195,19 +204,20 @@ public class NormalChatAction { ...@@ -195,19 +204,20 @@ public class NormalChatAction {
response(reqId, imMessageOnlineSend.getMsgId(), request.getSenderChannel()); response(reqId, imMessageOnlineSend.getMsgId(), request.getSenderChannel());
} }
private void sendMsgToMember(ImApplication imApplication, ImConversationMembers member, ImClient imClientSender, ImMessageOnlineSend imMessageOnlineSend, PushVO push) { private void sendMsgToMember(ImApplication imApplication, ImConversationMembers member, ImMessageOnlineSend imMessageOnlineSend, PushVO push) {
if (member.getFkClientId().equals(imClientSender.getId())) {
// 不给自己发
return;
}
// 在线用户直接发消息 // 在线用户直接发消息
Boolean sendSuccess = sendMsgForOnline(member.getFkClientId(), imMessageOnlineSend); Boolean sendSuccess = sendMsgForOnline(member.getFkClientId(), imMessageOnlineSend);
if (!sendSuccess && !member.getDoNotDisturb()) { if (!sendSuccess && !member.getDoNotDisturb()) {
// 异步推送系统通知消息 String key = "push_" + member.getFkClientId();
PushDTO pushDTO = mqSender.buildPushDto(push, member.getFkClientId(), member.getClientId(), imApplication); String value = redisUtils.getKey(key);
if (pushDTO != null) { if (StringUtils.isBlank(value)) {
mqSender.orderSend(MqConstant.Topic.IM_ORDER_MSG_TOPIC, MqConstant.Tag.IM_ORDER_MSG_TAG, pushDTO); // 异步推送系统通知消息 2分钟内推一次消息
redisUtils.addKey(key, "1", Duration.ofMinutes(2));
PushDTO pushDTO = mqSender.buildPushDto(push, member.getFkClientId(), member.getClientId(), imApplication);
if (pushDTO != null) {
mqSender.orderSend(MqConstant.Topic.IM_ORDER_MSG_TOPIC, MqConstant.Tag.IM_ORDER_MSG_TAG, pushDTO);
}
} }
} }
} }
...@@ -461,7 +471,6 @@ public class NormalChatAction { ...@@ -461,7 +471,6 @@ public class NormalChatAction {
} }
// 非陌生人 // 非陌生人
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