From 3e59693e017742d971f490eb7c58870cb745a98d Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Fri, 18 Jul 2025 03:58:34 +0000 Subject: (김준회) 결재 모듈 개발 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/knox-api/messenger/messenger-guide.html | 9422 +++++++++++++++++++++++++++ lib/knox-api/messenger/messenger.ts | 925 +++ 2 files changed, 10347 insertions(+) create mode 100644 lib/knox-api/messenger/messenger-guide.html create mode 100644 lib/knox-api/messenger/messenger.ts (limited to 'lib/knox-api/messenger') diff --git a/lib/knox-api/messenger/messenger-guide.html b/lib/knox-api/messenger/messenger-guide.html new file mode 100644 index 00000000..d91167ea --- /dev/null +++ b/lib/knox-api/messenger/messenger-guide.html @@ -0,0 +1,9422 @@ +
+
+

메신저

+
+
+

사전에 생성하신 Knox Portal 비실명계정을 발신자로 하여 Knox Messenger 내에서 + 대화방을 생성하고 메시지를 발신할 수 있습니다.
발신계정을 챗봇 타입으로 생성하시고 수신API 구축하시면 메시지를 수신하실 수도 있습니다..

+

+
[정책 및 제약사항]
+
+
+
1. 토큰 발급부터 메시지 발송까지 필수 작업 순서는 아래와 같습니다. +
+
 1) 메신저 API 신청을 통해 Access Token을 + 획득합니다.
+
 2) 디바이스 등록 API 수행 (GET + /messenger/contact/api/v1.0/device/o1/reg)을 통해 Devide ID를 획득합니다.
+
 3) 암호화 키 조회 API 수행 (GET + /messenger/msgctx/api/v1.0/key/getkeys)을 통해 key value를 획득합니다.
+
 4) 위의 1),2),3) 에서 획득한 파라미터를 사용하여 대화방 생성 + API(/messenger/message/api/v1.0/message/createChatroomRequest), 메시지 발신 + API(/messenger/message/api/v1.0/message/chatRequest) 호출합니다.
+
2. 메신저 API는 다음과 같은 연속호출 제한조건이 있으니 반드시 준수하여 주시기 + 바랍니다.
+
 - ShortTerm 정책: 1초당 50건 초과 시 해당 계정으로의 요청이 + 1초 간 차단
+
 - LongTerm 정책: 15분당 20,000건 초과 시 해당 계정으로의 + 요청이 12시간 동안 차단
+
3. 1회 발송 가능한 최대 메시지 길이는 유형별로 상이합니다.
+
 - 0 (Text type) : 3300 자
+
 - 1 (Media type), 8 (Ncustom type) : + 40,000 byte
+
4. 전송가능 파일 확장자는 아래와 같습니다.
+
 - IMAGE : jpg,jpeg,png,gif
+
 - VIDEO : + mp4,3gp,mov,flv,wmv,mkv,mpg,avi,3g2,m4v,ts,webm
+
 - AUDIO : + mp3,aac,m4a,amr,3ga,wma,imy,mid,mpeg,flac,ogg,wav
+
 - FILE : + pdf,gul,hwp,ppt,pptx,doc,docx,rtf,xls,xlsx,txt,snb,scc,spd,zip,ics
+
+

+
[API 목록]
+
+
+ + + + + + + + + + + + + + + +
APIURIMethodDescription
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
메신저 연락처 + 추가/messenger/contact/api/v1.0/contact/o1/user + POST메신저 연락처에 친구를 + 등록한다.
메신저 연락처 + 삭제/messenger/contact/api/v1.0/contact/o1/user/delete + POST메신저 연락처에 친구를 + 삭제한다.
메신저 연락처 리스트 + 조회/messenger/contact/api/v1.0/contact/o1/list + GET메신저 연락처 등록된 리스트를 + 조회한다.
메신저 User ID + 검색/messenger/contact/api/v1.0/profile/o1/search/loginid + POSTKnox Portal ID로 메신저 + 내부 User ID를 검색한다.
메신저 Device + 등록/messenger/contact/api/v1.0/device/o1/reg + GET연계시스템 발신계정에 대한 메신저 + Device를 등록한다.
메신저 Device + 해지/messenger/contact/api/v1.0/device/o1/delete + POST연계시스템 발신계정에 대한 메신저 + Device를 해지한다.
메신저 Device + 사용정보 조회/messenger/contact/api/v1.0/device/o1/use/info + POST본인 또는 타인의 메신저 Device별 + 사용정보를 조회한다.
파일서버 암호화 Key + 조회/messenger/file/api/v1.0/file/v1/getCurrentTime + GET파일 업로드/다운로드 API 사용을 + 위한 암호화 Key를 조회한다.
파일 + 업로드/messenger/file/api/v1.0/file/v1s/file/{filename} + PUT첨부파일을 업로드한다. +
파일 + 다운로드/messenger/file/api/v1.0/file/v1s/file/{file_id} + GET첨부파일을 다운로드한다. +
메시지서버 암호화 + Key 조회/messenger/msgctx/api/v1.0/key/getkeys + GET메시지서버의 Body 암호화용 Key를 + 조회한다.
대화방 참여자정보 + 조회/messenger/msgctx/api/v1.0/chat/activemember + GET특정 대화방의 참여자수와 User + ID를 조회한다.
대화방 + 생성/messenger/message/api/v1.0/message/createChatroomRequest + POST신규 대화방을 생성한다. +
메시지 + 발신/messenger/message/api/v1.0/message/chatRequest + POST대화방에 메시지를 + 발신한다.
대화상대 + 초대/messenger/message/api/v1.0/message/inviteRequest + POST대화방에 대화상대를 + 초대한다.
대화상대 + 내보내기/messenger/message/api/v1.0/message/removeMemberRequest + POST대화방에서 대화상대를 + 내보낸다.
대화방 + 삭제/messenger/message/api/v1.0/message/destroyChatroomRequest + POST대화방을 삭제한다. +
메시지 + 발신취소/messenger/message/api/v1.0/message/recallMessageRequest + POST발신된 메시지를 + 발신취소한다.
대화방명 + 변경/messenger/message/api/v1.0/message/changeChatroomMetaRequest + POST대화방 이름을 변경한다. (방장만 + 가능)
방장 + 변경/messenger/message/api/v1.0/message/changeOwnerRequest + POST대화방의 방장을 변경한다. (방장만 + 가능)
대화방 + 나가기/messenger/message/api/v1.0/message/endChatRequest + POST대화방을 나간다.
메시지 읽음 + Count 조회/messenger/message/api/v1.0/message/messageReadCountRequest + POST발신된 메시지의 읽음 Count를 + 조회한다.
+
+



+
+
Add user +
+
+

/messenger/contact/api/v1.0/contact/o1/user

+
+
+

연락처에 친구 추가. 자통법 대상자는 친구 추가 불가 및 blocklist로 결과 + 반환.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorizationyHeaderStringBearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + Typex-device-type + yHeaderStringrelation +
3Device + IDx-device-idyHeaderString1234 + +
4Content Type + Content-Type + yHeaderStringapplication/json + +
5AcceptAcceptyHeaderStringapplication/json
6연락처에 등록할 + contactListcontactList + yBodyList +
7연락처에 등록할 + userIDcontactList.userID + yBodyLong1010101010101 +
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
연락처에 등록된 + userID 리스트contactList + List + +
연락처에 + 등록된 userIDuserID + Long + 1010101010103 + +
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +

POST + /messenger/contact/api/v1.0/contact/o1/user HTTP/1.1
Host : yyy.xxxxxx.com

{
    “contactList” : [
         { “userID” : + 10101010101 },
         { “userID” : + 10101010102 }
    ]
}

{
    “contactList” : [
         { “userID” : + 10101010101 }
    ],    “blockedUserIDList” + : [
         { “userID” : + 10101010102 }
    ]
}
+
+
+
Error Code
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
400 + CFC-100002 + Group + is not exist +
400 + CFC-200001 + Contact + is already added +
400 + CFC-200003 + parameter + userID is invalid userID +
400 + CFC-200004 + Blocked + Group Relation +
400 + CFC-200005 + Exceeded + max contact member limit +
+
+

+
+
Delete + user
+
+

/messenger/contact/api/v1.0/contact/o1/user/delete +

+
+
+

연락처에서 친구를 삭제.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorizationyHeaderStringBearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + Typex-device-type + yHeaderStringrelation +
3Device + IDx-device-idyHeaderString1234 + +
4Content Type + Content-Type + yHeaderStringapplication/json + +
5AcceptAcceptyHeaderStringapplication/json
6연락처에서 제거할 + contactListcontactList + yBodyList +
7연락처에서 제거할 + userIDcontactList.userID + yBodyLong1010101010101 +
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + +
-----
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +

POST + /messenger/contact/api/v1.0/contact/o1/user/delete HTTP/1.1
Host : yyy.xxxxxx.com

