-
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-161 [deploy] v1.194
- Loading branch information
Showing
10 changed files
with
126 additions
and
2 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
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
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
src/main/java/com/yello/server/infrastructure/slack/annotation/SlackSignUpNotification.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 SlackSignUpNotification { | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...main/java/com/yello/server/infrastructure/slack/aspect/SlackSignUpNotificationAspect.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,47 @@ | ||
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 SlackSignUpNotificationAspect { | ||
|
||
private final SlackApi slackSignUpApi; | ||
private final SlackWebhookMessageFactory slackWebhookMessageFactory; | ||
private final TaskExecutor taskExecutor; | ||
|
||
public SlackSignUpNotificationAspect( | ||
@Qualifier("slackSignUpApi") SlackApi slackSignUpApi, | ||
SlackWebhookMessageFactory slackWebhookMessageFactory, | ||
TaskExecutor taskExecutor) { | ||
this.slackSignUpApi = slackSignUpApi; | ||
this.slackWebhookMessageFactory = slackWebhookMessageFactory; | ||
this.taskExecutor = taskExecutor; | ||
} | ||
|
||
@Around("@annotation(com.yello.server.infrastructure.slack.annotation.SlackSignUpNotification)") | ||
Object signUpNotification(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { | ||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) | ||
.getRequest(); | ||
|
||
SlackMessage slackMessage = slackWebhookMessageFactory.generateSlackSignUpMessage( | ||
request | ||
); | ||
|
||
Runnable runnable = () -> slackSignUpApi.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
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