Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop


jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/spotless-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
pull_request:
branches:
- main
- develop

push:
branches:
- main
- develop

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ public InstagramSocialShareServiceImpl(
@Override
protected void addPlatformSpecificInfo(Map<String, Object> result, Content content, String baseUrl) {
// 인스타그램 공유 URL 생성
String shareUrl = createShareUrlWithUtm(baseUrl, "instagram");
String instagramShareUrl = createShareUrlWithUtm(baseUrl, "instagram");

try {
// 1. 인스타그램 스토리 딥링크 생성
String storyDeepLink = generateInstagramStoryDeepLink(
content.getThumbnailUrl(),
shareUrl,
instagramShareUrl,
content.getTitle());

result.put("instagramStoryDeepLink", storyDeepLink);
result.put("instagramShareUrl", shareUrl);
result.put("instagramCopyMessage", content.getTitle() + " " + shareUrl);
result.put("instagramShareUrl", instagramShareUrl);
result.put("instagramCopyMessage", content.getTitle() + " " + instagramShareUrl);
result.put("instagramShareInstructions",
"인스타그램 공유 방법:\n" +
"1. 스토리 공유: '인스타그램 스토리에 공유' 버튼을 클릭하세요.\n" +
Expand Down Expand Up @@ -121,7 +121,7 @@ public SocialShareResponse generateInstagramShareUrl(Long contentId, String cust
* 인스타그램에 직접 공유하기 (현재 API 미지원)
*/
@Override
public SocialShareResponse shareToSocialMedia(Long contentId, String message, String authToken) {
public SocialShareResponse shareToSocialMedia(Long contentId, String message) {
return SocialShareResponse.failure("인스타그램은 API를 통한 직접 공유를 지원하지 않습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.spoti.api.auth.domain.oauth2.socialShare.usecase;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
Expand All @@ -18,6 +19,7 @@
/**
* 카카오톡 공유 기능 구현 클래스
*/
@Getter
@Service
@Primary
public class KakaoSocialShareServiceImpl extends SocialShareServiceImpl {
Expand All @@ -34,13 +36,13 @@ public KakaoSocialShareServiceImpl(
@Override
protected void addPlatformSpecificInfo(Map<String, Object> result, Content content, String baseUrl) {
// 카카오톡 공유 URL 생성
String shareUrl = createShareUrlWithUtm(baseUrl, "kakao");
String kakaoShareUrl = createShareUrlWithUtm(baseUrl, "kakao");

// 카카오톡에서만 사용되는 특정 정보 추가
result.put("kakaoApiKey", kakaoApiKey);

// 카카오톡 메시지 템플릿 정보 추가
Map<String, Object> kakaoTemplate = generateKakaoTemplate(content, shareUrl);
Map<String, Object> kakaoTemplate = generateKakaoTemplate(content, kakaoShareUrl);
result.put("kakaoTemplate", kakaoTemplate);
}

Expand Down Expand Up @@ -95,18 +97,11 @@ public SocialShareResponse getKakaoTemplateByContentId(Long contentId) {
return response;
}

/**
* API 키 getter 메서드
*/
public String getKakaoApiKey() {
return kakaoApiKey;
}

/**
* 카카오톡에 직접 공유하기 (현재 API 미지원)
*/
@Override
public SocialShareResponse shareToSocialMedia(Long contentId, String message, String authToken) {
public SocialShareResponse shareToSocialMedia(Long contentId, String message) {
return SocialShareResponse.failure("카카오톡은 SDK를 통한 클라이언트 측 공유만 지원합니다.");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.spoti.api.auth.domain.oauth2.socialShare.usecase;

import java.util.Map;
import com.spoti.api.auth.domain.oauth2.socialShare.dto.SocialShareResponse;

/**
Expand All @@ -24,19 +23,11 @@ public interface SocialShareService {
*/
void trackShare(Long contentId, String platform, Long userId);

/**
* 사용자 인증 토큰 검증
* @param authToken 인증 토큰
* @return 유효성 여부
*/
boolean validateToken(String authToken);

/**
* 소셜 미디어에 직접 콘텐츠 공유하기
* @param contentId 컨텐츠 ID
* @param message 공유 메시지
* @param authToken 인증 토큰
* @return 공유 결과 정보
*/
SocialShareResponse shareToSocialMedia(Long contentId, String message, String authToken);
SocialShareResponse shareToSocialMedia(Long contentId, String message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,11 @@ public void trackShare(Long contentId, String platform, Long userId) {
shareStatisticsRepository.save(stats);
}

/**
* 사용자 인증 토큰 검증
*/
@Override
public boolean validateToken(String authToken) {
// 실제 구현에서는 JWT 토큰 검증 등의 로직 필요
return authToken != null && authToken.startsWith("Bearer ");
}

/**
* 소셜 미디어에 직접 콘텐츠 공유하기 (기본 구현)
*/
@Override
public SocialShareResponse shareToSocialMedia(Long contentId, String message, String authToken) {
public SocialShareResponse shareToSocialMedia(Long contentId, String message) {
return SocialShareResponse.failure("이 플랫폼은 직접 공유를 지원하지 않습니다.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void addPlatformSpecificInfo(Map<String, Object> platformData, Content

/**
* X 공유 URL 생성
* 프론트엔드에서 window.open()으로 열 수 있는 URL을 생성합니다.
* 프론트엔드에서 window.open()으로 열 수 있는 URL을 생성
*/
public String generateXShareUrl(Long contentId, String customText) {
try {
Expand Down Expand Up @@ -80,7 +80,7 @@ public String generateXShareUrl(Long contentId, String customText) {
* X(트위터)로 직접 공유하기 (현재는 API 접근이 불가능하므로 지원하지 않음)
*/
@Override
public SocialShareResponse shareToSocialMedia(Long contentId, String message, String authToken) {
public SocialShareResponse shareToSocialMedia(Long contentId, String message) {
try {
// 공유 URL 생성만 제공
String shareUrl = generateXShareUrl(contentId, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,50 +236,6 @@ public ResponseEntity<Void> trackShare(
return ResponseEntity.ok().build();
}

/**
* 소셜 미디어 직접 공유 API (OAuth 인증 필요한 경우)
*/
@Operation(summary = "소셜 미디어에 직접 공유", description = "소셜 미디어 플랫폼에 컨텐츠를 직접 공유합니다 (인증 필요한 경우)")
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "공유 성공",
content = @Content(
schema = @Schema(implementation = SocialShareResponse.class)
)
),
@ApiResponse(
responseCode = "400",
description = "잘못된 요청",
content = @Content(
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(
value = "{\"status\": 400, \"code\": \"S005\", \"message\": \"지원하지 않는 플랫폼입니다.\"}"
)
)
),
@ApiResponse(
responseCode = "401",
description = "인증 오류",
content = @Content(
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(
value = "{\"status\": 401, \"code\": \"S006\", \"message\": \"인증이 필요합니다.\"}"
)
)
),
@ApiResponse(
responseCode = "500",
description = "서버 오류",
content = @Content(
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(
value = "{\"status\": 500, \"code\": \"S007\", \"message\": \"공유 처리 중 오류 발생\"}"
)
)
)
})

@PostMapping("/post")
public ResponseEntity<SocialShareResponse> postToSocialMedia(
@io.swagger.v3.oas.annotations.parameters.RequestBody(
Expand All @@ -292,41 +248,30 @@ public ResponseEntity<SocialShareResponse> postToSocialMedia(
)
)
)
@RequestBody SocialShareRequest request,
@Parameter(description = "인증 토큰 (OAuth 인증이 필요한 경우)")
@RequestHeader(value = "Authorization", required = false) String authToken) {
@RequestBody SocialShareRequest request) {

String platform = request.getPlatform().toLowerCase();

// OAuth 인증이 필요한 경우 토큰 검증
if ("x".equals(platform) && (authToken == null || !xShareService.validateToken(authToken))) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
.body(SocialShareResponse.failure("인증이 필요합니다."));
}

try {
SocialShareResponse response;

switch (platform) {
case "x":
response = xShareService.shareToSocialMedia(
request.getContentId(),
request.getMessage(),
authToken);
request.getMessage());
break;

case "kakao":
response = kakaoShareService.shareToSocialMedia(
request.getContentId(),
request.getMessage(),
authToken);
request.getMessage());
break;

case "instagram":
response = instagramShareService.shareToSocialMedia(
request.getContentId(),
request.getMessage(),
authToken);
request.getMessage());
break;

default:
Expand All @@ -341,4 +286,5 @@ public ResponseEntity<SocialShareResponse> postToSocialMedia(
.body(SocialShareResponse.failure("공유 처리 중 오류 발생: " + e.getMessage()));
}
}

}