{
    “contactList” : [
         { “userID” : + 10101010101 },
         { “userID” : + 10101010102 }
    ]
}
-
+
+
+
Error Code
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + +
400 + CFC-100002 + Group + is not exist +
400 + CFC-200002 + parameter + userid is not exist in contactlist +
+
+

+
+
Contact + list
+
+

GET + /messenger/contact/api/v1.0/contact/o1/list

+
+
+

등록된 연락처 목록을 조회횐다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorizationyHeaderStringBearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + Typex-device-type + yHeaderStringrelation +
3Device + IDx-device-idyHeaderString1234 + +
4Content Type + Content-Type + yHeaderStringapplication/json + +
5AcceptAcceptyHeaderStringapplication/json
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
동기화시간 + syncTime + long + 1480489063661 + Returns + sync time which will be used at next API call.
연락처 + 목록contactList + List + [
{"userID": + 753912291915206657},
{"userID": + 753912292411707393},
{"userID": + 753912844722900993},
{"userID": + 753913660166377473}
]
Returns + contact list
사용자ID + contactList:userID + long + 753912291915206657 + Returns + userID of contact.
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
/messenger/contact/api/v1.0/contact/o1/list + {
"syncTime": + 1480489063661",
"contactList": [
{"userID": 753912291915206657},
{"userID": 753912292411707393},
{"userID": 753912844722900993},
{"userID": 753913660166377473}
]
}
+
+

+
+
Login ID + List Search
+
+

POST + /messenger/contact/api/v1.0/profile/o1/search/loginid

+
+
+

SingleID (Knox Portal ID)를 이용한 사용자 + 검색

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorizationyHeaderStringBearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + Typex-device-type + yHeaderStringrelation +
3Device + IDx-device-idyHeaderString1234 + +
4Content Type + Content-Type + yHeaderStringapplication/json + +
5AcceptAcceptyHeaderStringapplication/json
6검색할 + 사용자 리스트singleIdList + yBodyList[
{"singleId" : + "test1.kim"},
{"singleId" : + "test2.lee"},
{"singleId" : + "test3.park"}
]
검색할 사용자 + 리스트
7검색할 + 사용자의 Knox Portal IDsingleIdList:singleId + yBodyStringtest1.kim + 검색할 사용자의 + Knox Portal ID
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
사용자조회결과 + userSearchResult + Object + + Returns + profile search result.
조회결과목록 + searchResultList + List + + Returns + users userID
사용자ID + userID + long + 753913659651002369 + Returns + users userID.
싱글ID + singleID + String + test1.kim + Returns + users Knox Suite ID
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/contact/api/v1.0/profile/o1/search/loginid HTTP/1.1 +
{
"singleIdList" : + [
{"singleId" : "test1.kim"},
{"singleId" : "test2.lee"},
{"singleId" : "test3.park"}
]
}
{
"userSearchResult": + {
"searchResultList": [
{
"userID": + 753913659651002369,
"singleID": + "test1.kim"
}
{
"userID": + 753913660166377473,
"singleID": + "test3.park"
}
],
"hasMore": + false

}
}
+
+

+
+
Device + registration
+
+

GET + /messenger/contact/api/v1.0/device/o1/reg

+
+
+

사용 기기를 등록 및 Knox Messenger 기기 인증에 + 사용될 x-device-id값 제공.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorizationyHeaderStringBearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + Typex-device-type + yHeaderStringrelation +
3Content Type + Content-Type + yHeaderStringapplication/json + +
4AcceptAcceptyHeaderStringapplication/json
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
디바이스서버ID + deviceServerID + long + 22222 + 등록된 + deviceID.
등록된 + 기기의 사용자IDuserID + long + 110101010 + Returns + users userID.
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
GET + /messenger/contact/api/v1.0/device/o1/reg HTTP/1.1{
“deviceServerID” : + 22222,
“userID” : 110101010
}
+
+
+
Error Code
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
403 + CFC-900003 + device + type is not invalid +
403 + CFC-900008 + exceeded + device reg limit +
403 + CFC-900009 + exceeded + device model length limit +
403 + CFC-900010 + Device + reg is not allowed +
+
+

+
+
Device + deregistration
+
+

/messenger/contact/api/v1.0/device/o1/delete +

+
+
+

등록된 기기를 해지. 접속 중인 기기를 해지할 경우 미인증 단말로 + 인식.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorizationyHeaderStringBearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + Typex-device-type + yHeaderStringrelation +
3Device + IDx-device-idyHeaderString1234 + +
4Content Type + Content-Type + yHeaderStringapplication/json + +
5AcceptAcceptyHeaderStringapplication/json
6등록 해지된 + deviceID.deviceServerID + yBodyLong10101010101 +
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + +
API 호출 성공 + 여부resultStringsuccess, + fail
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
{
POST + /messenger/contact/api/v1.0/device/o1/delete HTTP/1.1
Host : yyy.xxxxxx.com

{
“deviceList” : [
     { “deviceServerID” : 10101010101 + },
     { “deviceServerID” : + 10101010102 }
]
}}
-
+
+
+
Error Code
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + +
400CFC-900006parameter + deviceID is not registeredparameter + deviceID is not registered
+
+

+
+
Device use + Info
+
+

/messenger/contact/api/v1.0/device/o1/use/info +

+
+
+

본인 및 타인의 기기별 마지막 사용시간 조회.(Open API 기기 + 제외)

+

singleIdList는 최대 600개까지 입력 가능함.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorizationyHeaderStringBearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + Typex-device-type + yHeaderStringrelation +
3Device + IDx-device-idyHeaderString1234 + +
4Content Type + Content-Type + yHeaderStringapplication/json + +
5AcceptAcceptyHeaderStringapplication/json
6조회할 사용자 + 리스트.singleIdList + yBodyList[] + +
7조회할 사용자의 + Knox Suite IDsingleIdList.singleId + yBodyString[] + +
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
API 호출 성공 + 여부resultString + success, + fail +
사용자별 검색 + 결과userDeviceList + String + [ + ] +
사용자의 + userIDuserIDLong + 10101010101 +
사용자의 Knox + Suite IDsingleIDString + test1.kim +
사용자의 + deviceListdeviceList + List + [ + ] +
사용자의 + deviceIDdeviceServerID + Long + 20490 +
마지막 + 접속시간conn_date + String + 2016-06-22 PM + 04:22:46 +
OS + TypedeviceOsType + String + Windows, + Android,iOS +
Device + TypedeviceType + String + pc, + mobile +
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
{
POST + /messenger/contact/api/v1.0/device/o1/use/info HTTP/1.1

{
     "singleIdList" : [
         {"singleId" : + "test1.kim"},
         {"singleId" : + "test2.lee"},
         {"singleId" : + "test3.park"}
     + ]
}
Host : + yyy.xxxxxx.com}}
{
{
     "userDeviceList": [
     {
         "userID": + 761258979308365297,
         "singleID": + "test1.kim",
         "deviceList": + [
         + {
             + "deviceServerID": 1000003610,
             + "conn_date": "2016-06-22 PM 04:22:46",
             + "deviceType": "pc",
             + “deviceOsType”: “Windows”
         }
         ]
     },
     {
     "userID": + 755053073097855041,
     + "singleID": "test2.lee",
     + "deviceList": [
     + {
         + "deviceServerID": 20490,
         "deviceType": + "mobile",
“deviceOsType”: “Android”
     },
+      {
     + "deviceServerID": 1000006058,
+      "deviceType": "mobile"
“deviceOsType”: “iOS”
+      }
+      ]
     + },
     {
     "userID": + 755053029387931649,
     + "singleID": "test3.park",
     + "deviceList": []
}
]
}
}
+
+
+
Error Code
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + +
+
+

+
+
FILE + SERVER TIME(KEY)
+
+

GET + /messenger/file/api/v1.0/file/v1/getCurrentTime

+
+
+

