发送IM模版消息时, 支持设置发送时间

This commit is contained in:
yanglin 2024-08-19 11:33:09 +08:00
parent c4ef37f291
commit d67d1ca3c7
5 changed files with 45 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package cn.axzo.msg.center.inside.notices.service.impl.v3;
import cn.axzo.msg.center.api.request.v3.ImSendInfo;
import cn.axzo.msg.center.api.request.v3.MessageSendReqV3;
import cn.axzo.msg.center.api.request.v3.PendingSendInfo;
import cn.axzo.msg.center.api.response.v3.MessageSendRespV3;
@ -33,11 +34,15 @@ public class MessageServiceV3Impl implements MessageServiceV3 {
PendingSendInfo pendingInfo = request.getChannelParam(
MessageSendReqV3.CHANNEL_PENDING, PendingSendInfo.class);
messageSendRequest.put("pendingSendInfo", pendingInfo);
// 4. 构建event-hub的请求
// 4. 设置发送IM消息的信息
ImSendInfo imSendInfo = request.getChannelParam(
MessageSendReqV3.CHANNEL_IM, ImSendInfo.class);
messageSendRequest.put("imSendInfo", imSendInfo);
// 5. 构建event-hub的请求
JSONObject performActionRequest = new JSONObject();
performActionRequest.put("eventCode", request.getBizEventMappingCode());
performActionRequest.put("messageSendRequest", messageSendRequest);
// 5. 调用event-hub的接口
// 6. 调用event-hub的接口
JSONObject response = actionClient.performAction(performActionRequest);
log.info("actionClient.performAction, request={}, resp={}", performActionRequest, response);
BizAssertions.assertTrue(response.getIntValue("code") == 200, response.getString("msg"));

View File

@ -143,6 +143,9 @@ public class TemplateMessage {
}
}
imReq.setReceivePersons(receivers);
if (req.getImSendInfo() != null) {
imReq.setPlanStartTime(req.getImSendInfo().getPlanStartTime());
}
// 扩展信息
JSONObject ext = new JSONObject();
ext.put("minAppVersion", template.getMinAppVersion());

View File

@ -0,0 +1,23 @@
package cn.axzo.msg.center.api.request.v3;
import lombok.Getter;
import lombok.Setter;
import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.Date;
/**
* @author yanglin
*/
@Setter
@Getter
public class ImSendInfo implements Serializable {
/**
* 计算发送时间
*/
@Nullable
private Date planStartTime;
}

View File

@ -29,6 +29,11 @@ public class MessageSendReqV3 implements Serializable {
*/
public static final String CHANNEL_PENDING = "channel_pending";
/**
* 发送IM消息时, channelParams key, 传值 {@link ImSendInfo}
*/
public static final String CHANNEL_IM = "channel_im";
/**
* 发起者
* <p>如果是平台则发起人为空

View File

@ -1,5 +1,6 @@
package cn.axzo.msg.center.api.request.v4;
import cn.axzo.msg.center.api.request.v3.ImSendInfo;
import cn.axzo.msg.center.api.request.v3.PendingSendInfo;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
@ -28,10 +29,15 @@ public class MessageSendRequestV4 implements Serializable {
private MessageSendBasicInfoV4 sendBasicInfo;
/**
* 发送待办时必传
* 更多的待办信息, 发送待办时, 根据需要传入
*/
private PendingSendInfo pendingSendInfo;
/**
* 更多的IM信息, 发送IM时, 根据需要传入
*/
private ImSendInfo imSendInfo;
// !! internal fields
/**