REQ-2141: 是否拼接routerPrams加入白名单
This commit is contained in:
parent
0eed683479
commit
5f7918746d
@ -100,6 +100,13 @@ public class PendingMessageBizConfig {
|
||||
@Getter
|
||||
private boolean formatExecSQL;
|
||||
|
||||
@Getter
|
||||
private Set<String> dontConcatRouterParamsTemplateCodes;
|
||||
|
||||
public boolean isConcatRouterParams(String templateCode) {
|
||||
return dontConcatRouterParamsTemplateCodes == null || !dontConcatRouterParamsTemplateCodes.contains(templateCode);
|
||||
}
|
||||
|
||||
public boolean hasMessageDetailStyle(String code) {
|
||||
return name2DetailStyle != null && name2DetailStyle.containsKey(code);
|
||||
}
|
||||
|
||||
@ -30,12 +30,13 @@ import java.util.stream.Collectors;
|
||||
public class MessageTemplateParser {
|
||||
|
||||
private final MessageSystemConfig messageSystemConfig;
|
||||
private final MessageRouterUtil messageRouterUtil;
|
||||
|
||||
GeneralMessagePushVO parse(MessageRecordV3 message, MessageTemplateDTO template) {
|
||||
// 对应模板的路由列表
|
||||
MessageTemplateRouterDTO msgTemplateRouter = template.getMsgTemplateRouter();
|
||||
// 解析路由地址
|
||||
msgTemplateRouter = MessageRouterUtil.parseAndConcatRouteUrl(msgTemplateRouter, message.getRouterParams());
|
||||
msgTemplateRouter = messageRouterUtil.parseAndConcatRouteUrl(template, msgTemplateRouter, message.getRouterParams());
|
||||
// 获取模板卡片信息
|
||||
List<MessageCardContentItemDTO> rawCardContentItems = template.getMsgCardContentItems();
|
||||
List<MessageCardContentItemDTO> cardContentItems = rawCardContentItems;
|
||||
|
||||
@ -77,6 +77,7 @@ public class GeneralMessageServiceImpl implements GeneralMessageService {
|
||||
private final GeneralMessageOldServiceImpl generalMessageOldService;
|
||||
private final MessageTemplateNewService messageTemplateNewService;
|
||||
private final MessageSendTwiceRecordService messageSendTwiceRecordService;
|
||||
private final MessageRouterUtil messageRouterUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||
@ -180,7 +181,7 @@ public class GeneralMessageServiceImpl implements GeneralMessageService {
|
||||
// 对应模板的路由列表
|
||||
MessageTemplateRouterDTO msgTemplateRouter = template.getMsgTemplateRouter();
|
||||
// 解析路由地址
|
||||
msgTemplateRouter = MessageRouterUtil.parseAndConcatRouteUrl(msgTemplateRouter, record.getRouterParams());
|
||||
msgTemplateRouter = messageRouterUtil.parseAndConcatRouteUrl(template, msgTemplateRouter, record.getRouterParams());
|
||||
// 获取模板卡片信息
|
||||
List<MessageCardContentItemDTO> rawCardContentItems = template.getMsgCardContentItems();
|
||||
List<MessageCardContentItemDTO> cardContentItems = rawCardContentItems;
|
||||
|
||||
@ -154,6 +154,7 @@ public class PendingMessageNewServiceImpl implements PendingMessageNewService {
|
||||
private final OrganizationalTeamOuRelationApi organizationalTeamOuRelationApi;
|
||||
private final PendingMessageBizConfig pendingMessageBizConfig;
|
||||
private final MessageGroupNodeDao messageGroupNodeDao;
|
||||
private final MessageRouterUtil messageRouterUtil;;
|
||||
|
||||
@Value("${msg.center.pending.hide-seconds:60}")
|
||||
private int pendingDefaultHideSeconds;
|
||||
@ -813,8 +814,8 @@ public class PendingMessageNewServiceImpl implements PendingMessageNewService {
|
||||
if (adapter.getBizCategory() == BizCategoryEnum.FLOW && (!authParam.containsKey("identityCode") || null == authParam.get("identityCode"))) {
|
||||
authParam.put("identityCode", adapter.getIdentityCode());
|
||||
}
|
||||
msgTemplateRouter = MessageRouterUtil.parseRouteUrl(msgTemplateRouter, authParam);
|
||||
msgTemplateRouter = MessageRouterUtil.parseAndConcatRouteUrl(msgTemplateRouter, routerParam);
|
||||
msgTemplateRouter = messageRouterUtil.parseRouteUrl(msgTemplateRouter, authParam);
|
||||
msgTemplateRouter = messageRouterUtil.parseAndConcatRouteUrl(template, msgTemplateRouter, routerParam);
|
||||
pendingMessage.setMsgTemplateRouter(msgTemplateRouter);
|
||||
// 获取模板卡片信息
|
||||
List<MessageCardContentItemDTO> msgCardContentItems = messageTemplates.stream()
|
||||
|
||||
@ -29,6 +29,7 @@ import java.util.List;
|
||||
class TodoPushSender implements ApplicationListener<NewTodoEvent> {
|
||||
|
||||
private final YoumengTemplateClient youmengTemplateClient;
|
||||
private final MessageRouterUtil messageRouterUtil;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(@NotNull NewTodoEvent event) {
|
||||
@ -55,8 +56,8 @@ class TodoPushSender implements ApplicationListener<NewTodoEvent> {
|
||||
List<MessageRouterConfigDTO> routerConfigs = detail.getRouterConfigs();
|
||||
if (CollectionUtils.isEmpty(routerConfigs))
|
||||
return Collections.emptyList();
|
||||
MessageTemplateRouterDTO router = MessageRouterUtil.parseAndConcatRouteUrl(
|
||||
template.getMsgTemplateRouter(), todo.getRouterParams());
|
||||
MessageTemplateRouterDTO router = messageRouterUtil.parseAndConcatRouteUrl(
|
||||
template, template.getMsgTemplateRouter(), todo.getRouterParams());
|
||||
if (router == null)
|
||||
return Collections.emptyList();
|
||||
ArrayList<PushNavigation> navigations = new ArrayList<>();
|
||||
|
||||
@ -40,9 +40,9 @@ public class YoumengTemplateClient {
|
||||
private final MessageBaseTemplateMapper messageBaseTemplateMapper;
|
||||
|
||||
private final ExecutorService executor = new ThreadPoolExecutor(
|
||||
5, 10,
|
||||
5, TimeUnit.MINUTES,
|
||||
new ArrayBlockingQueue<>(500),
|
||||
15, 30,
|
||||
10, TimeUnit.MINUTES,
|
||||
new ArrayBlockingQueue<>(3000),
|
||||
new NamedThreadFactory(getClass().getSimpleName()));
|
||||
|
||||
public void asyncSend(Long templateId, List<YoumengPush> pushes) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.axzo.msg.center.utils;
|
||||
|
||||
import cn.axzo.msg.center.common.utils.PlaceholderResolver;
|
||||
import cn.axzo.msg.center.inside.notices.config.PendingMessageBizConfig;
|
||||
import cn.axzo.msg.center.message.domain.dto.MessageTemplateDTO;
|
||||
import cn.axzo.msg.center.message.domain.dto.MessageTemplateRouterDTO;
|
||||
import cn.axzo.msg.center.message.domain.dto.MessageTemplateRouterDTO.MessageRouteButtonDTO;
|
||||
import cn.axzo.msg.center.message.domain.dto.MessageTemplateRouterDTO.MessageRouteDetailDTO;
|
||||
@ -17,11 +19,11 @@ import cn.axzo.msg.center.service.enums.TerminalTypeEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.URLEncoder;
|
||||
@ -44,11 +46,14 @@ import java.util.stream.Collectors;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public final class MessageRouterUtil {
|
||||
|
||||
public static final String DETAIL_ROUTER_DESC = "详情";
|
||||
|
||||
private final PendingMessageBizConfig cfg;
|
||||
|
||||
/**
|
||||
* 获取业务详情路由策略
|
||||
*
|
||||
@ -142,7 +147,7 @@ public final class MessageRouterUtil {
|
||||
* @param routerParam 路由参数
|
||||
* @return MessageTemplateRouterDTO
|
||||
*/
|
||||
public static MessageTemplateRouterDTO parseRouteUrl(MessageTemplateRouterDTO msgTemplateRouter,
|
||||
public MessageTemplateRouterDTO parseRouteUrl(MessageTemplateRouterDTO msgTemplateRouter,
|
||||
JSONObject routerParam) {
|
||||
if (Objects.isNull(msgTemplateRouter)) {
|
||||
return msgTemplateRouter;
|
||||
@ -162,12 +167,14 @@ public final class MessageRouterUtil {
|
||||
/**
|
||||
* 解析模板上配置的路由地址,将发送消息时的参数替换上去,并将路由参数追加到模板的路由地址后面,兼容APP端新老版本
|
||||
*
|
||||
* @param template
|
||||
* @param msgTemplateRouter 路由信息
|
||||
* @param routerParam 路由参数
|
||||
* @param routerParam 路由参数
|
||||
* @return MessageTemplateRouterDTO
|
||||
*/
|
||||
public static MessageTemplateRouterDTO parseAndConcatRouteUrl(MessageTemplateRouterDTO msgTemplateRouter,
|
||||
JSONObject routerParam) {
|
||||
public MessageTemplateRouterDTO parseAndConcatRouteUrl(MessageTemplateDTO template,
|
||||
MessageTemplateRouterDTO msgTemplateRouter,
|
||||
JSONObject routerParam) {
|
||||
if (Objects.isNull(msgTemplateRouter)) {
|
||||
return msgTemplateRouter;
|
||||
}
|
||||
@ -175,10 +182,11 @@ public final class MessageRouterUtil {
|
||||
msgTemplateRouter = msgTemplateRouter.deepClone();
|
||||
// 路由参数有效
|
||||
if (Objects.nonNull(routerParam)) {
|
||||
boolean isConcatRouterParams = cfg.isConcatRouterParams(template.getCode());
|
||||
// 编排业务详情路由
|
||||
parseAndConcatDetailRouterUrl(msgTemplateRouter.getRouteDetail(), routerParam, true);
|
||||
parseAndConcatDetailRouterUrl(msgTemplateRouter.getRouteDetail(), routerParam, isConcatRouterParams);
|
||||
// 编排路由按钮
|
||||
parseAndConcatButtonRouterUrl(msgTemplateRouter.getRouteButtons(), routerParam, true);
|
||||
parseAndConcatButtonRouterUrl(msgTemplateRouter.getRouteButtons(), routerParam, isConcatRouterParams);
|
||||
}
|
||||
return msgTemplateRouter;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user