REQ-3284: 推送
This commit is contained in:
parent
fe721ddf8f
commit
9555db73d8
@ -2,6 +2,7 @@ package cn.axzo.msg.center.inside.notices.service.impl.v3.msg;
|
||||
|
||||
import cn.axzo.framework.jackson.utility.JSON;
|
||||
import cn.axzo.im.center.api.feign.MessageApi;
|
||||
import cn.axzo.im.center.api.vo.ApiChannel;
|
||||
import cn.axzo.im.center.api.vo.req.SendTemplateMessageParam;
|
||||
import cn.axzo.im.center.api.vo.req.SendTemplateMessageParam.ReceivePerson;
|
||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||
@ -178,7 +179,8 @@ public class TemplateMessage {
|
||||
peer.setSenderImAccount(imSenderAccount);
|
||||
peer.setOuId(sample.getReceiverOuId());
|
||||
peer.setWorkspaceId(sample.getReceiverWorkspaceId());
|
||||
return nimPushService.buildPayloadString(parsedModelV3, peer, appType);
|
||||
return nimPushService.buildPayloadString(
|
||||
parsedModelV3, peer, appType, ApiChannel.COMMON_MESSAGE);
|
||||
}
|
||||
|
||||
// ------------------------------- 辅助方法
|
||||
|
||||
@ -2,6 +2,7 @@ package cn.axzo.msg.center.message.service.todo.manage.event;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.im.center.api.feign.MessageApi;
|
||||
import cn.axzo.im.center.api.vo.ApiChannel;
|
||||
import cn.axzo.im.center.api.vo.req.CustomMessageInfo;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageCustomResp;
|
||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||
@ -65,7 +66,7 @@ public class TodoPushSenderV3 implements ApplicationListener<NewTodoEvent> {
|
||||
peer.setOuId(todo.getOuId());
|
||||
peer.setWorkspaceId(todo.getOrgId());
|
||||
String payload = nimPushService.buildPayloadString(
|
||||
parsedModelV3, peer, appType);
|
||||
parsedModelV3, peer, appType, ApiChannel.CUSTOM_MESSAGE);
|
||||
if (StringUtils.isBlank(payload))
|
||||
continue;
|
||||
CustomMessageInfo pushRequest = new CustomMessageInfo();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.nimpush;
|
||||
|
||||
import cn.axzo.im.center.api.vo.ApiChannel;
|
||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||
import cn.axzo.msg.center.common.utils.BizAssertions;
|
||||
import cn.axzo.msg.center.inside.notices.config.PendingMessageBizConfig;
|
||||
@ -38,15 +39,17 @@ public class NimPushService {
|
||||
|
||||
public String buildPayloadString(PushMessage message,
|
||||
PushPeer peer,
|
||||
AppTypeEnum appType) {
|
||||
JSONObject payload = buildPayload(message, peer, appType);
|
||||
AppTypeEnum appType,
|
||||
ApiChannel apiChannel) {
|
||||
JSONObject payload = buildPayload(message, peer, appType, apiChannel);
|
||||
return payload == null ? null : payload.toJSONString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JSONObject buildPayload(PushMessage message,
|
||||
PushPeer peer,
|
||||
AppTypeEnum appType) {
|
||||
AppTypeEnum appType,
|
||||
ApiChannel apiChannel) {
|
||||
if (cfg.getPushChannel() != PushChannel.NIM) return null;
|
||||
PushData pushData = message.getPushData();
|
||||
if (pushData == null || !pushData.isSwitchOn()) return null;
|
||||
@ -59,8 +62,9 @@ public class NimPushService {
|
||||
.findByCode(PushMessageTye.class, pushData.getType())
|
||||
.orElse(null));
|
||||
content.setCustomSoundFile(pushData.getVoiceFile());
|
||||
populateUrl(content, message.getPushUrl(), appType);
|
||||
return buildPayload(content, peer);
|
||||
if (apiChannel == ApiChannel.CUSTOM_MESSAGE)
|
||||
populateUrl(content, message.getPushUrl(), appType);
|
||||
return buildPayload(content, peer, apiChannel);
|
||||
}
|
||||
|
||||
private void populateUrl(PushContent content,
|
||||
@ -95,9 +99,13 @@ public class NimPushService {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private JSONObject buildPayload(PushContent content, PushPeer peer) {
|
||||
private JSONObject buildPayload(PushContent content,
|
||||
PushPeer peer,
|
||||
ApiChannel apiChannel) {
|
||||
Consumer<Intent<?>> intentPopulator = intent -> {
|
||||
intent.setValue(Intent.INTENT_TYPE, IntentValue.CONSTANT_TYPE);
|
||||
intent.setValue(Intent.INTENT_TYPE, apiChannel == ApiChannel.CUSTOM_MESSAGE
|
||||
? IntentValue.TYPE_SERVER
|
||||
: IntentValue.TYPE_IM);
|
||||
intent.setValue(Intent.INTENT_SESSION_TYPE, IntentValue.CONSTANT_SESSION_TYPE);
|
||||
intent.setValue(Intent.INTENT_SESSION_ID, IntentValue.create(peer.getSenderImAccount()));
|
||||
if (peer.getOuId() != null && peer.getOuId() != 0L)
|
||||
|
||||
@ -15,7 +15,8 @@ public class IntentValue {
|
||||
|
||||
private static final IntentValue NULL = new IntentValue(null);
|
||||
public static final IntentValue CONSTANT_SESSION_TYPE = new IntentValue("0");
|
||||
public static final IntentValue CONSTANT_TYPE = new IntentValue("server");
|
||||
public static final IntentValue TYPE_SERVER = new IntentValue("server");
|
||||
public static final IntentValue TYPE_IM = new IntentValue("im");
|
||||
|
||||
public static IntentValue create(Object value) {
|
||||
if (value == null) return NULL;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user