Secure API 호출 시 사용되는 x-request-time에 대입할 서버 + 측 현재 시간(UTC) 및 암호화 키를 반환한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1AcceptAcceptHeaderStringapplication/json + application/json +
2Access + tokenAuthorization + yHeaderStringBearer + ce1d72e2a6c96cc09db7c837b1e44fc1[평문] Access + Token.
3Access + tokenx-access-token + yHeaderStringce1d72e2a6c96cc09db7c837b1e44fc1 + [평문] Access + Token - Authorization과 동일한 값이나 Bearer는 제외
4Device ID + x-device-id + yHeaderString131314850 + [평문] Device + registration API를 통해 얻은 deviceServerID를 사용
5Device + Typex-device-type + yHeaderStringrelation + [평문] Device type을 + 사용. - Valid Values: [relation]
6키문자열(파일명)wordyPathStringr1234562312121.gif + [평문] 파일명을 이용해서 암호화 키 문자열로 사용
- + Upload : [file name] Download : [fileid]
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
서버시간serverTime + String1487298788653 + 서버측 현재 + 시간(UTC)
암호키값wordString!2#4%6&8(0gif.gif1@3$5^7*9)!2#4% + 암호키값
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
GET + /messenger/file/api/v1.0/file/v1/getCurrentTime HTTP/1.1 Host : File + Server Authorization: Bearer f5fe27195fb2523cee1758c162a9f60 x-access-token: + f5fe27195fb2523cee1758c162a9f60 x-device-id: 131314850 x-device-type: + relation  [Upload] GET + /messenger/file/api/v1.0/file/v1/getCurrentTime?word=r1234562312121.gif + HTTP/1.1 Host : File Server Authorization: Bearer + f5fe27195fb2523cee1758c162a9f60 x-access-token: + f5fe27195fb2523cee1758c162a9f60 x-device-id: 131314850 x-device-type: + relation  [Download] GET + /messenger/file/api/v1.0/file/v1/getCurrentTime?word=70wT1NHM0y0TF HTTP/1.1 Host : + File Server Authorization: Bearer + f5fe27195fb2523cee1758c162a9f60 x-access-token: + f5fe27195fb2523cee1758c162a9f60 x-device-id: 131314850 x-device-type: + relation[success] HTTP/1.1 + 200 OK Content-Type: application/json Server: File + Server { "serverTime": "1487298788653", "word": + "!2#4%6&8(0gif.gif1@3$5^7*9)!2#4%" }  [error] HTTP/1.1 400 Bad + Request Content-Type: application/json Content-Length: 97 Server: File + Server Connection: close  { "svrTime": "2016-02-11 + 12:34:03.997", "errorCode": "CFI-10001", "errorMessage": " x-device-id is + mandatory" }
+
+
+
+

Error Code

+
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
200Success +
204No + Content +
301Moved + Permanently +
302Found +
307Temporary + redirect +
400CFI-10001{argument} is + mandatory +
400CFI-10002{argument} is + invalid +
400BLUE-999999Device is not + registered +
400BLUE-444401Email address is not + verified +
401Unauthorized +
403Forbidden +
500Internal + Server Error +
+
+

+
+
SECURE + UPLOAD FILE
+
+

PUT + /messenger/file/api/v1.0/file/v1s/file/{filename}

+
+
+

파일 서버에 파일이 업로드 되고 해당 파일을 다운로드 받을 수 있는 URL을 + 반환한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1AcceptAcceptHeaderStringapplication/json + 응답에 허용되는 특정 미디어 + 유형을 지정. - Default: application/json - Valid Values: [application/json, + application/xml]
2Content-Type + Content-Type + HeaderStringbinary/octet-stream + Content-Type - + Default: binary/octet-stream - Valid Values: MIME types
3Content-Length + Content-Length + yHeaderString32121 + 업로드 할 파일의 크기 + (bytes) Valid Values: decimal number
4Access + tokenAuthorization + yHeaderStringBearer + ce1d72e2a6c96cc09db7c837b1e44fc1[평문] Access + Token
5Access + tokenx-access-token + yHeaderStringBublCtBL1kiiUfArCc1ECFChhKGKrdc5liIrsFEuc1kh2pgPShAar9x81edAn1zd + [암호화] Access + Token을 aes256으로 암호화 해야함 - Token type (“Bearer”)를 제외한 Token Value만 Encrypt 처리 +
6Device ID + x-device-id + yHeaderStringwsXERf15w7AZy9m0xJVg+g== + [암호화] Device + registration API를 통해 얻은 deviceServerID를 AES256으로 암호화해서 사용
7Device + Typex-device-type + yHeaderString9JtF6T25SvaSnkgmbkIZsA== + [암호화] Device type을 + AES256으로 암호화해서 사용. - Valid Values: [relation]
8Server + Timex-request-time + yHeaderStringJVdr5iiTe6ogMBoGnwkhOg== + [암호화] File Server + Time(key) API를 통해 얻은 serverTime을 AES256으로 암호화해서 사용
9File + NamefilenameyHeaderStringr1500944966271.jpg + [평문] 업로드 시 파일이름은 + 반드시 다음의 Rule을 준수해서 지정. - Rule : “r” + TimeStamp + Extension
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + +
다운로드 경로 + download_url + Stringhttps://yyy.xxxxxx.com/file/v1s/file/70wT1NHM0y0TF + 파일 다운로드 경로 +
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
PUT + /messenger/file/api/v1.0/file/v1s/file/ r1500944966271.jpg HTTP/1.1 Host : File + Server Content-Length: 11434 Authorization: Bearer + f5fe27195fb2523cee1758c162a9f60 x-access-token: + BublCtBL1kiiUfArCc1ECFChhKGKrdc5liIrsFEuc1kh2pgPShAar9x81edAn1zd x-device-id: + wsXERf15w7AZy9m0xJVg+g== x-device-type: + 9JtF6T25SvaSnkgmbkIZsA== x-request-time: JVdr5iiTe6ogMBoGnwkhOg==  [11434 + bytes of object data][success] HTTP/1.1 + 200 OK Content-Type: application/json Server: File + Server { "download_url": + "https://yyy.xxxxxx.com/file/v1s/file/70wT1NHM0y0TF" }  [error] HTTP/1.1 + 400 Bad Request Content-Type: application/json Content-Length: 98 Server: + File Server Connection: close { "svrTime": "2015-02-11 + 12:32:30.234", "errorCode": "CFI-10002", "errorMessage": "filename is + invalid" }
+
+
+
+

Error Code

+
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
200Success +
204No + Content +
301Moved + Permanently +
302Found +
307Temporary + redirect +
400CFI-10001{argument} is + mandatory +
400CFI-10002{argument} is + invalid +
400CFI-10003File size is + overflow +
400CFI-10004File size is + empty +
400CFI-10005File format is + error +
400CFI-10006File format is not + supported +
400CFI-10011Infected File + +
400CFI-10013No + permission to upload a file +
400BLUE-999999Device is not + registered +
400BLUE-444401Email address is not + verified +
401Unauthorized +
403Forbidden +
500Internal + Server Error +
+
+

+
+
SECURE DOWNLOAD FILE
+
+

GET + /messenger/file/api/v1.0/file/v1s/file/{file_id}

+
+
+

파일 서버에서 파일을 다운로드 한다. 만약 파일을 다운로드 하려면, + 당신의 application은 반드시 302 code responses를 취급해야 한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorization + yHeaderStringBearer + ce1d72e2a6c96cc09db7c837b1e44fc1[평문] Access + Token
2Access + tokenx-access-token + yHeaderStringBublCtBL1kiiUfArCc1ECFChhKGKrdc5liIrsFEuc1kh2pgPShAar9x81edAn1zd + [암호화] Access + Token을 aes256으로 암호화 해야함 - Token type (“Bearer”)를 제외한 Token Value만 Encrypt 처리 +
3Device ID + x-device-id + yHeaderStringwsXERf15w7AZy9m0xJVg+g== + [암호화] 기기 등록을 통해 + 얻은 deviceServerID를 aes256으로 암호화 해야함.
4Device + Typex-device-type + yHeaderString9JtF6T25SvaSnkgmbkIZsA== + [암호화] 기기 타입을 + aes256으로 암호화 해야함. - Valid Values: [relation]
5Server + Timex-request-time + yHeaderStringJVdr5iiTe6ogMBoGnwkhOg== + [암호화] 파일 서버에서 받은 + 서버시간을 AES256 Encrypt 처리하여 지정
6파일IDfile_idyPathString70wT1NHM0y0TF + [암호화] Secure + Upload File API를 통해 얻은 download_url의 맨 뒤 file ID값을 AES256으로 암호화해서 사용
7썸네일 + 크기thumbParameter + String160x160 + 다운로드 할 썸네일의 사이즈 + 지정. - Valid Values: [160x160]
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + +
(데이터) + (payload) + Binary + 파일 바이너리 + 데이터
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
GET + /messenger/file/api/v1.0/file/v1s/file/70wT1NHM0y0TF?thumb=160x160 HTTP/1.1 Host : + File Server Authorization: Bearer + f5fe27195fb2523cee1758c162a9f60 x-access-token: + BublCtBL1kiiUfArCc1ECFChhKGKrdc5liIrsFEuc1kh2pgPShAar9x81edAn1zd x-device-id: + wsXERf15w7AZy9m0xJVg+g== x-device-type: + 9JtF6T25SvaSnkgmbkIZsA== x-request-time: JVdr5iiTe6ogMBoGnwkhOg==[success] HTTP/1.1 + 200 OK Content-Length: 434234 Content-Type: image/jpeg Connection: + close Server: File Server  [434234 bytes of object + data]  [error] HTTP/1.1 400 Bad Request Content-Type: + application/json Content-Length: 97 Server: File Server Connection: + close {"svrTime": "2015-02-11 12:34:03.997","errorCode": "CFI-10002", + "errorMessage": "file_id is invalid"}
+
+
+
+

