-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from Modagbul/fix/auth
Slack 알림 EventPublisher로 수정
- Loading branch information
Showing
10 changed files
with
114 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/moing/backend/global/config/slack/SlackConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.moing.backend.global.config.slack; | ||
|
||
import com.slack.api.Slack; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SlackConfig { | ||
|
||
@Bean | ||
public Slack slackClient() { | ||
return Slack.getInstance(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/moing/backend/global/config/slack/exception/ExceptionEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.moing.backend.global.config.slack.exception; | ||
|
||
import com.moing.backend.global.config.slack.exception.dto.ExceptionEvent; | ||
import com.moing.backend.global.config.slack.util.WebhookUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class ExceptionEventHandler { | ||
|
||
private final WebhookUtil webhookUtil; | ||
|
||
@Async("asyncTaskExecutor") | ||
@EventListener | ||
public void onExceptionEvent(ExceptionEvent event) { | ||
webhookUtil.sendSlackAlertErrorLog(event.getRequest(), event.getException()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/moing/backend/global/config/slack/exception/dto/ExceptionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.moing.backend.global.config.slack.exception.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ExceptionEvent { | ||
|
||
private final HttpServletRequest request; | ||
private final Exception exception; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/moing/backend/global/config/slack/team/TeamCreateHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.moing.backend.global.config.slack.team; | ||
|
||
import com.moing.backend.global.config.slack.team.dto.TeamCreateEvent; | ||
import com.moing.backend.global.config.slack.util.WebhookUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class TeamCreateHandler { | ||
|
||
private final WebhookUtil webhookUtil; | ||
|
||
@Async("asyncTaskExecutor") | ||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
public void onTeamCreateEvent(TeamCreateEvent event) { | ||
webhookUtil.sendSlackTeamCreatedMessage(event.getTeamName(), event.getLeaderId()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/moing/backend/global/config/slack/team/dto/TeamCreateEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.moing.backend.global.config.slack.team.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class TeamCreateEvent { | ||
|
||
private final String teamName; | ||
private final Long leaderId; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/moing/backend/global/config/slack/util/WebhookUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.moing.backend.global.config.slack.util; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
public interface WebhookUtil { | ||
|
||
void sendSlackAlertErrorLog(HttpServletRequest request, Exception e); | ||
|
||
void sendSlackTeamCreatedMessage(String teamName, Long leaderId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters