Skip to content

Commit

Permalink
fix: 회원 가입 로직에서 Notion OG 획득 제거 (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimminkyeu authored Dec 11, 2024
1 parent beab617 commit 92fda35
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import lombok.RequiredArgsConstructor;
import techpick.api.domain.user.service.strategy.StarterFolderStrategy;
import techpick.core.annotation.TechpickAnnotation;
import techpick.core.model.folder.Folder;
import techpick.core.model.folder.FolderRepository;
import techpick.core.model.user.User;
Expand All @@ -18,6 +19,22 @@ public class UserService {
private final FolderRepository folderRepository;
private final StarterFolderStrategy folderStrategy;

/**
* @author minkyeu kim
* TODO: 로그인 회원가입 예외 처리
* 기본 폴더 생성 실패시 회원 가입 자체가 실패해야 한다. DB가 오염되기 때문.
* 그렇다고 회원 가입 로직을 Transaction 으로 감싸면
* 현재 로그인 / 회원가입 주체가 백엔드여서 프론트엔드에서
* UI 로직 ("가입 실패하였습니다") 처리를 못한다.
* -
* 방법은 있음.
* 1. 백엔드에서 Transaction으로 감싸고, 회원 가입 / 로그인이 실패하면 "/login/failed" 로 리다이렉트
* 2. 프론트 Next.js 에서 해당 경로는 실패 UI 띄워준다.
* 근데 이 방식이 맞는지 잘 모르겠음.
* 결국 프론트에서 로그인 / 회원가입의 주체를 가져가는게 맞지 않을까?
* 그래야 일관된 로그인 / 회원가입 UI 처리가 가능하다.
*/
@TechpickAnnotation.MeasureTime
public void createUser(OAuth2UserInfo userInfo) {
if (!userRepository.existsBySocialProviderId(userInfo.getName())) {
User user = User.createSocialUser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import techpick.api.domain.link.dto.LinkInfo;
import techpick.api.domain.link.exception.ApiLinkException;
import techpick.api.domain.link.service.LinkService;
import techpick.api.domain.pick.dto.PickCommand;
import techpick.api.domain.pick.service.PickService;
import techpick.core.model.folder.Folder;
import techpick.core.model.user.User;

@Slf4j
Expand All @@ -32,10 +33,18 @@ public class ManualInitStrategy implements ContentInitStrategy {
"https://positive-airboat-4de.notion.site/15841a7fba65809d89a6dceb89060f70?pvs=4"
);

/**
* link 가 db 에 존재하지 않으면 새로 추가함 by psh
*/
@Override
public void initContent(User user, Long folderId) {
for (var url : MANUAL_URLS) {
var linkInfo = linkService.saveLinkAndUpdateOgTag(url);
LinkInfo linkInfo = null;
try {
linkInfo = linkService.getLinkInfo(url);
} catch (ApiLinkException exception) {
linkInfo = linkService.saveLinkAndUpdateOgTag(url);
}
var command = new PickCommand.Create(
user.getId(), linkInfo.title(), new ArrayList<>(), folderId, linkInfo
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public void initContent(User user, Long folderId) {
/**
* 링크 일부가 잘못되었어도, 가능한 링크에 대해서 폴더가 생성되도록 처리.
* 리스트를 역순으로 삽입해야 UI 상단에 랭킹이 높은 Pick이 표시된다.
*
* link 가 db 에 존재하지 않으면 새로 추가함 by psh
*/
private void savePickFromRankingList(Long userId, List<UrlWithCount> rankingList, Long destinationFolderId) {
if (Objects.isNull(rankingList)) {
Expand All @@ -57,7 +59,6 @@ private void savePickFromRankingList(Long userId, List<UrlWithCount> rankingList
try {
linkInfo = linkService.getLinkInfo(curr.url());
} catch (ApiLinkException exception) {
// mongodb 에서 받은 link 가 db 에 존재하지 않으면 새로 추가함 by psh
linkInfo = linkService.saveLinkAndUpdateOgTag(curr.url());
}
if (linkInfo.title().isBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import techpick.api.domain.folder.dto.FolderCommand;
import techpick.api.domain.folder.service.FolderService;
import techpick.api.domain.link.service.LinkService;
import techpick.api.domain.pick.service.PickService;
import techpick.api.infrastructure.folder.FolderDataHandler;
import techpick.core.model.folder.Folder;
import techpick.core.model.user.User;
Expand Down

0 comments on commit 92fda35

Please sign in to comment.