Error Code

+
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
200Success +
204No + Content +
301Moved + Permanently +
302Found +
307Temporary + redirect +
400CFI-10001{argument} is + mandatory +
400CFI-10002{argument} is + invalid +
400CFI-10007File has expired + +
400CFI-10012V7 + Empsearch API error +
400BLUE-999999Device is not + registered +
400BLUE-444401Email address is not + verified +
401Unauthorized +
403Forbidden +
500Internal + Server Error +
+
+

+
+
Get Keys +
+
+

/messenger/msgctx/api/v1.0/key/getkeys

+
+
+

Device의 channel auth Key and device key를 조회한다. +

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorization + yHeader + String + Bearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + IDx-device-id + yHeader + Long1234 +
3Content + TypeContent-Type + nHeader + String + application/json +
4AcceptAcceptnHeader + Stringapplication/json + +
5Device Type + x-device-type + nHeader + Stringmobilemobile or pc or + relation
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Device의 + Message keykey + String4cc5d9fa5d44819357618b8a8d8c21326df20fa95cd5fd6da0f9cdd030d1a9b7c31df7eb7080b9c3b62ee0348eb1d86b + +
Device의 Expired + message keyexpiredkey + String + 4cc5d9fa5d44819357618b8a8d8c21326df20fa95cd5fd6da0f9cdd030d1a9b7c31df7eb7080b9c3b62ee0348eb1d86b + optional
Channel Auth + keychannelauthkey + String + 537461636b5472616365456c656d656e745b5d20656c656d73203d2065782e67696e742066696e616c4c656e203d2070 +
Message + key의 expiring Timestamp 값keyexpirationtimestamp + Long + 1718094662042 +
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
GET /messenger/msgctx/api/v1.0/key/getkeys
HTTP/1.1
Host : + yyy.xxxxxx.com
Content-type: + application/json
Accept: + application/json
x-device-type : + mobile
x-device-id : 1234
Authorization : Bearer fc55e83b7dea72ebe8f4f0dee2a2c4
+
HTTP/1.1 200 OK
{
    “key” : + “4cc5d9fa5d44819357618b8a8d8c21326df20fa95cd5fd6da0f9cdd030d1a9b7c31df7eb7080b9c3b62ee0348eb1d86b”,
    “channelauthkey” : + “537461636b5472616365456c656d656e745b5d20656c656d73203d2065782e67696e742066696e616c4c656e203d2070”
}
+
+
+
Error Code
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + +
400 + BLUE-999999 + Not exist + deviceId +
400 + BMC-300150 + Not Exist + Channel Auth Key. +
+
+

+
+
Chat + Active Member
+
+

/messenger/msgctx/api/v1.0/chat/activemember +

+
+
+

채팅방의 참여자 수와 User ID를 조회한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
No.PropertiesAttributeMandatoryParameter TypeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1Access + tokenAuthorization + y + Header + String + Bearer + fc55e83b7dea72ebe8f4f0dee2a2c4
2Device + IDx-device-id + y + Header + Long + 1234 +
3Content + TypeContent-Type + n + Header + String + application/json +
4Accept + Accept + n + Header + String + application/json +
5Device + Typex-device-type + n + Header + String + mobile + mobile or pc or + relation
6Chatroom + Idchatroomid + y + Query + Long + 332321144605 + max 19 number + string
+
+
+
+

Response Parameter

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
현재 + 대화방에 참여중인 멤버의 수activemembercount + Integer + 10 + +
현재 + 대화방에 참여중인 멤버의 User ID List.activememberlist + Long + + List +
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
GET + /messenger/msgctx/api/v1.0/chat/activemember?chatroomid=1221232323
HTTP/1.1
Host : + yyy.xxxxxx.com
Content-type: + application/json
Accept: + application/json
x-device-type : + mobile
x-device-id : 1234
Authorization : Bearer fc55e83b7dea72ebe8f4f0dee2a2c4
+
HTTP/1.1 200 OK
{
    “activemembercount”:5,
    “activememberlist” : [
        753913371694206977,
        753915435136061441,
        753915446684553217,
        753916848394735617,
        753916967328419841
    ]
}
+
+
+
Error Code
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + +
400 + BLUE-999999 + Not + exist deviceId +
+
+

+
+
메시지 + API 공통 포맷
+
+

아래 목록의 API들은 메시지군의 API들로써 공통적인 포맷을 + 갖는다. (payload data 암호화, 공통 error 코드)
- 대화방 생성
- 메시지 발신
- 대화상대 초대
- 대화상대 내보내기
- 대화방 + 삭제
- 메시지 발신취소
- 대화방명 변경
- 방장 변경
- 대화방 나가기
- 메시지 읽음 Count 조회

+
+
+

payload data 암호화

+
+
+

API호출에 사용되는 Request Payload data와 + Response Payload data는 암호된 값을 사용한다.
각 API 기능별로 Payload 내에 적재된 RequestBody와 ResponseBody내용을 전송단에서 + Aes256암호화 > Base64암호화를 거쳐 데이터를 보내며, 수신단에서 Base64복호화 > Aes256복호화를 거쳐 암호화를 해제함으로써 데이터 추출할 수 + 있다.
기능별 API 명세에서는 각 API별로, 암호화가 해제된 평문 기준의 RequestBody, ResponseBody 명세에 대한 설명이 기재되어 있다.

+

+
+
+

연계 시스템측에서 사용하게 되는 RequestBody 암호화 및 + ResponseBody 복호화에 대한 예시는 아래와 같다.

+
+
+
+ + + + + + + + + + + +
[RequestBody + 암호화 예시][ResponseBody + 복호화 예시]
+
+
+ + + + + + + + + + + +
적용전 (RequestBody평문): {"requestId": 1578016699286727, "chatroomId": + 99343295704997888}
암호화 1단계: AES256 + 인코딩
암호화 2단계: BASE64 인코딩
적용후 (RequestBody암호문): + IN/WslquK+4b3I+I3lJF1UyiYksAhZRncHL5axCGpJur9U/LabuKIIo7OKEQe1JOSaCb3szhWphL2Ufhj86dcClTXz5b+AVYDq6LRbd4zBQ=
+
적용전 (ResponseBody-암호문): + 7Q9FCL95U+5FIFGcZbG9Y6wvpod95dfH+pxDZVb3HnJzz/U+nZAG3tQ+NPOUprKaMZ3rTEPbYsMr89KIWEdpog== +
복호화 1단계: AES256 디코딩
복호화 2단계: AES256 디코딩
적용후 + (ResponseBody-평문): { "code": 3003, "msg": "All receivers are invalid." + }
+
+
+
+

※ 예시에 사용된 메시지 키 값은 아래와 같으며, 실사용시 메시지 + 키값을 "메시지서버 암호화 Key 조회" api로 조회하여 사용하여야 한다.(메시지 key값은 단말별로 부여됨)
- 예시에 사용된 메시지 key: + "b6d06ce799b97b58aa606e393c6a18ee1f6008726b59072036207ccafe6443b9b3c546f665fdae562a7d8d35f4bca16e"
+

+

+

※ 암복호화 모듈 구현은 샘플 코드를 참고 바람.

+
+
+

메시지 공통 Error Code

+
+
+
+ + + + + + + + + + + + + + + +
HTTP응답코드에러코드에러메시지조치방안
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
2001000Success +
2001001Detected + some invalid receivers. (Success partial) +
204No + Content +
4002001Wrong + token +
4002002Not + registered requester. +
4003003Invalid + receiver. +
4003004Receiver is + not enabled. +
4003005Exceeded + chatroom count limit. +
4003009Membership + violation detected. +
4003106All + receivers are invalid. +
4004001Wrong + parameter value. +
4004003Wrong body! (Fail decrypt about message body.)
해당 에러 발생 시 6.1 GET Keys API를 수행하여 최신 Key value를 response 받아서 + RequestBody 암호화를 수행할 것을 권장함.
+
4006001General DAO + error +
4007001Not bounded + device. +
4009000Internal + server error. +
4009001Exceeded + session count limit. +
4009002Short Term + DDoS detected. +
4009003Long Term DDoS detected.
(정책 시간 동안 + api 사용 금지 ex. 12시간)
+
401Unauthorized +
403Forbidden +
500Internal + Server Error +
+
+

+
+
대화방 + 생성
+
+

POST + /messenger/message/api/v1.0/message/createChatroomRequest

+
+
+

신규 대화방을 생성한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY:requestId + yLong1302575819285 + Packet별로 + Unique한 Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방유형 + BODY:chatType + yInteger2Chat Type, 대화방 유형
“단방향(공지type)” + 외부연계 사용 시 2,5만 사용

