-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
๐ :: (#230) ํผ๋ ์ ๊ณ Slack ์ฐ๋ #114
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f4bb995
โก๏ธ :: webhook ์์กด์ฑ ์ถ๊ฐ
jeongho1209 0d75b2a
๐ :: AsyncConfig ์ถ๊ฐ
jeongho1209 6afbf8d
โป๏ธ :: ์ฝ๋ ์ ๋ ฌ
jeongho1209 bd52ec0
โก๏ธ :: webhook url ์ถ๊ฐ
jeongho1209 d38a82a
๐ :: SlackReport ์ถ๊ฐ
jeongho1209 5b0ca08
โก๏ธ :: ํผ๋ ์ ๊ณ ์ slack ์๋ ๊ธฐ๋ฅ ์ถ๊ฐ
jeongho1209 2454e6d
โก๏ธ :: ์์ด๋๋ก ์ฌ์ฉ์ ์ ๋ณด ์กฐํ API ์ถ๊ฐ
jeongho1209 324da78
๐ :: UserNotFoundException ์ถ๊ฐ
jeongho1209 ec14fc7
โก๏ธ :: ์์ด๋๋ก ์ฌ์ฉ์ ์ ๋ณด ์กฐํ API ์ถ๊ฐ
jeongho1209 93990a0
โป๏ธ :: ๋จ์ผ ์์ด๋๋ก ์ ๋ณด ์กฐํํ๋๋ก ์์
jeongho1209 c8899c6
โป๏ธ :: ํ์์๋ ๊ณต๋ฐฑ ์ ๊ฑฐ
jeongho1209 288f386
โป๏ธ :: ํ์์๋ ์ค ์ ๊ฑฐ
jeongho1209 aa7511d
โป๏ธ :: EventListener ๊ตฌ์กฐ๋ก ์์
jeongho1209 0f88bfe
โป๏ธ :: import ์ ๋ฆฌ
jeongho1209 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
14 changes: 14 additions & 0 deletions
14
feed-domain/src/main/java/com/xquare/v1servicefeed/user/exception/UserNotFoundException.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.xquare.v1servicefeed.user.exception; | ||
|
||
import com.xquare.v1servicefeed.error.FeedException; | ||
import com.xquare.v1servicefeed.user.error.UserErrorCode; | ||
|
||
public class UserNotFoundException extends FeedException { | ||
|
||
public static final FeedException EXCEPTION = | ||
new UserNotFoundException(); | ||
|
||
private UserNotFoundException() { | ||
super(UserErrorCode.USER_NOT_FOUND); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
feed-domain/src/main/java/com/xquare/v1servicefeed/webhook/SlackReport.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,15 @@ | ||
package com.xquare.v1servicefeed.webhook; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class SlackReport { | ||
|
||
private final String feedContent; | ||
|
||
private final String userName; | ||
|
||
private final String reportContent; | ||
} |
10 changes: 10 additions & 0 deletions
10
feed-domain/src/main/java/com/xquare/v1servicefeed/webhook/spi/SendWebhookSpi.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.xquare.v1servicefeed.webhook.spi; | ||
|
||
import com.xquare.v1servicefeed.annotation.Spi; | ||
import com.xquare.v1servicefeed.webhook.SlackReport; | ||
|
||
@Spi | ||
public interface SendWebhookSpi { | ||
|
||
void sendReportToSlack(SlackReport slackReport); | ||
} |
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
9 changes: 9 additions & 0 deletions
9
...frastructure/src/main/java/com/xquare/v1servicefeed/configuration/config/AsyncConfig.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,9 @@ | ||
package com.xquare.v1servicefeed.configuration.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
|
||
@EnableAsync | ||
@Configuration | ||
public class AsyncConfig { | ||
} |
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
48 changes: 48 additions & 0 deletions
48
feed-infrastructure/src/main/java/com/xquare/v1servicefeed/webhook/SendWebhookAdapter.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,48 @@ | ||
package com.xquare.v1servicefeed.webhook; | ||
|
||
import com.xquare.v1servicefeed.webhook.spi.SendWebhookSpi; | ||
import lombok.RequiredArgsConstructor; | ||
import net.gpedro.integrations.slack.SlackApi; | ||
import net.gpedro.integrations.slack.SlackAttachment; | ||
import net.gpedro.integrations.slack.SlackMessage; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class SendWebhookAdapter implements SendWebhookSpi { | ||
|
||
private static final String REPORT_MESSAGE = "ํผ๋ ์ ๊ณ ๋ฐ์"; | ||
private static final String REPORT_USER_NAME = "์ ๊ณ ์"; | ||
private static final String REPORT_CONTENT = "์ ๊ณ ๋ด์ฉ"; | ||
private static final String REPORT_FEED_CONTENT = "์ ๊ณ ํ ๊ฒ์๊ธ ๋ด์ฉ"; | ||
private static final String MESSAGE_COLOR = "#9650FA"; | ||
private static final String FALLBACK = "Required plain-text summary of the attachment"; | ||
|
||
@Value("${webhook.url}") | ||
private String webhookUrl; | ||
|
||
@Override | ||
@Async | ||
public void sendReportToSlack(SlackReport slackReport) { | ||
SlackAttachment slackAttachment = createSlackAttachment(slackReport); | ||
SlackMessage slackMessage = new SlackMessage("").addAttachments(slackAttachment); | ||
new SlackApi(webhookUrl).call(slackMessage); | ||
} | ||
|
||
private SlackAttachment createSlackAttachment(SlackReport slackReport) { | ||
SlackAttachment slackAttachment = new SlackAttachment(); | ||
slackAttachment.setTitle(REPORT_MESSAGE); | ||
slackAttachment.setText(getErrorReason(slackReport)); | ||
slackAttachment.setColor(MESSAGE_COLOR); | ||
slackAttachment.setFallback(FALLBACK); | ||
return slackAttachment; | ||
} | ||
|
||
private String getErrorReason(SlackReport slackReport) { | ||
return REPORT_USER_NAME + " : " + slackReport.getUserName() | ||
+ "\n" + REPORT_FEED_CONTENT + " : " + slackReport.getFeedContent() | ||
+ "\n" + REPORT_CONTENT + " : " + slackReport.getReportContent(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -46,3 +46,6 @@ springdoc: | |
display-request-duration: true | ||
cache: | ||
disabled: true | ||
|
||
webhook: | ||
url: ${webhook.url} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spring EventListener ์์๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ์์ :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ต!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์๋ดค๋์ ? ์ด๋ค๊ฒ๊ฐ์์??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ๊ฐ ์ ์ report๋ผ๋ ๋ ํฌ์งํ ๋ฆฌ์์๋ ์์ ๊ฐ์ ์ฝ๋๋ฅผ ์์ฑํ๋ ๊ฒฝํ์ด ์์ด์ ๊ทธ๋๋ Event Listener๋ฅผ ์ฌ์ฉํ ๊น ๊ณ ๋ฏผํ์๋๋ฐ
api ์๋ฃ๋๋๋ฐ๊น์ง ์๊ฐ๋ง ์ต์ ํํ๋ ค๋ฉด @async๋ง ์ฌ์ฉํด๋ ๊ด์ฐฎ์๊ฑฐ ๊ฐ๋ค ์๊ฐํ์๋๋ฐ ํน์ ์ด๋ป๊ฒ ์๊ฐํ์๋์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฌ๊ธฐ์ ๋ด๊ฐ ๋ง์ฝ EventListener๋ฅผ ์ฌ์ฉํ๋ค๋ฉด ์๊ฐ ์ต์ ํ๋ฅผ ์ด์ ๋ก ์ฌ์ฉํ์ง๋ ์์ ๊ฒ ๊ฐ์
๋ ์ค๋ฅด๋๊ฑฐ ์์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ๊ณ ์ ์ฅ ์คํจํ๋ฉด ๊ธฐ์กด๋ Slack์ ์๋ ์๊ฐ๊ฑฐ๊ฐ์๋?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋๋ ์์กด์ฑ ์ด์ผ๊ธฐํ๋ถ๋ถ์ด๊ธด ํจ
์ ๊ณ ๋ฅผ ์ ์ฅํ๋ ์ ๋ ์ฌ๋์ ๋ณด๋ด๋์ ๋ฅผ ๊ตณ์ด ์ธ๋ถ์ ์ผ๋ก ์์์ผํ ์ด์ ๊ฐ ์๋๋ฐ, ์์กดํ๊ณ ์์ผ๋ EventListener๋ฅผ ์ฌ์ฉํ๋ฉด ์์กด์ฑ์ ์์จ ์ ์์ผ๋๊น(Dto ๋นผ๊ณ ) ์ง๊ธ๊ฐ์ ๊ตฌ์กฐ๋ ๊ด์ฐฎ์๋ฐ, ๋จ๋ฐฉํฅ ์์กด์ผ๋ก ๋ชจ๋๋ณ ์์กด์ด ์์ ๋ ๊ทธ ํ๋ฆ์ ์ญํํด์ ๋ญ๊ฐ ๋ฉ์์ง๋ฅผ ๋ณด๋ด์ผํ ๋๊ฐ ์๋๋ฐ, ๊ทธ๋ด ๋ ์ฌ์ฉํ๋ฉด ๊ฐ๊ฟ์
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ทธ๋ฌ๋ฉด ํ ๋ฒ ์ ์ฉํด์ ์์ ํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ ์ข ๋ค๋ฅธ ๊ด์ ์ด๊ธด ํจ
slack ์ฅ์ ์์ ์ ๊ณ ์๋น์ค์ ์ํฅ์ ์ค์ผํ๋? ์ง๊ธ ์ํ๋๋ก๋ฉด ์ฌ๋ ์ฅ์ ์์ ์ ๊ณ ๊ธฐ๋ฅ์ด ๋จนํต์ผํ ๋ฐ ๊ด์ฐฎ์๊ฐ?๋ ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข์๋ฏ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ต!