261008_01_ENH: 알림톡 템플릿 관련내용 구현 및 발송 구현
This commit is contained in:
@@ -16,3 +16,19 @@ export const getNearestFutureDateTime = (stepMinutes = RESERVE_MINUTE_STEP): str
|
||||
|
||||
return `${year}-${month}-${day}T${hour}:${minute}`
|
||||
}
|
||||
|
||||
const KST_DATE_TIME_FORMAT = new Intl.DateTimeFormat('sv-SE', {
|
||||
timeZone: 'Asia/Seoul',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false,
|
||||
})
|
||||
|
||||
// 날짜·시각 선택값(로컬 시각)을 예약 발송 sendDt 형식(KST "yyyy-MM-dd HH:mm:ss")으로 바꾼다.
|
||||
// 이메일·문자·알림톡 공통 형식이다.
|
||||
export const toReserveSendDt = (localDateTime: string): string =>
|
||||
KST_DATE_TIME_FORMAT.format(new Date(localDateTime))
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
export const substituteVariables = (contents: string, values: Record<string, string>) =>
|
||||
contents.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");
|
||||
|
||||
// 알림톡 본문의 #{변수}, [$변수] 토큰을 values 값으로 바꾼다.
|
||||
// 발송 시 값이 없는 변수는 원문이 그대로 남으므로, 미리보기에서도 원문 토큰을 유지한다.
|
||||
export const substituteKkoVariables = (contents: string, values: Record<string, string>) =>
|
||||
contents.replace(/#\{([^}]+)\}|\[\$([^\]]+)\]/g, (token, kkoKey?: string, kriKey?: string) =>
|
||||
values[(kkoKey ?? kriKey) as string] ?? token);
|
||||
|
||||
export const escapeHtml = (value: string) =>
|
||||
value.replace(
|
||||
/[&<>"']/g,
|
||||
|
||||
Reference in New Issue
Block a user