Skip to content

Commit 1c6422c

Browse files
author
Lee Euije
authored
Merge pull request #380 from team-yello/staging
YEL-173 [deploy] v1.21
2 parents 508a8e9 + 119b9fb commit 1c6422c

26 files changed

+518
-68
lines changed

src/main/java/com/yello/server/domain/authorization/filter/JwtExceptionFilter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ protected void doFilterInternal(
4747
|| requestPath.startsWith("/actuator") || requestPath.startsWith("/prometheus")
4848
|| requestPath.startsWith("/api/v1/admin/login")
4949
|| requestPath.startsWith("/v2/apple/notifications")
50+
|| requestPath.startsWith("/v2/google/notifications")
5051
|| (requestPath.startsWith("/api/v1/auth")
5152
&& !requestPath.startsWith("/api/v1/auth/token/issue"))) {
5253
filterChain.doFilter(request, response);
@@ -60,8 +61,8 @@ protected void doFilterInternal(
6061
log.info("Authorization-access : {}", accessHeader);
6162
log.info("Authorization-refresh : {}", refreshHeader);
6263

63-
if (accessHeader==null || !accessHeader.startsWith(BEARER)
64-
|| refreshHeader==null || !refreshHeader.startsWith(BEARER)) {
64+
if (accessHeader == null || !accessHeader.startsWith(BEARER)
65+
|| refreshHeader == null || !refreshHeader.startsWith(BEARER)) {
6566
throw new CustomAuthenticationException(AUTHENTICATION_ERROR);
6667
}
6768

@@ -72,7 +73,7 @@ protected void doFilterInternal(
7273
val accessHeader = request.getHeader(AUTHORIZATION);
7374
log.info("Authorization : {}", accessHeader);
7475

75-
if (accessHeader==null || !accessHeader.startsWith(BEARER)) {
76+
if (accessHeader == null || !accessHeader.startsWith(BEARER)) {
7677
throw new CustomAuthenticationException(AUTHENTICATION_ERROR);
7778
}
7879

src/main/java/com/yello/server/domain/authorization/filter/JwtFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
4040
|| requestPath.startsWith("/actuator") || requestPath.startsWith("/prometheus")
4141
|| requestPath.startsWith("/api/v1/admin/login")
4242
|| requestPath.startsWith("/api/v1/auth")
43-
|| requestPath.startsWith("/v2/apple/notifications")) {
43+
|| requestPath.startsWith("/v2/apple/notifications")
44+
|| requestPath.startsWith("/v2/google/notifications")) {
4445
filterChain.doFilter(request, response);
4546
return;
4647
}

src/main/java/com/yello/server/domain/purchase/controller/PurchaseNotificationController.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package com.yello.server.domain.purchase.controller;
22

33
import static com.yello.server.global.common.SuccessCode.POST_APPLE_NOTIFICATION_SUCCESS;
4+
import static com.yello.server.global.common.SuccessCode.POST_GOOGLE_NOTIFICATION_SUCCESS;
45

56
import com.yello.server.domain.purchase.dto.request.AppleNotificationRequest;
7+
import com.yello.server.domain.purchase.dto.request.GooglePubSubNotificationRequest;
68
import com.yello.server.domain.purchase.service.PurchaseService;
79
import com.yello.server.global.common.dto.BaseResponse;
10+
import com.yello.server.global.common.dto.EmptyObject;
811
import com.yello.server.infrastructure.slack.annotation.SlackApplePurchaseNotification;
912
import lombok.RequiredArgsConstructor;
13+
import lombok.extern.slf4j.Slf4j;
1014
import org.springframework.web.bind.annotation.PostMapping;
1115
import org.springframework.web.bind.annotation.RequestBody;
1216
import org.springframework.web.bind.annotation.RestController;
1317

18+
@Slf4j
1419
@RestController
1520
@RequiredArgsConstructor
1621
public class PurchaseNotificationController {
@@ -25,4 +30,12 @@ public BaseResponse appleNotification(
2530
purchaseService.appleNotification(request);
2631
return BaseResponse.success(POST_APPLE_NOTIFICATION_SUCCESS);
2732
}
33+
34+
@PostMapping("/v2/google/notifications")
35+
public BaseResponse<EmptyObject> googleNotification(
36+
@RequestBody GooglePubSubNotificationRequest request
37+
) {
38+
purchaseService.googleNotification(request);
39+
return BaseResponse.success(POST_GOOGLE_NOTIFICATION_SUCCESS, EmptyObject.builder().build());
40+
}
2841
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.yello.server.domain.purchase.dto.request;
2+
3+
import com.yello.server.domain.purchase.dto.request.google.GooglePubSubMessage;
4+
5+
public record GooglePubSubNotificationRequest(
6+
GooglePubSubMessage message,
7+
String subscription
8+
) {
9+
10+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.yello.server.domain.purchase.dto.request.google;
2+
3+
import static com.yello.server.global.common.util.ConstantUtil.GOOGLE_FIVE_TICKET_ID;
4+
import static com.yello.server.global.common.util.ConstantUtil.GOOGLE_ONE_TICKET_ID;
5+
import static com.yello.server.global.common.util.ConstantUtil.GOOGLE_TWO_TICKET_ID;
6+
7+
import com.fasterxml.jackson.annotation.JsonInclude;
8+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
9+
import com.yello.server.domain.purchase.entity.ProductType;
10+
import org.springframework.util.ObjectUtils;
11+
12+
@JsonInclude(Include.NON_NULL)
13+
public record DeveloperNotification(
14+
String version,
15+
String packageName,
16+
Long eventTimeMillis,
17+
OneTimeProductNotification oneTimeProductNotification,
18+
SubscriptionNotification subscriptionNotification,
19+
TestNotification testNotification
20+
) {
21+
22+
public ProductType getProductType() {
23+
if (!ObjectUtils.isEmpty(testNotification)) {
24+
return ProductType.TEST;
25+
} else if (!ObjectUtils.isEmpty(subscriptionNotification)) {
26+
return ProductType.YELLO_PLUS;
27+
} else if (!ObjectUtils.isEmpty(oneTimeProductNotification)) {
28+
switch (oneTimeProductNotification.sku()) {
29+
case GOOGLE_ONE_TICKET_ID -> {
30+
return ProductType.ONE_TICKET;
31+
}
32+
case GOOGLE_TWO_TICKET_ID -> {
33+
return ProductType.TWO_TICKET;
34+
}
35+
case GOOGLE_FIVE_TICKET_ID -> {
36+
return ProductType.FIVE_TICKET;
37+
}
38+
}
39+
}
40+
return null;
41+
}
42+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.yello.server.domain.purchase.dto.request.google;
2+
3+
import java.util.Map;
4+
import java.util.Optional;
5+
6+
public record GooglePubSubMessage(
7+
Optional<Map<String, String>> attributes,
8+
String data,
9+
Long messageId,
10+
Optional<Long> message_id,
11+
Optional<String> publishTime,
12+
Optional<String> publish_time
13+
) {
14+
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.yello.server.domain.purchase.dto.request.google;
2+
3+
public record OneTimeProductNotification(
4+
String version,
5+
OneTimeProductNotificationType notificationType,
6+
String purchaseToken,
7+
String sku
8+
) {
9+
10+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.yello.server.domain.purchase.dto.request.google;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
6+
@Getter
7+
public enum OneTimeProductNotificationType {
8+
@SerializedName("1")
9+
ONE_TIME_PRODUCT_PURCHASED(1),
10+
@SerializedName("2")
11+
ONE_TIME_PRODUCT_CANCELED(2);
12+
13+
private final Long value;
14+
15+
OneTimeProductNotificationType(long value) {
16+
this.value = value;
17+
}
18+
19+
@Override
20+
public String toString() {
21+
return this.name();
22+
}
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.yello.server.domain.purchase.dto.request.google;
2+
3+
public record SubscriptionNotification(
4+
String version,
5+
SubscriptionNotificationType notificationType,
6+
String purchaseToken,
7+
String subscriptionId
8+
) {
9+
10+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.yello.server.domain.purchase.dto.request.google;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
6+
@Getter
7+
public enum SubscriptionNotificationType {
8+
@SerializedName("1")
9+
SUBSCRIPTION_RECOVERED(1),
10+
@SerializedName("2")
11+
SUBSCRIPTION_RENEWED(2),
12+
@SerializedName("3")
13+
SUBSCRIPTION_CANCELED(3),
14+
@SerializedName("4")
15+
SUBSCRIPTION_PURCHASED(4),
16+
@SerializedName("5")
17+
SUBSCRIPTION_ON_HOLD(5),
18+
@SerializedName("6")
19+
SUBSCRIPTION_IN_GRACE_PERIOD(6),
20+
@SerializedName("7")
21+
SUBSCRIPTION_RESTARTED(7),
22+
@SerializedName("8")
23+
SUBSCRIPTION_PRICE_CHANGE_CONFIRMED(8),
24+
@SerializedName("9")
25+
SUBSCRIPTION_DEFERRED(9),
26+
@SerializedName("10")
27+
SUBSCRIPTION_PAUSED(10),
28+
@SerializedName("11")
29+
SUBSCRIPTION_PAUSE_SCHEDULE_CHANGED(11),
30+
@SerializedName("12")
31+
SUBSCRIPTION_REVOKED(12),
32+
@SerializedName("13")
33+
SUBSCRIPTION_EXPIRED(13);
34+
35+
private final Integer value;
36+
37+
SubscriptionNotificationType(int value) {
38+
this.value = value;
39+
}
40+
41+
@Override
42+
public String toString() {
43+
return this.name();
44+
}
45+
}

0 commit comments

Comments
 (0)