REQ-3284: 推送

This commit is contained in:
yanglin 2024-11-20 14:56:05 +08:00
parent 876ec519aa
commit b2765b5e04
7 changed files with 104 additions and 3 deletions

View File

@ -1,11 +1,13 @@
package cn.axzo.msg.center.message.controller;
import cn.axzo.msg.center.api.MNSNoticesApi;
import cn.axzo.msg.center.api.MessageAPIV3;
import cn.axzo.msg.center.api.MessageAPIV4;
import cn.axzo.msg.center.api.request.AddMnsChannelRequest;
import cn.axzo.msg.center.api.request.MnsSendCodeV2Req;
import cn.axzo.msg.center.api.request.SendMessageRequestDto;
import cn.axzo.msg.center.api.request.UpdateMnsTemplateContentRequest;
import cn.axzo.msg.center.api.request.v3.MessageSendReqV3;
import cn.axzo.msg.center.api.request.v3.SearchMessageReqV3;
import cn.axzo.msg.center.api.request.v3.SearchPendingMessageReq;
import cn.axzo.msg.center.api.request.v3.SearchTodoLogReq;
@ -61,6 +63,7 @@ public class PrivateMessageController {
private final MessageRecordServiceV3 messageRecordServiceV3;
private final MessageAPIV4 messageAPIV4;
private final MessageAPIV3 messageAPIV3;
private final TodoSearchService todoSearchService;
private final TodoManager todoManager;
private final GroupTemplateService groupTemplateService;
@ -92,6 +95,12 @@ public class PrivateMessageController {
return messageAPIV4.send(request);
}
@PostMapping("/sendByEventMappingV3")
@EnableResponseAdvice(enable = false)
public Object sendByEventMappingV3(@RequestBody @Valid MessageSendReqV3 request) {
return messageAPIV3.send(request);
}
@PostMapping("/searchImRecord")
@EnableResponseAdvice(enable = false)
public Object searchImRecord(@RequestBody @Valid SearchMessageReqV3 req) {

View File

@ -0,0 +1,18 @@
package cn.axzo.msg.center.nimpush.payload;
import cn.axzo.msg.center.nimpush.PushMessageContent;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
/**
* @author yanglin
*/
@Component
public class MZPushPayloadBuilder implements PushPayloadBuilder {
@Override
public void build(PushMessageContent message, JSONObject payload) {
// NOP
}
}

View File

@ -0,0 +1,33 @@
package cn.axzo.msg.center.nimpush.payload;
import cn.axzo.msg.center.inside.notices.config.PushProps;
import cn.axzo.msg.center.nimpush.PushMessageContent;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
/**
* @author yanglin
*/
@Component
@RequiredArgsConstructor
public class OppoPushPayloadBuilder implements PushPayloadBuilder {
private final PushProps pushProps;
@Override
public void build(PushMessageContent message, JSONObject payload) {
PushProps.ChannelConfig xmCfg = pushProps.getOppoChannelConfig();
JSONObject oppoField = new JSONObject();
oppoField.put("style", 1);
oppoField.put("network_type", 0);
oppoField.put("channel_id", message.determineChannelId(xmCfg));
if (message.hasAndroidPushUrl()) {
oppoField.put("click_action_type", 2);
oppoField.put("click_action_url", message.getAndroidPushUrl());
}
payload.put("oppoField", oppoField);
}
}

View File

@ -15,6 +15,7 @@ public class PGPushPayloadBuilder implements PushPayloadBuilder {
@Override
public void build(PushMessageContent message, JSONObject payload) {
JSONObject userInfo = new JSONObject();
// router为自定义的字段
userInfo.put("router", message.getIosPushUrl());
JSONObject alert = new JSONObject();

View File

@ -21,9 +21,14 @@ public class RYPushPayloadBuilder implements PushPayloadBuilder {
clickAction.put("url", message.getAndroidPushUrl());
// 通知的内容
JSONObject honorField = new JSONObject();
JSONObject notification = new JSONObject();
notification.put("title", message.getTitle());
notification.put("body", message.getContent());
if (message.hasAndroidPushUrl())
honorField.put("clickAction", clickAction);
notification.put("clickAction", clickAction);
JSONObject honorField = new JSONObject();
honorField.put("notification", notification);
payload.put("honorField", honorField);
}

View File

@ -0,0 +1,33 @@
package cn.axzo.msg.center.nimpush.payload;
import cn.axzo.msg.center.nimpush.PushMessageContent;
import cn.axzo.msg.center.nimpush.PushMessageTye;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
/**
* VIVO
*
* @author yanglin
*/
@Component
public class VivoPushPayloadBuilder implements PushPayloadBuilder {
/**
* 没找到自定义声音相关的字段
*/
@Override
public void build(PushMessageContent message, JSONObject payload) {
JSONObject vivoField = new JSONObject();
vivoField.put("content", message.getContent());
vivoField.put("classification",
message.getMessageTye() == PushMessageTye.OP ? "0" : "1");
if (message.hasAndroidPushUrl()) {
vivoField.put("skipType", "3");
vivoField.put("skipContent", message.getAndroidPushUrl());
}
payload.put("vivoField", vivoField);
}
}

View File

@ -23,8 +23,10 @@ public class XMPushPayloadBuilder implements PushPayloadBuilder {
payload.put("channel_id", message.determineChannelId(xmCfg));
if (message.hasCustomSoundFile())
payload.put("sound", message.getCustomSoundFile());
if (message.hasAndroidPushUrl())
if (message.hasAndroidPushUrl()) {
payload.put("intent_uri", message.getAndroidPushUrl());
payload.put("web_uri", message.getAndroidPushUrl());
}
}
}