0: (SINGLE) – 1:1 대화
1: (GROUP) – + Group 대화
2: (BROADCAST GROUP) Group + 공지방(2인이상)
5: (BROADCAST SINGLE) 1:1 + 공지방
(3)참여자목록 + BODY:receivers + yList + [753917009235808257,753916848517419009] + 채팅 참여자들의 User + Id를 리스트 형태로 작성
(4)대화방이름 + BODY:chatroomTitle + String"dev server + team"최대 길이 128 자 + (utf8mb4)
+
+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 + Id
결과 + result + 결과
결과:코드 + result:code + Integer1000 + 결과 코드 +
결과:(에러)내용 + result:msg + String"Detected + some invalid receivers."결과 내용 +
결과:참여불가상세 + result:wrongReceiverDetail +
결과:참여불가상세:잘못된 + 사용자 목록result: + wrongReceiverDetail: invalidReceiversList + [897548937598437953, + 89754354568789456]잘못된 유저정보로 대화방에 입장할 수 없는 사용자
* 결과 + 코드 1001/3003 리턴
결과:참여불가상세:정책상 + 불허된 목록result: + wrongReceiverDetail: organizationViolatedList + [897548937598437953, + 89754354568789456]정책상 대화할 수 없는 사용자 (회사가 다르면 대화가 불가함)
* 결과 코드 1001/3003 리턴
결과:참여불가상세:단말 + 미등록자 목록result: + wrongReceiverDetail: disabledReceiversList + [897548937598437953, + 89754354568789456]등록된 단말이 없어서 대화에 참여할 수 없는 사용자
* 결과 + 코드 1001/3003 리턴
결과:참여불가상세:자통법상 + 차단된 목록result: + wrongReceiverDetail: blockedGroupList + [897548937598437953, + 89754354568789456]자본시장통합법에 의거 대화를 할 수 없는 관계의 사용자
* + 결과 코드 1001/3003 리턴
대화방 + 생성시간createTimeMillis + Long1578386757248 + 대화방 + 생성시간
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/createChatroomRequest + HTTP/1.1

headers: + {"Accept": "application/json", "Authorization": "Bearer + ed114dc382ca16d5b43154fe5832a7", "Content-Type": "application/json", "x-device-id": + "1000145874", "Content-Length": "172"}

body(암호화전): {"chatType": 2, + "requestId": 1578016699286727, + "receivers":[753917009235808257,753916848517419009]}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId": 1578016699286727, "chatroomId": 99343295704997888, + "result": {"code": 1000, "wrongReceiverDetail": {}}, createTimeMillis": + 1578016699269}
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
메시지 + 발신
+
+

POST + /messenger/message/api/v1.0/message/chatRequest

+
+
+

메시지를 발송한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY: + requestIdyLong# + {"requestId": 15784605065976949, "chatroomId": 99343295704997888, "chatMessageParams": + [{"msgId": 15784605065976949, "msgType": 0, "chatMsg": "blah~ blah~", "msgTtl": + 7200}]}Packet별로 Unique한 + Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY: + chatroomIdyLong99343295704997888 + 대화방 ID
(3)BODY: + chatMessageParamsyList + 최대 10개
(3-1)BODY: + chatMessageParam: msgIdyLong1578409921352 + 메시지별 Unique한 ID, + Milliseconds 형식 (ex. 1302575819285 )
(3-2)BODY: + chatMessageParam: msgTypeyInteger0Msg Type, 메시지 유형

0: (TEXT) ? Common text message
1: + (MEDIA) ? MultiMedia message (file, video)
7: (RTF) + - Excel message
8: (NCUSTOM) - Message with json + format
(3-3)BODY: + chatMessageParam: chatMsgyString"Hello + world!"메시지 내용 (최대 + 3,300자)
(3-4)BODY: + chatMessageParam: msgTtlInteger7200메시지 서버 저장 기간 (Min : 3600 sec / Max : according to company policy / + Default : 259200 sec)
* If an unacceptable value is + entered, the default value
+
+
+
+

# {"requestId": + 15784605065976949, "chatroomId": 99343295704997888, "chatMessageParams": [{"msgId": 15784605065976949, + "msgType": 0, "chatMsg": "blah~ blah~", "msgTtl": 7200}]}

+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 Id +
결과 + result + Result
* If Nth message in 10 is + failed, It is cause of failure for the message.
결과: 코드 + result: + codeInteger1000 + Result + code
결과: + (에러)내용result: + msgStringResult + message
결과: + 메시지처리상세result: + processedMessageEntriesList +
결과: 메시지처리상세: + 메시지IDresult: + processedMessageEntrie: msgIdLong전달된 메시지 ID +
결과: 메시지처리상세: + 전달시간result: + processedMessageEntrie: sentTimeLong1578449866003 + 전달시간 (서버 기준)
* If it is failed to + sending message, returns 0
결과: + 참여불가상세result: + wrongReceiverDetail
결과: 참여불가상세: + 잘못된 사용자 목록result: + wrongReceiverDetail: invalidReceiversList + [897548937598437953, + 89754354568789456]잘못된 유저 정보로 메시지를 전달할 수 없는 사용자
* It + is available for ResultCode 1001/3003
결과: 참여불가상세: + 단말 미등록자 목록result: + wrongReceiverDetail: disabledReceiversList + [897548937598437953, + 89754354568789456]등록된 단말이 없어서 메시지를 전달할 수 없는 사용자
* It + is available for ResultCode 1001/1003
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/chatRequest + HTTP/1.1
headers: {"Accept": "application/json", + "Authorization": "Bearer ed114dc382ca16d5b43154fe5832a7", "Content-Type": + "application/json", "x-device-id": "1000145874", "Content-Length": + "172"}

body(암호화전): {"requestId": 15784605065976949, "chatroomId": + 99343295704997888, "chatMessageParams": [{"msgId": 15784605065976949, "msgType": 0, + "chatMsg": "blah~ blah~", "msgTtl": 7200}]}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId":15784605065976949,"chatroomId":99343295704997888,"result":{"code":1000,"wrongReceiverDetail":{}},"processedMessageEntries":[{"msgId":15784605065976949,"sentTime":1578460506612}]}
+
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
대화상대 + 초대
+
+

POST + /messenger/message/api/v1.0/message/inviteRequest

+
+
+

대화 상대를 초대한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY: + requestIdyLong1302575819285 + Packet별로 Unique한 + Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY: + chatroomIdyLong99343295704997888 + 대화방 ID +
(3)초대자목록 + BODY: + invitingMembersyList + [773887412433063937, + 74124330639377655]초대 대상자 User + Id
+
+
+
+

# {"requestId": 15784506666772442, + "chatroomId": 99343295704997888, "invitingMembers": [773887412433063937]}

+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 + Id
초대받은시간 + sentTime + Long1578450666592 + 서버로부터 초대받은 + 시간
결과 + result + Result
* If Nth message in 10 is + failed, It is cause of failure for the message.
결과: + 코드result: + codeInteger1000 + Result + code
결과: + (에러)내용result: + msgStringResult + message
결과: + 참여불가상세result: + wrongReceiverDetail
결과: 참여불가상세: + 잘못된 사용자 목록result: + wrongReceiverDetail: invalidReceiversList + [897548937598437953, + 89754354568789456]잘못된 유저 정보로 메시지를 전달할 수 없는 사용자
* It + is available for ResultCode 1001/3003
결과: 참여불가상세: + 정책상 불허된 목록result: + wrongReceiverDetail: organizationViolatedList + [897548937598437953, + 89754354568789456]정책상 대화할 수 없는 사용자 (회사가 다르면 대화가 불가함)
* It is available for ResultCode 1001/3003
결과: + 참여불가상세: 단말 미등록자 목록result: + wrongReceiverDetail: disabledReceiversList + [897548937598437953, + 89754354568789456]등록된 단말이 없어서 메시지를 전달할 수 없는 사용자
* + It is available for ResultCode 1001/1003
결과: + 참여불가상세: 이미 참여한 목록result: + wrongReceiverDetail: existingList + [897548937598437953, + 89754354568789456]이미 대화방에 참여중인 사용자
* It is available + for ResultCode 1001/3003
결과: + 참여불가상세: 인원제한으로 누락된 목록result: + wrongReceiverDetail: interruptedReceiversList + [897548937598437953, + 89754354568789456]대화방의 멤버가 최대 인원을 넘어서 초대할 수 없는 사용자
* + It is available for ResultCode 1001/3003
결과: + 참여불가상세: 자통법상 차단된 목록result: + wrongReceiverDetail: blockedGroupList + [897548937598437953, + 89754354568789456]자본시장통합법에 의거 대화를 할 수 없는 관계의 사용자
* + It is available for ResultCode 1001/3003
+
+
+
+

# + {"requestId":15784506666772442,"chatroomId":99343295704997888,"result":{"code":1000,"wrongReceiverDetail":{}},"sentTime":1578450666592} +

