260716_02_ENH: 프로젝트에 발신 번호추가 및 리다이렉트 url, api 수정
This commit is contained in:
16
src/app/api/external/[[...slug]]/route.ts
vendored
16
src/app/api/external/[[...slug]]/route.ts
vendored
@@ -6,8 +6,9 @@ import { errorToResponse } from "@kri/common/http";
|
||||
import { getClientIp } from "@kri/common/server";
|
||||
import {
|
||||
EXTERNAL_ACTION_CODE_BY_SLUG,
|
||||
EXTERNAL_ENTRY_TYPE_CODE,
|
||||
ExternalAction,
|
||||
ExternalEntryType,
|
||||
ExternalEntryTypeCode,
|
||||
ExternalEventBody,
|
||||
} from "@/types/external";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
@@ -17,8 +18,10 @@ const getHeader = (headers: Headers, name: string): string | null => {
|
||||
return value && value.trim().length > 0 ? value : null;
|
||||
};
|
||||
|
||||
const getEntryType = (headers: Headers): ExternalEntryType => {
|
||||
return getHeader(headers, "x-entry-type") === "redirect" ? "redirect" : "api";
|
||||
const getEntryTypeCode = (headers: Headers): ExternalEntryTypeCode => {
|
||||
return getHeader(headers, "x-entry-type") === "redirect"
|
||||
? EXTERNAL_ENTRY_TYPE_CODE.redirect
|
||||
: EXTERNAL_ENTRY_TYPE_CODE.api;
|
||||
};
|
||||
|
||||
const toExternalAction = (value: string): ExternalAction | null => {
|
||||
@@ -41,13 +44,12 @@ const buildExternalEventBody = (
|
||||
const actionCode = EXTERNAL_ACTION_CODE_BY_SLUG[action];
|
||||
|
||||
return {
|
||||
actionCode,
|
||||
action: actionCode,
|
||||
prjctIdx,
|
||||
sid,
|
||||
meta: {
|
||||
entryType: getEntryType(h),
|
||||
action,
|
||||
actionCode,
|
||||
entryType: getEntryTypeCode(h),
|
||||
action: actionCode,
|
||||
pid: String(prjctIdx),
|
||||
sid: String(sid),
|
||||
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
||||
|
||||
Reference in New Issue
Block a user