-
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 #136 from Team-Capple/develop
[RELEASE] ๊ฒ์ํ, ๊ฒ์ํ ๋๊ธ ,์ ํ ํธ์ ์๋ฆผ ๊ตฌํ
- Loading branch information
Showing
43 changed files
with
1,849 additions
and
61 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
Submodule config
updated
from 5736a3 to cdea0f
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/server/capple/config/apns/config/ApnsClientConfig.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,44 @@ | ||
package com.server.capple.config.apns.config; | ||
|
||
import io.netty.handler.ssl.SslContext; | ||
import io.netty.handler.ssl.SslContextBuilder; | ||
import io.netty.handler.timeout.WriteTimeoutHandler; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import reactor.netty.http.HttpProtocol; | ||
import reactor.netty.http.client.HttpClient; | ||
import reactor.netty.resources.ConnectionProvider; | ||
|
||
import javax.net.ssl.SSLException; | ||
import java.time.Duration; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@Configuration | ||
public class ApnsClientConfig { | ||
@Bean("apnsSslContext") | ||
public SslContext getApnsSslContext() throws SSLException { | ||
return SslContextBuilder.forClient().protocols("TLSv1.2").build(); // SSL ์ค์ | ||
} | ||
|
||
@Bean("apnsConnectionProvider") | ||
public ConnectionProvider getApnsConnectionProvider() { | ||
return ConnectionProvider.builder("apns") | ||
.maxConnections(10) // ์ต๋ ์ปค๋ต์ ์ | ||
.pendingAcquireMaxCount(-1) // ์ฌ์๋ ํ์ (-1 : ๋ฌดํ๋) | ||
.pendingAcquireTimeout(java.time.Duration.ofSeconds(10)) // ์ปค๋ฅ์ ํ์ ์ฌ์ฉ ๊ฐ๋ฅํ ์ปค๋ฅ์ ์์ ๋์ ๋๊ธฐ ์๊ฐ | ||
.maxIdleTime(java.time.Duration.ofSeconds(5)) // ์ต๋ ์ ํด ์๊ฐ | ||
.maxLifeTime(java.time.Duration.ofSeconds(300)) // ์ต๋ ์๋ช ์๊ฐ | ||
.lifo() // ํ์ ์ ์ถ | ||
.build(); | ||
} | ||
|
||
@Bean("apnsH2HttpClient") | ||
public HttpClient getApnsH2HttpClient(ConnectionProvider apnsConnectionProvider, SslContext apnsSslContext) { | ||
return HttpClient.create(apnsConnectionProvider) // reactor HttpClient ์์ฑ | ||
.keepAlive(true) // keep-alive ํ์ฑํ | ||
.protocol(HttpProtocol.H2) // HTTP/2 ํ์ฑํ | ||
.doOnConnected(connection -> connection.addHandlerLast(new WriteTimeoutHandler(10, TimeUnit.SECONDS))) // ์ฐ๊ธฐ ํ์ ์์ | ||
.responseTimeout(Duration.ofSeconds(10)) // ์๋ต ํ์ ์์ | ||
.secure(sslSpec -> sslSpec.sslContext(apnsSslContext)); // SSL ํ์ฑํ | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
src/main/java/com/server/capple/config/apns/dto/ApnsClientRequest.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,93 @@ | ||
package com.server.capple.config.apns.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.*; | ||
|
||
public class ApnsClientRequest { | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@ToString | ||
public static class SimplePushBody { | ||
private Aps aps; | ||
|
||
public SimplePushBody(String title, String subTitle, String body, Integer badge, String threadId, String targetContentId) { | ||
this.aps = new Aps(new Aps.Alert(title, subTitle, body), badge, threadId, targetContentId); | ||
} | ||
|
||
@ToString | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class Aps { | ||
private Alert alert; | ||
private Integer badge; | ||
@JsonProperty("thread-id") | ||
private String threadId; | ||
@JsonProperty("target-content-id") | ||
private String targetContentId; // ํ๋ก ํธ ์ธก ์์ ํ์ํจ | ||
|
||
@ToString | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class Alert { | ||
private String title; | ||
private String subtitle; | ||
private String body; | ||
} | ||
} | ||
} | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@ToString | ||
public static class FullAlertBody { | ||
private Aps aps; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@ToString | ||
public static class Aps { | ||
private Alert alert; // alert ์ ๋ณด | ||
private Integer badge; // ์ฑ ์์ด์ฝ์ ํ์ํ ๋ฑ์ง ์ซ์ | ||
@Schema(defaultValue = "default") | ||
private String sound; // Library/Sounds ํด๋ ๋ด์ ํ์ผ ์ด๋ฆ | ||
@Schema(defaultValue = "thread-id") | ||
private String threadId; // ์๋ฆผ ๊ทธ๋ฃนํ๋ฅผ ์ํ thread id (UNNotificationContent ๊ฐ์ฒด์ threadIdentifier์ ์ผ์นํด์ผ ํจ) | ||
private String category; // ์๋ฆผ ๊ทธ๋ฃนํ๋ฅผ ์ํ category, (UNNotificationCategory ์๋ณ์์ ์ผ์นํด์ผ ํจ) | ||
@Schema(defaultValue = "0") | ||
@JsonProperty("content-available") | ||
private Integer contentAvailable; // ๋ฐฑ๊ทธ๋ผ์ด๋ ์๋ฆผ ์ฌ๋ถ, 1์ด๋ฉด ๋ฐฑ๊ทธ๋ผ์ด๋ ์๋ฆผ, 0์ด๋ฉด ํฌ๊ทธ๋ผ์ด๋ ์๋ฆผ (๋ฐฑ๊ทธ๋ผ์ด๋์ผ ๊ฒฝ์ฐ alert, badge, sound๋ ๋ฃ์ผ๋ฉด ์๋จ) | ||
@Schema(defaultValue = "0") | ||
@JsonProperty("mutable-content") | ||
private Integer mutableContent; // ์๋ฆผ ์๋น์ค ํ์ฅ ํ๋๊ทธ | ||
@Schema(defaultValue = "") | ||
@JsonProperty("target-content-id") | ||
private String targetContentId; // ์๋ฆผ์ด ํด๋ฆญ๋์์ ๋ ๊ฐ์ ธ์ฌ ์ฐฝ์ ์๋ณ์, UNNotificationContent ๊ฐ์ฒด์ ์ฑ์์ง | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@ToString | ||
public static class Alert { | ||
@Schema(defaultValue = "title") | ||
private String title; | ||
@Schema(defaultValue = "subTitle") | ||
private String subtitle; | ||
@Schema(defaultValue = "body") | ||
private String body; | ||
@Schema(defaultValue = "") | ||
@JsonProperty("launch-image") | ||
private String launchImage; // ์คํ์ ๋ณด์ฌ์ค ์ด๋ฏธ์ง ํ์ผ, ๊ธฐ๋ณธ ์คํ ์ด๋ฏธ์ง ๋์ ์ ๋ ฅํ ์ด๋ฏธ์ง ๋๋ ์คํ ๋ฆฌ๋ณด๋๊ฐ ์ผ์ง | ||
} | ||
} | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/server/capple/config/apns/service/ApnsService.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.server.capple.config.apns.service; | ||
|
||
import java.util.List; | ||
|
||
public interface ApnsService { | ||
<T> Boolean sendApns(T request, String ... deviceTokens); | ||
<T> Boolean sendApns(T request, List<String> deviceTokenList); | ||
<T> Boolean sendApnsToMembers(T request, Long ... memberIds); | ||
<T> Boolean sendApnsToMembers(T request, List<Long> memberIdList); | ||
} |
Oops, something went wrong.