+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/inviteRequest + HTTP/1.1
headers: {"Accept": "application/json", + "Authorization": "Bearer ed114dc382ca16d5b43154fe5832a7", "Content-Type": + "application/json", "x-device-id": "1000145874", "Content-Length": + "172"}
body(��ȣȭ��): {"requestId": + 15784506666772442, "chatroomId": 99343295704997888, "invitingMembers": + [773887412433063937]}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server
{"requestId":15784506666772442,"chatroomId":99343295704997888,"result":{"code":1000,"wrongReceiverDetail":{}},"sentTime":1578450666592}
+
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
대화상대 + 내보내기
+
+

POST + /messenger/message/api/v1.0/message/removeMemberRequest

+
+
+

대화 상대를 방출한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY:requestId + yLong1302575819285 + Packet별로 Unique한 + Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY:chatroomId + yLong99343295704997888 + 대화방 ID +
(3)방출자 목록 + BODY:removingMembers + yList + [753917009235808257,753916848517419009] + 방출할 대상자 User Id를 + 리스트 형태로 작성
+
+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 + Id
요청시간 + + 1578450666592 + 서버로 요청받은 + 시간
결과 + result + 결과
결과:코드 + result:code + Integer1000 + 결과 코드 +
결과:(에러)내용 + result:msg + String결과 내용 +
결과:비정상수신자상세 + result:wrongReceiverDetail +
결과:비정상수신자상세:미참여 + result: + wrongReceiverDetail:notExistingList + [897548937598437953, + 89754354568789456]내보내기 대상자 중 대화방 멤버가 아닌 사용자
* 결과 코드 + 1001/3003 리턴
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/removeMemberRequest + HTTP/1.1

headers: + {"Accept": "application/json", "Authorization": "Bearer + ed114dc382ca16d5b43154fe5832a7", "Content-Type": "application/json", "x-device-id": + "1000145874", "Content-Length": "172"}

body(암호화전): {"requestId": + 15784562811364493, "chatroomId": 99343295704997888, "removingMembers": + [773887412433063937]}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId":15784562811364493,"chatroomId":99343295704997888,"result":{"code":1000},"sentTime":1578456281137}
+
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
대화방 + 삭제
+
+

POST + /messenger/message/api/v1.0/message/destroyChatroomRequest

+
+
+

대화방을 삭제한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY:requestId + yLong1302575819285 + Packet별로 + Unique한 Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY:chatroomId + yLong99343295704997888 + 대화방 ID +
+
+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 + Id
결과 + result + + 결과 +
결과:코드 + result:code + Integer1000 + 결과 코드 +
결과:(에러)내용 + result:msg + String + 결과 내용 +
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/destroyChatroomRequest + HTTP/1.1

headers: + {"Accept": "application/json", "Authorization": "Bearer + ed114dc382ca16d5b43154fe5832a7", "Content-Type": "application/json", "x-device-id": + "1000145874", "Content-Length": "172"}

body(암호화전){"requestId": + 15784562811364493, "chatroomId": 99343295704997888}
HTTP/1.1 200 OK Content-Type: application/json Server: Message + Server
{"requestId":15784562811364493,"chatroomId":99343295704997888,"result":{"code":1000}}
+
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
메시지 + 발신취소
+
+

POST + /messenger/message/api/v1.0/message/recallMessageRequest

+
+
+

발송된 메시지를 취소한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY:requestId + yLong1302575819285 + Packet별로 Unique한 + Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY:chatroomId + yLong99343295704997888 + 대화방 ID +
(3)메시지ID + BODY:msgId + yLong15784605065976949 + 발신 취소 대상 메시지 + ID
(4)원본메시지 + 발송시간BODY:sentTime + yLong1578460506612 + 원본 메시지 발송시간 + (메시지 발송 ChatReply 의 sentTime)
(5)미디어정보 + BODY:mediaInfo + String"http:// + sqaproxy.samsung.net/file/v1/file/esK93SYcoqeE8ETvJgUdeg"발신취소 대상 메시지가 + MEDIA 타입인 경우 삭제 대상 파일의 "download url"
+
+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 + Id
결과 + result + 결과
결과:코드 + result:code + Integer1000 + 결과 코드 +
결과:(에러)내용 + result:msg + String결과 내용 +
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/recallMessageRequest + HTTP/1.1

headers: + {"Accept": "application/json", "Authorization": "Bearer + ed114dc382ca16d5b43154fe5832a7", "Content-Type": "application/json", "x-device-id": + "1000145874", "Content-Length": "172"}

body(암호화전): {"requestId": + 15784610001948974, "chatroomId": 99343295704997888, "msgId": 15784605065976949, + "sentTime": 1578460506612}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId":15784610001948974,"chatroomId":99343295704997888,"result":{"code":1000}}
+
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
대화방명 변경
+
+

POST + /messenger/message/api/v1.0/message/changeChatroomMetaRequest

+
+
+

대화방의 Meta 정보를 변경한다. (대화방명 변경만 + 가능)

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY: + requestIdyLong1302575819285 + Packet별로 + Unique한 Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY: + chatroomIdyLong99343295704997888 + 대화방 + ID
(3)대화방 + 이름BODY: + titleString"dev + server team"변경하고자 하는 + 대화방명
+
+
+
+

# {"requestId": + 15784610001948974, "chatroomId": 99343295704997888, "title": "메시지 테스트방1"}

+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 + Id
결과 + result + + Result +
결과: + 코드result: + codeInteger1000 + Result + code
결과: + (에러)내용result: + msgString + Result + message
대화방 + 변경시간changeTimeMillis + Long1578386757248 + 대화방 + 속성(이름)이 변경된 시간
+
+
+
+

# {"requestId": + 15784610001948974, "chatroomId": 99343295704997888, "result": {"code": 1000}, changeTimeMillis": + 1578016699269}

+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/changeChatroomMetaRequest + HTTP/1.1
headers: {"Accept": "application/json", + "Authorization": "Bearer ed114dc382ca16d5b43154fe5832a7", "Content-Type": + "application/json", "x-device-id": "1000145874", "Content-Length": + "172"}

body(암호화전): {"requestId": 15784610001948974, "chatroomId": + 99343295704997888, "title": "메시지 테스트방1"}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId": 15784610001948974, "chatroomId": 99343295704997888, + "result": {"code": 1000}, changeTimeMillis": 1578016699269}
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
방장 + 변경
+
+

POST + /messenger/message/api/v1.0/message/changeOwnerRequest

+
+
+

대화방의 방장을 변경한다. (ChatType이 0: (1:1 + 대화방), 1: (Group 대화방)에서만 지원됨)

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY: + requestIdyLong# + {"requestId": 15784610001948974, "chatroomId": 99343295704997888, "newOwner": + 753917009235808257}Packet별로 + Unique한 Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY: + chatroomIdyLong99343295704997888 + 대화방 + ID
(3)새방장ID + + Long753917009235808257 + 새로운 + 방장ID
+
+
+
+

# {"requestId": + 15784610001948974, "chatroomId": 99343295704997888, "newOwner": 753917009235808257}

+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 생성된 대화방 + Id
결과 + result + + Result +
결과: + 코드result: + codeInteger1000 + Result + code
결과: + (에러)내용result: + msgString + Result + message
요청시간 + sentTime + Long1578386757248 + 서버에서 해당 + Request를 받은 시간
+
+
+
+

{"requestId": + 15784610001948974, "chatroomId": 99343295704997888, newOwner": 753917009235808257}

+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/changeOwnerRequest + HTTP/1.1
headers: {"Accept": "application/json", + "Authorization": "Bearer ed114dc382ca16d5b43154fe5832a7", "Content-Type": + "application/json", "x-device-id": "1000145874", "Content-Length": + "172"}

body(암호화전): {"requestId": 15784610001948974, "chatroomId": + 99343295704997888, "newOwner": 753917009235808257}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId": 15784610001948974, "chatroomId": 99343295704997888, + "result": {"code": 1000}, newOwner": 753917009235808257}
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
대화방 나가기 +
+
+

POST + /messenger/message/api/v1.0/message/endChatRequest

+
+
+

대화방에서 퇴장한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청IDBODY:requestId + yLong1302575819285 + Packet별로 Unique한 Id + Milliseconds 형식 (ex. 1302575819285 )
(2)BODY:endChatEntries + yList +
(2-1)퇴장할 + 대화방 IDBODY:endChatEntriy:chatroomId + yLong99343295704997888 + 퇴장할 대화방 ID
+
+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청IDrequestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
결과result + 결과
결과:코드result:code + Integer1000결과 코드
결과:(에러)내용 + result:msg + String결과 내용
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/endChatRequest + HTTP/1.1

headers: + {"Accept": "application/json", "Authorization": "Bearer + ed114dc382ca16d5b43154fe5832a7", "Content-Type": "application/json", "x-device-id": + "1000145874", "Content-Length": "172"}

