-
Notifications
You must be signed in to change notification settings - Fork 0
Pinpoint의 알람을 슬랙에 전송하는 기능 구현 #36
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
Open
hsik0225
wants to merge
5
commits into
dev
Choose a base branch
from
pinpoint_alarm
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
13 changes: 6 additions & 7 deletions
13
src/main/java/com/simleetag/homework/api/domain/user/oauth/api/dto/TokenResponse.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,25 +1,24 @@ | ||
| package com.simleetag.homework.api.domain.user.oauth.api.dto; | ||
|
|
||
| import javax.validation.constraints.NotBlank; | ||
|
|
||
| import com.simleetag.homework.api.domain.user.User; | ||
| import com.simleetag.homework.api.domain.user.api.dto.findUserWithHomeAndMembersResponse; | ||
|
|
||
| import com.simleetag.homework.api.domain.user.api.dto.UserWithHomeAndMembersResponse; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| import javax.validation.constraints.NotBlank; | ||
|
|
||
| public record TokenResponse( | ||
| @Schema(description = "Homework 서비스를 사용하기 위한 JWT") | ||
| @NotBlank | ||
| String homeworkToken, | ||
|
|
||
| @Schema(description = "Homework에 가입된 유저의 정보") | ||
| @NotBlank findUserWithHomeAndMembersResponse user | ||
| @NotBlank UserWithHomeAndMembersResponse user | ||
| ) { | ||
| public static TokenResponse from(String homeworkToken, findUserWithHomeAndMembersResponse user) { | ||
| public static TokenResponse from(String homeworkToken, UserWithHomeAndMembersResponse user) { | ||
| return new TokenResponse(homeworkToken, user); | ||
| } | ||
|
|
||
| public static TokenResponse from(String homeworkToken, User user) { | ||
| return from(homeworkToken, findUserWithHomeAndMembersResponse.from(user)); | ||
| return from(homeworkToken, UserWithHomeAndMembersResponse.from(user)); | ||
| } | ||
| } |
167 changes: 167 additions & 0 deletions
167
src/main/java/com/simleetag/homework/api/domain/webhook/BlockKit.java
This file contains hidden or 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,167 @@ | ||
| package com.simleetag.homework.api.domain.webhook; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
| import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
| import lombok.AllArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * https://api.slack.com/reference/block-kit | ||
| */ | ||
| public class BlockKit { | ||
|
|
||
| @JsonTypeInfo( | ||
| use = JsonTypeInfo.Id.NAME, | ||
| include = JsonTypeInfo.As.EXISTING_PROPERTY, | ||
| property = "type", | ||
| visible = true | ||
| ) | ||
| @JsonSubTypes({ | ||
| @JsonSubTypes.Type(value = Context.class, name = "context"), | ||
| @JsonSubTypes.Type(value = Header.class, name = "header"), | ||
| @JsonSubTypes.Type(value = Section.class, name = "section"), | ||
| @JsonSubTypes.Type(value = Divider.class, name = "divider"), | ||
| @JsonSubTypes.Type(value = Image.class, name = "checkboxes"), | ||
| @JsonSubTypes.Type(value = Text.class, name = "plain_text"), | ||
| @JsonSubTypes.Type(value = Text.class, name = "mrkdwn"), | ||
| @JsonSubTypes.Type(value = Button.class, name = "button"), | ||
| @JsonSubTypes.Type(value = Checkbox.class, name = "checkboxes"), | ||
| @JsonSubTypes.Type(value = Image.class, name = "image"), | ||
| }) | ||
| public interface Block { | ||
|
|
||
| } | ||
|
|
||
| public interface BlockKitElement extends Block { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * https://api.slack.com/reference/block-kit#objects | ||
| */ | ||
| public interface BlockKitObject extends Block { | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * https://api.slack.com/reference/block-kit#blocks | ||
| */ | ||
| public interface BlockKitBlock extends Block { | ||
|
|
||
| } | ||
|
|
||
| @AllArgsConstructor | ||
| public static class Context implements BlockKitBlock { | ||
| /** | ||
| * Only images BlockElement and text CompositionObject are allowed. | ||
| */ | ||
| public String type; | ||
| public List<BlockKitObject> elements; | ||
| public String blockId; | ||
|
|
||
| public Context(List<BlockKitObject> elements) { | ||
| this("context", elements, null); | ||
| } | ||
| } | ||
|
|
||
| public record Header( | ||
| Text text | ||
| ) implements BlockKitBlock { | ||
| public static String type = "header"; | ||
| } | ||
|
|
||
| @AllArgsConstructor | ||
| public static class Section implements BlockKitBlock { | ||
| public String type; | ||
| public Text text; | ||
| public String blockId; | ||
| public List<Text> fields; | ||
| public BlockKitElement accessor; | ||
|
|
||
| public Section(Text text) { | ||
| this("section", text, null, null, null); | ||
| } | ||
| } | ||
|
|
||
| public class Divider implements BlockKitBlock { | ||
| public static String type = "divider"; | ||
| } | ||
|
|
||
| public record Button( | ||
| Text text, | ||
| String actionId, | ||
| String url, | ||
| String value, | ||
| Style style, | ||
| ConfirmationDialog confirm, | ||
| Text accessibilityLabel | ||
| ) implements BlockKitElement { | ||
| public static String type = "button"; | ||
|
|
||
| public enum Style { | ||
| primary, | ||
| danger | ||
| } | ||
| } | ||
|
|
||
| public record Checkbox( | ||
| String actionId, | ||
| List<Option> options, | ||
| List<Option> initialOptions, | ||
| ConfirmationDialog confirm, | ||
| Boolean focusOnLoad | ||
| ) implements BlockKitElement { | ||
| public static String type = "checkboxes"; | ||
| } | ||
|
|
||
| public record Image( | ||
| String imageUrl, | ||
| String altText | ||
| ) implements BlockKitElement, BlockKitObject { | ||
| public static String type = "image"; | ||
| } | ||
|
|
||
| public record Text( | ||
| Type type, | ||
| String text, | ||
| Boolean emoji, | ||
| Boolean verbatim | ||
| ) implements BlockKitObject { | ||
| public enum Type { | ||
| plain_text, | ||
| mrkdwn | ||
| } | ||
|
|
||
| public Text(Type type, String text) { | ||
| this(type, text, null, null); | ||
| } | ||
| } | ||
|
|
||
| public record ConfirmationDialog( | ||
| Text title, | ||
| Text text, | ||
| Text confirm, | ||
| Text deny, | ||
| Style style | ||
| ) implements BlockKitObject { | ||
| public enum Style { | ||
| danger, | ||
| primary | ||
| } | ||
| } | ||
|
|
||
| public record Option( | ||
| Text text, | ||
| String value | ||
| ) implements BlockKitObject { | ||
|
|
||
| } | ||
|
|
||
| public record OptionGroup( | ||
| Text label, | ||
| List<Option> options | ||
| ) implements BlockKitObject { | ||
|
|
||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
block kit 데모 사이트입니다.
https://app.slack.com/block-kit-builder/T02TM7502NM#%7B%22type%22:%22home%22,%22blocks%22:%5B%5D%7D
block kit은 사이트에서 보이다시피 JSON으로 슬랙의 메시지를 표현해줘요!