-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YEL-170 [feat] apple notification slack webhook
YEL-170 [feat] apple notification slack webhook
- Loading branch information
Showing
5 changed files
with
144 additions
and
7 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
12 changes: 12 additions & 0 deletions
12
...java/com/yello/server/infrastructure/slack/annotation/SlackApplePurchaseNotification.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,12 @@ | ||
package com.yello.server.infrastructure.slack.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface SlackApplePurchaseNotification { | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...va/com/yello/server/infrastructure/slack/aspect/SlackApplePurchaseNotificationAspect.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.yello.server.infrastructure.slack.aspect; | ||
|
||
import com.yello.server.infrastructure.slack.factory.SlackWebhookMessageFactory; | ||
import javax.servlet.http.HttpServletRequest; | ||
import net.gpedro.integrations.slack.SlackApi; | ||
import net.gpedro.integrations.slack.SlackMessage; | ||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.core.task.TaskExecutor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.context.request.RequestContextHolder; | ||
import org.springframework.web.context.request.ServletRequestAttributes; | ||
|
||
@Aspect | ||
@Component | ||
public class SlackApplePurchaseNotificationAspect { | ||
|
||
private final SlackApi slackApplePurchaseApi; | ||
private final SlackWebhookMessageFactory slackWebhookMessageFactory; | ||
private final TaskExecutor taskExecutor; | ||
|
||
public SlackApplePurchaseNotificationAspect( | ||
@Qualifier("slackApplePurchaseNotificationApi") SlackApi slackApplePurchaseApi, | ||
SlackWebhookMessageFactory slackWebhookMessageFactory, | ||
TaskExecutor taskExecutor) { | ||
this.slackApplePurchaseApi = slackApplePurchaseApi; | ||
this.slackWebhookMessageFactory = slackWebhookMessageFactory; | ||
this.taskExecutor = taskExecutor; | ||
} | ||
|
||
@Around("@annotation(com.yello.server.infrastructure.slack.annotation.SlackApplePurchaseNotification)") | ||
Object applePurchaseNotification(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { | ||
HttpServletRequest request = | ||
((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) | ||
.getRequest(); | ||
|
||
SlackMessage slackMessage = slackWebhookMessageFactory.generateAppleSlackPurchaseMessage( | ||
request | ||
); | ||
|
||
Runnable runnable = () -> slackApplePurchaseApi.call(slackMessage); | ||
taskExecutor.execute(runnable); | ||
|
||
return proceedingJoinPoint.proceed(); | ||
} | ||
} |
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