body(암호화전): {"requestId": + 15784610001948974, "endChatEntries":[{"chatroomId": + 99343295704997888}]}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId": 15784610001948974, "result": {"code": + 1000}}
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+

+
+
메시지 읽음 + Count 조회
+
+

POST + /messenger/message/api/v1.0/message/messageReadCountRequest

+
+
+

발신 메시지를 읽은 사용자의 수를 조회한다.

+
+
+

Request Parameter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeNo.PropertiesAttributeMandatoryData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header1응답 허용 + 타입Accept + String"application/json" + Default: application/json
Valid + Values: [application/json, application/xml]
2첨부데이터타입 + Content-Type + yString"application/json" + Payload의 content type 명시
ex) + application/json
3인증토큰 + Authorization + yString"Bearer + f5fe27195fb2523cee1758c162a9f60"[평문] Access Token (발급 + 받은 Access Token)
4단말IDx-device-id + yString"104032854"[평문] + 연계시스템용으로 등록한 단말 ID ("메신저 Device 등록" 부분 참조)
5단말종류x-device-type + yString"relation" + [평문] 단말 타입, “relation” 으로 고정
※ + relation: 외부연계 시스템
PayloadBodyyString"/6Fz+KIhVzmyhiBpMrLNJp+0saSg7b7XlZp3tlXrnRLVaCHDD4XqV9dGVh6hmri7hR3dJdTps1qO3gDH1XccTj3Qmy3X4MsMBFP8AW3uIGk7QdlBp0wMi8FBrHExUR/h" + [암호화] Payload 데이터
※ 평문 + 상태(json문자열)의 BODY항목을 2단계 암호화를 거친 암호화된 문자열 값.
1단계: + Aes256암호화 (암호화키는 "메시지서버 암호화 Key 조회" 부분 참조)
2단계: + Base64암호화
(1)요청ID + BODY:requestId + yLong1302575819285 + Packet별로 Unique한 + Id Milliseconds 형식 (ex. 1302575819285 )
(2)대화방ID + BODY:chatroomId + yLong99343295704997888 + 대화방 ID +
(3)메시지정보 + BODY:messageEntry + yList +
(3-1)메시지ID + BODY:messageEntry: + msgIdyLong38635452485935 + 카운트 조회를 하고자 하는 + 메시지의 ID
(3-2)원본메시지 + 발송시간BODY:endChatEntriy:messageEntry: + sentTimeLong1472639462088 + 카운트 조회를 하고자 하는 + 메시지의 sent time
+
+
+
+

Response Parameter [Encrypted]

+
+
+
+ + + + + + + + + + + + + + + + + +
PropertiesAttributeData TypeSample DataNote
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
요청ID + requestId + Long15783867572942564 + Packet별로 Unique한 Id (Milliseconds 형식)
※ 요청시 사용한 requestId 값과 동일
대화방ID + chatroomId + Long99536308621824000 + 대화방 Id +
결과 + result + 결과
결과:코드 + result:code + Integer1000 + 결과 코드 +
결과:(에러)내용 + result:msg + String결과 내용 +
결과:카운트 조회 + 목록result:messageEntry + List +
결과:카운트 조회 + 목록:메시지IDresult:messageEntry:msgId + Long카운트 조회한 메시지의 + ID
결과:카운트 조회 + 목록:메시지발송시간result:messageEntry:sentTime + Long카운트 조회한 메시지의 + sent time
결과:카운트 조회 + 목록:읽음 카운트result:messageEntry:readCount + Integer해당 메시지에 대한 읽음 + 카운트
+
+
+
+

Sample

+
+
+
+ + + + + + + + + + + +
RequestResponse
+
+
+ + + + + + + + + + + +
POST /messenger/message/api/v1.0/message/messageReadCountRequest + HTTP/1.1

headers: + {"Accept": "application/json", "Authorization": "Bearer + ed114dc382ca16d5b43154fe5832a7", "Content-Type": "application/json", "x-device-id": + "1000145874", "Content-Length": "172"}

body(암호화전): {"requestId": + 15784610001948974, "chatroomId": 99343295704997888, "messageEntry":[{"msgId": + 38635452485935, "sentTime":1472639462088}]}
HTTP/1.1 200 OK
Content-Type: + application/json
Server: Message + Server

{"requestId": 15784610001948974, "chatroomId": 99343295704997888, + "result": {"code": 1000}, "messageEntry":[{"msgId": 38635452485935, + "sentTime":1472639462088, "readCount":0}]}
+
+
+
+

Error Code

+
+
+

"메시지 API 공통 포맷" 부분 참조 (에러코드 부분)

