Skip to content

Commit

Permalink
[hotfix] fix: Slack 내에 json 변환 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
elive7 committed Dec 17, 2024
1 parent 5cb7530 commit 2458cea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public ResponseEntity<Void> handleInteractiveMessage(HttpServletRequest request)
String actionId = slack.getActionId();

if (actionId.contains("report")) {
if (slack.getApprovalStatus() == null || slack.getReportId() == null || slack.getThreadTimestamp() == null) {
throw new SlackException(ErrorMessage.SLACK_INTERACTION_FAILED);
}
reportService.resolve(slack.getReportId(), slack.getApprovalStatus(), slack.getThreadTimestamp());
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/org/recordy/server/slack/domain/Slack.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ public Slack(HttpServletRequest request) {
String encodedPayload = (String) request.getAttribute("slackPayload");
System.out.println("Encoded Slack payload = " + encodedPayload);

if (encodedPayload == null) {
if (encodedPayload == null || encodedPayload.isBlank()) {
throw new SlackException(ErrorMessage.SLACK_INTERACTION_FAILED);
}

// URL 디코딩
String payload = URLDecoder.decode(encodedPayload, StandardCharsets.UTF_8);
System.out.println("Decoded Slack payload = " + payload);
String decodedPayload = URLDecoder.decode(encodedPayload, StandardCharsets.UTF_8);
System.out.println("Decoded Slack payload = " + decodedPayload);

// "payload=" 제거
String jsonPayload = decodedPayload.substring(8); // "payload=" 이후의 값 추출

// JSON 파싱
JSONObject json = new JSONObject(payload);
JSONObject json = new JSONObject(jsonPayload);

JSONObject action = json.getJSONArray("actions").getJSONObject(0);
JSONObject value = new JSONObject(action.getString("value"));
Expand Down

0 comments on commit 2458cea

Please sign in to comment.