261023_01_ENH: 문자 발송 유형 LMS(22)·MMS(23) 분리 및 최종 발송 내용 기준 유형 자동 판정
This commit is contained in:
@@ -21,7 +21,15 @@ public final class NotihubConst {
|
|||||||
public static final short EMAIL_RESULT_SEARCH_DELAY = 500;
|
public static final short EMAIL_RESULT_SEARCH_DELAY = 500;
|
||||||
public static final short EMAIL_DELAY = 500;
|
public static final short EMAIL_DELAY = 500;
|
||||||
public static final short DELAY_MAX_MS = (short) 5_000; // 필요시 조정
|
public static final short DELAY_MAX_MS = (short) 5_000; // 필요시 조정
|
||||||
public static final List<Short> SMS_TYPE_CODE_LIST = List.of(SendType.SMS.getCode(), SendType.LMS_MMS.getCode());
|
public static final List<Short> SMS_TYPE_CODE_LIST = List.of(
|
||||||
|
SendType.SMS.getCode(),
|
||||||
|
SendType.LMS.getCode(),
|
||||||
|
SendType.MMS.getCode()
|
||||||
|
);
|
||||||
|
public static final List<Short> LMS_MMS_TYPE_CODE_LIST = List.of(
|
||||||
|
SendType.LMS.getCode(),
|
||||||
|
SendType.MMS.getCode()
|
||||||
|
);
|
||||||
public static final List<Short> KKO_TYPE_CODE_LIST = List.of(SendType.KKO_AT.getCode());
|
public static final List<Short> KKO_TYPE_CODE_LIST = List.of(SendType.KKO_AT.getCode());
|
||||||
public static final List<Short> EMAIL_TYPE_CODE_LIST = List.of(SendType.EMAIL.getCode());
|
public static final List<Short> EMAIL_TYPE_CODE_LIST = List.of(SendType.EMAIL.getCode());
|
||||||
public static final String EMAIL_RESERVATION_PREFIX = "RESERVATION_";
|
public static final String EMAIL_RESERVATION_PREFIX = "RESERVATION_";
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public enum SendSmsType implements CodeEnum<Short> {
|
public enum SendSmsType implements CodeEnum<Short> {
|
||||||
SMS((short) 21),
|
SMS((short) 21),
|
||||||
LMS_MMS((short) 22);
|
LMS((short) 22),
|
||||||
|
MMS((short) 23);
|
||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import lombok.RequiredArgsConstructor;
|
|||||||
public enum SendType implements CodeEnum<Short> {
|
public enum SendType implements CodeEnum<Short> {
|
||||||
EMAIL(SendEmailType.EMAIL),
|
EMAIL(SendEmailType.EMAIL),
|
||||||
SMS(SendSmsType.SMS),
|
SMS(SendSmsType.SMS),
|
||||||
LMS_MMS(SendSmsType.LMS_MMS),
|
LMS(SendSmsType.LMS),
|
||||||
|
MMS(SendSmsType.MMS),
|
||||||
KKO_AT(SendKkoAtType.KKO_AT);
|
KKO_AT(SendKkoAtType.KKO_AT);
|
||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|||||||
@@ -167,11 +167,22 @@ public final class TemplateContentSanitizer {
|
|||||||
return text.trim();
|
return text.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SendType resolveSendType(SendType originalType, String title, String body,
|
||||||
|
String attachments) {
|
||||||
|
if (!SMS_TYPE_CODE_LIST.contains(originalType.getCode())) {
|
||||||
|
return originalType;
|
||||||
|
}
|
||||||
|
if (attachments != null && !attachments.isBlank()) {
|
||||||
|
return SendType.MMS;
|
||||||
|
}
|
||||||
|
return determineSms(title, body);
|
||||||
|
}
|
||||||
|
|
||||||
public static SendType determineSms(String outTitle, String outBody){
|
public static SendType determineSms(String outTitle, String outBody){
|
||||||
boolean hasTitle = StringUtil.hasText(outTitle);
|
boolean hasTitle = StringUtil.hasText(outTitle);
|
||||||
boolean isLargeBody = utf8ByteLength(outBody) >= SMS_MAX_BYTES_UTF8;
|
boolean isLargeBody = utf8ByteLength(outBody) >= SMS_MAX_BYTES_UTF8;
|
||||||
|
|
||||||
return hasTitle || isLargeBody ? SendType.LMS_MMS : SendType.SMS;
|
return hasTitle || isLargeBody ? SendType.LMS : SendType.SMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +208,7 @@ public final class TemplateContentSanitizer {
|
|||||||
case KKO_AT -> {
|
case KKO_AT -> {
|
||||||
// 카카오 등록 원문과 일치하도록 미리보기 제목과 본문을 변형하지 않는다.
|
// 카카오 등록 원문과 일치하도록 미리보기 제목과 본문을 변형하지 않는다.
|
||||||
}
|
}
|
||||||
case SMS, LMS_MMS -> {
|
case SMS, LMS, MMS -> {
|
||||||
// 평문화
|
// 평문화
|
||||||
outTitle = htmlToPlainTextPreserveNewlines(outTitle);
|
outTitle = htmlToPlainTextPreserveNewlines(outTitle);
|
||||||
outTitle = truncateTo128CodePoints(outTitle);
|
outTitle = truncateTo128CodePoints(outTitle);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.kri.notihub.server.persistence.entity;
|
package com.kri.notihub.server.persistence.entity;
|
||||||
|
|
||||||
import static com.kri.notihub.server.common.consts.NotihubConst.SMS_TYPE_CODE_LIST;
|
import static com.kri.notihub.server.common.consts.NotihubConst.SMS_TYPE_CODE_LIST;
|
||||||
import static com.kri.notihub.server.common.util.TemplateContentSanitizer.determineSms;
|
import static com.kri.notihub.server.common.util.TemplateContentSanitizer.resolveSendType;
|
||||||
|
|
||||||
import com.kri.notihub.server.common.enums.SendCorpType;
|
import com.kri.notihub.server.common.enums.SendCorpType;
|
||||||
import com.kri.notihub.server.common.enums.SendType;
|
import com.kri.notihub.server.common.enums.SendType;
|
||||||
@@ -239,11 +239,8 @@ public class TSendEntity {
|
|||||||
Short sendCorp = tmplat.getTmplatTy() == SendType.EMAIL ? SendCorpType.PRINGO.getCode()
|
Short sendCorp = tmplat.getTmplatTy() == SendType.EMAIL ? SendCorpType.PRINGO.getCode()
|
||||||
: SendCorpType.BIZ_PPURIO.getCode();
|
: SendCorpType.BIZ_PPURIO.getCode();
|
||||||
|
|
||||||
Short sendTy = tmplat.getTmplatTy().getCode();
|
Short sendTy = resolveSendType(tmplat.getTmplatTy(), msgTitle, msgBody,
|
||||||
if(SMS_TYPE_CODE_LIST.contains(sendTy)){
|
tmplat.getAtchFl()).getCode();
|
||||||
sendTy = tmplat.getAtchFl() != null && !tmplat.getAtchFl().isBlank()
|
|
||||||
? SendType.LMS_MMS.getCode() : determineSms(msgTitle, msgBody).getCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSendEntity.builder()
|
return TSendEntity.builder()
|
||||||
.cmid(sendResult.cmid())
|
.cmid(sendResult.cmid())
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.kri.notihub.server.service;
|
package com.kri.notihub.server.service;
|
||||||
|
|
||||||
import static com.kri.notihub.server.common.util.TemplateContentSanitizer.determineSms;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.firstNonBlank;
|
import static org.apache.commons.lang3.StringUtils.firstNonBlank;
|
||||||
|
|
||||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||||
@@ -11,6 +10,7 @@ import com.kri.notihub.server.common.enums.ChannelType;
|
|||||||
import com.kri.notihub.server.common.enums.SendStatusType;
|
import com.kri.notihub.server.common.enums.SendStatusType;
|
||||||
import com.kri.notihub.server.common.enums.SendType;
|
import com.kri.notihub.server.common.enums.SendType;
|
||||||
import com.kri.notihub.server.common.enums.TemplatePurpose;
|
import com.kri.notihub.server.common.enums.TemplatePurpose;
|
||||||
|
import com.kri.notihub.server.common.util.TemplateContentSanitizer;
|
||||||
import com.kri.notihub.server.dto.send.BulkSendCreateRequestDto;
|
import com.kri.notihub.server.dto.send.BulkSendCreateRequestDto;
|
||||||
import com.kri.notihub.server.dto.send.BulkSendResponseDto;
|
import com.kri.notihub.server.dto.send.BulkSendResponseDto;
|
||||||
import com.kri.notihub.server.dto.send.DestInfoDto;
|
import com.kri.notihub.server.dto.send.DestInfoDto;
|
||||||
@@ -304,7 +304,7 @@ public abstract class AbstractSendService {
|
|||||||
SendInternalResultDto sendResult = doSendInternal(
|
SendInternalResultDto sendResult = doSendInternal(
|
||||||
isResve,
|
isResve,
|
||||||
bulkSendKey,
|
bulkSendKey,
|
||||||
tmplat.getTmplatTy(),
|
resolveSendType(tmplat, msgTitle, msgBody),
|
||||||
tmplat.getTmplatIdx(),
|
tmplat.getTmplatIdx(),
|
||||||
tmplat.getAtchFl(),
|
tmplat.getAtchFl(),
|
||||||
sendFrom,
|
sendFrom,
|
||||||
@@ -413,13 +413,8 @@ public abstract class AbstractSendService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendType resolveSendType(TemplateDto tmplat, String msgTitle, String msgBody) {
|
private SendType resolveSendType(TemplateDto tmplat, String msgTitle, String msgBody) {
|
||||||
if (NotihubConst.SMS_TYPE_CODE_LIST.contains(tmplat.getTmplatTy().getCode())) {
|
return TemplateContentSanitizer.resolveSendType(
|
||||||
if (tmplat.getAtchFl() != null && !tmplat.getAtchFl().isBlank()) {
|
tmplat.getTmplatTy(), msgTitle, msgBody, tmplat.getAtchFl());
|
||||||
return SendType.LMS_MMS;
|
|
||||||
}
|
|
||||||
return determineSms(msgTitle, msgBody);
|
|
||||||
}
|
|
||||||
return tmplat.getTmplatTy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateBulkTemplatePurpose(TemplateDto tmplat) {
|
private void validateBulkTemplatePurpose(TemplateDto tmplat) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class ReportService {
|
|||||||
String regCmpn) {
|
String regCmpn) {
|
||||||
List<Short> sendTyList = switch (sendTy) {
|
List<Short> sendTyList = switch (sendTy) {
|
||||||
case EMAIL -> NotihubConst.EMAIL_TYPE_CODE_LIST;
|
case EMAIL -> NotihubConst.EMAIL_TYPE_CODE_LIST;
|
||||||
case SMS, LMS_MMS -> NotihubConst.SMS_TYPE_CODE_LIST;
|
case SMS, LMS, MMS -> NotihubConst.SMS_TYPE_CODE_LIST;
|
||||||
case KKO_AT -> NotihubConst.KKO_TYPE_CODE_LIST;
|
case KKO_AT -> NotihubConst.KKO_TYPE_CODE_LIST;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class SendSmsService extends AbstractBizppurioSendService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected short standbyResultCode(SendType sendType) {
|
protected short standbyResultCode(SendType sendType) {
|
||||||
return sendType == SendType.LMS_MMS
|
return NotihubConst.LMS_MMS_TYPE_CODE_LIST.contains(sendType.getCode())
|
||||||
? NotihubConst.LMS_MMS_STANDBY
|
? NotihubConst.LMS_MMS_STANDBY
|
||||||
: NotihubConst.SMS_STANDBY;
|
: NotihubConst.SMS_STANDBY;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,9 +91,6 @@ public class TemplateService {
|
|||||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||||
validateBySendType(template);
|
validateBySendType(template);
|
||||||
TemplateContentSanitizer.sanitizeAndNormalizeInPlace(template);
|
TemplateContentSanitizer.sanitizeAndNormalizeInPlace(template);
|
||||||
if (hasAttachments(files) && template.getTmplatTy() == SendType.SMS) {
|
|
||||||
template.setTmplatTy(SendType.LMS_MMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
TTmplatEntity entity = TTmplatEntity.create(itrntPrjctCd, template, regUser, now);
|
TTmplatEntity entity = TTmplatEntity.create(itrntPrjctCd, template, regUser, now);
|
||||||
entity.setAtchFl(null);
|
entity.setAtchFl(null);
|
||||||
@@ -110,6 +107,7 @@ public class TemplateService {
|
|||||||
entity.setAtchFl(attachmentService(template.getTmplatTy())
|
entity.setAtchFl(attachmentService(template.getTmplatTy())
|
||||||
.create(entity.getTmplatIdx(), files));
|
.create(entity.getTmplatIdx(), files));
|
||||||
}
|
}
|
||||||
|
normalizeSmsType(entity);
|
||||||
templateRepository.save(entity);
|
templateRepository.save(entity);
|
||||||
|
|
||||||
TemplateDto created = TemplateDto.from(entity);
|
TemplateDto created = TemplateDto.from(entity);
|
||||||
@@ -199,11 +197,6 @@ public class TemplateService {
|
|||||||
|
|
||||||
//제목, 본문 정규화
|
//제목, 본문 정규화
|
||||||
TemplateContentSanitizer.sanitizeAndNormalizeInPlace(template);
|
TemplateContentSanitizer.sanitizeAndNormalizeInPlace(template);
|
||||||
if (template.getTmplatTy() == SendType.SMS
|
|
||||||
&& (hasAttachments(files) || (previousType != SendType.EMAIL
|
|
||||||
&& entity.getAtchFl() != null && !entity.getAtchFl().isBlank()))) {
|
|
||||||
template.setTmplatTy(SendType.LMS_MMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateBasicDto before = TemplateDto.from(entity);
|
TemplateBasicDto before = TemplateDto.from(entity);
|
||||||
|
|
||||||
@@ -217,11 +210,7 @@ public class TemplateService {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.getTmplatTy() == SendType.LMS_MMS
|
normalizeSmsType(entity);
|
||||||
&& (entity.getAtchFl() == null || entity.getAtchFl().isBlank())) {
|
|
||||||
entity.setTmplatTy(TemplateContentSanitizer.determineSms(
|
|
||||||
entity.getTmplatTitle(), entity.getTmplatBody()).getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
templateRepository.save(entity);
|
templateRepository.save(entity);
|
||||||
|
|
||||||
@@ -276,8 +265,16 @@ public class TemplateService {
|
|||||||
return deleteFileNames != null && !deleteFileNames.isEmpty();
|
return deleteFileNames != null && !deleteFileNames.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void normalizeSmsType(TTmplatEntity entity) {
|
||||||
|
SendType type = SendType.fromCode(entity.getTmplatTy());
|
||||||
|
if (NotihubConst.SMS_TYPE_CODE_LIST.contains(type.getCode())) {
|
||||||
|
entity.setTmplatTy(TemplateContentSanitizer.resolveSendType(type,
|
||||||
|
entity.getTmplatTitle(), entity.getTmplatBody(), entity.getAtchFl()).getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean supportsAttachments(SendType type) {
|
private boolean supportsAttachments(SendType type) {
|
||||||
return type == SendType.EMAIL || type == SendType.SMS || type == SendType.LMS_MMS;
|
return type == SendType.EMAIL || NotihubConst.SMS_TYPE_CODE_LIST.contains(type.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractTemplateAttachmentService attachmentService(SendType type) {
|
private AbstractTemplateAttachmentService attachmentService(SendType type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user