+
+
\ No newline at end of file diff --git a/lib/knox-api/messenger/messenger.ts b/lib/knox-api/messenger/messenger.ts new file mode 100644 index 00000000..58611621 --- /dev/null +++ b/lib/knox-api/messenger/messenger.ts @@ -0,0 +1,925 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +"use server" + +import { z } from 'zod'; + +// 환경 변수 타입 정의 +const MESSENGER_BASE_URL = process.env.MESSENGER_BASE_URL || 'https://api.messenger.com'; +const ACCESS_TOKEN = process.env.MESSENGER_ACCESS_TOKEN; +const DEVICE_ID = process.env.MESSENGER_DEVICE_ID; + +// 공통 헤더 생성 함수 +function createHeaders(additionalHeaders?: Record) { + const headers: Record = { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${ACCESS_TOKEN}`, + 'x-device-id': DEVICE_ID!, + 'x-device-type': 'relation', + ...additionalHeaders + }; + + return headers; +} + +// 응답 타입 정의 +type ApiResponse = { + success: boolean; + data?: T; + error?: string; + statusCode?: number; +}; + +// 에러 핸들링 함수 +function handleApiError(error: any, endpoint: string): ApiResponse { + console.error(`Knox Messenger API Error (${endpoint}):`, error); + + return { + success: false, + error: error.message || `Failed to call ${endpoint}`, + statusCode: error.status || 500 + }; +} + +// ============================================================================= +// 연락처 관리 API +// ============================================================================= + +// 연락처 추가 스키마 +const addContactSchema = z.object({ + contactList: z.array(z.object({ + userID: z.number() + })) +}); + +// 연락처 추가 +export async function addContact(data: z.infer): Promise> { + try { + const validated = addContactSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/contact/api/v1.0/contact/o1/user`, { + method: 'POST', + headers: createHeaders(), + body: JSON.stringify(validated) + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to add contact', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'addContact'); + } +} + +// 연락처 삭제 스키마 +const deleteContactSchema = z.object({ + contactList: z.array(z.object({ + userID: z.number() + })) +}); + +// 연락처 삭제 +export async function deleteContact(data: z.infer): Promise> { + try { + const validated = deleteContactSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/contact/api/v1.0/contact/o1/user/delete`, { + method: 'POST', + headers: createHeaders(), + body: JSON.stringify(validated) + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to delete contact', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'deleteContact'); + } +} + +// 연락처 목록 조회 +export async function getContactList(): Promise> { + try { + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/contact/api/v1.0/contact/o1/list`, { + method: 'GET', + headers: createHeaders() + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to get contact list', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'getContactList'); + } +} + +// 사용자 검색 스키마 +const searchUserSchema = z.object({ + singleIdList: z.array(z.object({ + singleId: z.string() + })) +}); + +// 사용자 검색 +export async function searchUserByLoginId(data: z.infer): Promise> { + try { + const validated = searchUserSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/contact/api/v1.0/profile/o1/search/loginid`, { + method: 'POST', + headers: createHeaders(), + body: JSON.stringify(validated) + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to search user', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'searchUserByLoginId'); + } +} + +// ============================================================================= +// 장치 관리 API +// ============================================================================= + +// 장치 등록 +export async function registerDevice(): Promise> { + try { + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/contact/api/v1.0/device/o1/reg`, { + method: 'GET', + headers: createHeaders() + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to register device', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'registerDevice'); + } +} + +// 장치 해지 스키마 +const deregisterDeviceSchema = z.object({ + deviceServerID: z.number() +}); + +// 장치 해지 +export async function deregisterDevice(data: z.infer): Promise> { + try { + const validated = deregisterDeviceSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/contact/api/v1.0/device/o1/delete`, { + method: 'POST', + headers: createHeaders(), + body: JSON.stringify(validated) + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to deregister device', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'deregisterDevice'); + } +} + +// 장치 사용 정보 조회 스키마 +const getDeviceUseInfoSchema = z.object({ + singleIdList: z.array(z.object({ + singleId: z.string() + })) +}); + +// 장치 사용 정보 조회 +export async function getDeviceUseInfo(data: z.infer): Promise> { + try { + const validated = getDeviceUseInfoSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/contact/api/v1.0/device/o1/use/info`, { + method: 'POST', + headers: createHeaders(), + body: JSON.stringify(validated) + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to get device use info', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'getDeviceUseInfo'); + } +} + +// ============================================================================= +// 파일 관리 API +// ============================================================================= + +// 파일 서버 시간 및 키 조회 스키마 +const getFileServerTimeSchema = z.object({ + word: z.string() +}); + +// 파일 서버 시간 및 키 조회 +export async function getFileServerTime(data: z.infer): Promise> { + try { + const validated = getFileServerTimeSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/file/api/v1.0/file/v1/getCurrentTime?word=${validated.word}`, { + method: 'GET', + headers: createHeaders({ + 'x-access-token': ACCESS_TOKEN! + }) + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to get file server time', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'getFileServerTime'); + } +} + +// 파일 업로드 스키마 +const uploadFileSchema = z.object({ + filename: z.string(), + fileData: z.instanceof(FormData).or(z.any()) +}); + +// 파일 업로드 +export async function uploadFile(data: z.infer): Promise> { + try { + const validated = uploadFileSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/file/api/v1.0/file/v1s/file/${validated.filename}`, { + method: 'PUT', + headers: createHeaders({ + 'x-access-token': ACCESS_TOKEN!, + 'Content-Type': 'multipart/form-data' + }), + body: validated.fileData + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to upload file', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'uploadFile'); + } +} + +// 파일 다운로드 스키마 +const downloadFileSchema = z.object({ + fileId: z.string() +}); + +// 파일 다운로드 +export async function downloadFile(data: z.infer): Promise> { + try { + const validated = downloadFileSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/file/api/v1.0/file/v1s/file/${validated.fileId}`, { + method: 'GET', + headers: createHeaders({ + 'x-access-token': ACCESS_TOKEN! + }) + }); + + if (!response.ok) { + return { + success: false, + error: 'Failed to download file', + statusCode: response.status + }; + } + + const blob = await response.blob(); + + return { + success: true, + data: blob + }; + } catch (error) { + return handleApiError(error, 'downloadFile'); + } +} + +// ============================================================================= +// 메시지 관리 API +// ============================================================================= + +// 메시지 서버 키 조회 +export async function getMessageServerKeys(): Promise> { + try { + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/msgctx/api/v1.0/key/getkeys`, { + method: 'GET', + headers: createHeaders() + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to get message server keys', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'getMessageServerKeys'); + } +} + +// 대화방 참여자 정보 조회 스키마 +const getChatMembersSchema = z.object({ + chatroomId: z.number() +}); + +// 대화방 참여자 정보 조회 +export async function getChatMembers(data: z.infer): Promise> { + try { + const validated = getChatMembersSchema.parse(data); + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/msgctx/api/v1.0/chat/activemember?chatroomId=${validated.chatroomId}`, { + method: 'GET', + headers: createHeaders() + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to get chat members', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'getChatMembers'); + } +} + +// 대화방 생성 스키마 +const createChatroomSchema = z.object({ + requestId: z.number(), + chatType: z.number(), // 0: 1:1, 1: GROUP, 2: BROADCAST GROUP, 5: BROADCAST SINGLE + receivers: z.array(z.number()), + chatroomTitle: z.string().optional() +}); + +// 대화방 생성 +export async function createChatroom(data: z.infer): Promise> { + try { + const validated = createChatroomSchema.parse(data); + + // TODO: 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/createChatroomRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to create chatroom', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'createChatroom'); + } +} + +// 메시지 발송 스키마 +const sendMessageSchema = z.object({ + requestId: z.number(), + chatroomId: z.number(), + chatMessageParams: z.array(z.object({ + msgId: z.number(), + msgType: z.number(), // 0: TEXT, 1: MEDIA, 7: RTF, 8: NCUSTOM + chatMsg: z.string(), + msgTtl: z.number().optional() + })) +}); + +// 메시지 발송 +export async function sendMessage(data: z.infer): Promise> { + try { + const validated = sendMessageSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/chatRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to send message', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'sendMessage'); + } +} + +// 대화상대 초대 스키마 +const inviteUserSchema = z.object({ + requestId: z.number(), + chatroomId: z.number(), + invitingMembers: z.array(z.number()) +}); + +// 대화상대 초대 +export async function inviteUser(data: z.infer): Promise> { + try { + const validated = inviteUserSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/inviteRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to invite user', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'inviteUser'); + } +} + +// 대화상대 내보내기 스키마 +const removeUserSchema = z.object({ + requestId: z.number(), + chatroomId: z.number(), + removingMembers: z.array(z.number()) +}); + +// 대화상대 내보내기 +export async function removeUser(data: z.infer): Promise> { + try { + const validated = removeUserSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/removeMemberRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to remove user', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'removeUser'); + } +} + +// 대화방 삭제 스키마 +const deleteChatroomSchema = z.object({ + requestId: z.number(), + chatroomId: z.number() +}); + +// 대화방 삭제 +export async function deleteChatroom(data: z.infer): Promise> { + try { + const validated = deleteChatroomSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/destroyChatroomRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to delete chatroom', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'deleteChatroom'); + } +} + +// 메시지 발신취소 스키마 +const recallMessageSchema = z.object({ + requestId: z.number(), + chatroomId: z.number(), + msgId: z.number() +}); + +// 메시지 발신취소 +export async function recallMessage(data: z.infer): Promise> { + try { + const validated = recallMessageSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/recallMessageRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to recall message', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'recallMessage'); + } +} + +// 대화방명 변경 스키마 +const changeChatroomNameSchema = z.object({ + requestId: z.number(), + chatroomId: z.number(), + chatroomTitle: z.string() +}); + +// 대화방명 변경 +export async function changeChatroomName(data: z.infer): Promise> { + try { + const validated = changeChatroomNameSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/changeChatroomMetaRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to change chatroom name', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'changeChatroomName'); + } +} + +// 방장 변경 스키마 +const changeOwnerSchema = z.object({ + requestId: z.number(), + chatroomId: z.number(), + newOwnerUserId: z.number() +}); + +// 방장 변경 +export async function changeOwner(data: z.infer): Promise> { + try { + const validated = changeOwnerSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/changeOwnerRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to change owner', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'changeOwner'); + } +} + +// 대화방 나가기 스키마 +const leaveChatroomSchema = z.object({ + requestId: z.number(), + chatroomId: z.number() +}); + +// 대화방 나가기 +export async function leaveChatroom(data: z.infer): Promise> { + try { + const validated = leaveChatroomSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/endChatRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to leave chatroom', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'leaveChatroom'); + } +} + +// 메시지 읽음 카운트 조회 스키마 +const getMessageReadCountSchema = z.object({ + requestId: z.number(), + chatroomId: z.number(), + msgId: z.number() +}); + +// 메시지 읽음 카운트 조회 +export async function getMessageReadCount(data: z.infer): Promise> { + try { + const validated = getMessageReadCountSchema.parse(data); + + // 실제 구현에서는 메시지 서버 키를 사용하여 암호화해야 함 + const encryptedBody = JSON.stringify(validated); // 임시로 평문 사용 + + const response = await fetch(`${MESSENGER_BASE_URL}/messenger/message/api/v1.0/message/messageReadCountRequest`, { + method: 'POST', + headers: createHeaders(), + body: encryptedBody + }); + + const result = await response.json(); + + if (!response.ok) { + return { + success: false, + error: result.message || 'Failed to get message read count', + statusCode: response.status + }; + } + + return { + success: true, + data: result + }; + } catch (error) { + return handleApiError(error, 'getMessageReadCount'); + } +} + +// ============================================================================= +// 유틸리티 함수 +// ============================================================================= + +// 현재 시간을 밀리초로 반환 (requestId 생성용) +export async function generateRequestId(): Promise { + return Date.now(); +} + +// 메시지 ID 생성 (각 메시지마다 고유한 ID 필요) +export async function generateMessageId(): Promise { + return Date.now() + Math.floor(Math.random() * 1000); +} + +// 헬퍼 함수 - 간단한 텍스트 메시지 발송 +export async function sendTextMessage(chatroomId: number, message: string): Promise> { + const requestId = await generateRequestId(); + const msgId = await generateMessageId(); + + return sendMessage({ + requestId, + chatroomId, + chatMessageParams: [{ + msgId, + msgType: 0, // TEXT + chatMsg: message, + msgTtl: 7200 // 2시간 + }] + }); +} + +// 헬퍼 함수 - 그룹 대화방 생성 +export async function createGroupChatroom(userIds: number[], title?: string): Promise> { + const requestId = await generateRequestId(); + + return createChatroom({ + requestId, + chatType: 2, // BROADCAST GROUP + receivers: userIds, + chatroomTitle: title + }); +} + +// 헬퍼 함수 - 1:1 대화방 생성 +export async function createPrivateChatroom(userId: number): Promise> { + const requestId = await generateRequestId(); + + return createChatroom({ + requestId, + chatType: 5, // BROADCAST SINGLE + receivers: [userId] + }); +} -- cgit v1.2.3