-
Notifications
You must be signed in to change notification settings - Fork 0
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 #122 from Team-Going/develop
[release] v1.1.0 릴리즈
- Loading branch information
Showing
7 changed files
with
81 additions
and
9 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
13 changes: 13 additions & 0 deletions
13
doorip-common/src/main/java/org/doorip/message/EventMessage.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 org.doorip.message; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public enum EventMessage { | ||
SIGN_UP_EVENT("doorip 서비스에 회원가입 이벤트가 발생했습니다. 🎉"); | ||
|
||
private final String message; | ||
} |
12 changes: 12 additions & 0 deletions
12
doorip-external/src/main/java/org/doorip/openfeign/discord/DiscordFeignClient.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 org.doorip.openfeign.discord; | ||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
@FeignClient(name = "${discord.name}", url = "${discord.webhook-url}") | ||
public interface DiscordFeignClient { | ||
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
void sendMessage(@RequestBody DiscordMessage discordMessage); | ||
} |
9 changes: 9 additions & 0 deletions
9
doorip-external/src/main/java/org/doorip/openfeign/discord/DiscordMessage.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 org.doorip.openfeign.discord; | ||
|
||
public record DiscordMessage( | ||
String content | ||
) { | ||
public static DiscordMessage createDiscordMessage(String message) { | ||
return new DiscordMessage(message); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
doorip-external/src/main/java/org/doorip/openfeign/discord/DiscordMessageProvider.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,29 @@ | ||
package org.doorip.openfeign.discord; | ||
|
||
import feign.FeignException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.doorip.exception.InvalidValueException; | ||
import org.doorip.message.ErrorMessage; | ||
import org.doorip.message.EventMessage; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static org.doorip.openfeign.discord.DiscordMessage.createDiscordMessage; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class DiscordMessageProvider { | ||
private final DiscordFeignClient discordFeignClient; | ||
|
||
public void sendMessage(EventMessage eventMessage) { | ||
DiscordMessage discordMessage = createDiscordMessage(eventMessage.getMessage()); | ||
sendMessageToDiscord(discordMessage); | ||
} | ||
|
||
private void sendMessageToDiscord(DiscordMessage discordMessage) { | ||
try { | ||
discordFeignClient.sendMessage(discordMessage); | ||
} catch (FeignException e) { | ||
throw new InvalidValueException(ErrorMessage.INVALID_DISCORD_MESSAGE); | ||
} | ||
} | ||
} |