-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.2.0 배포 🎉
- Loading branch information
Showing
322 changed files
with
8,093 additions
and
5,345 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
# 사라지는 Slack 메시지, 우리가 주워줄게! 줍줍 | ||
|
||
|
||
## Members 👩🏻💻🧑🏻💻 | ||
|
||
| [호프](https://github.com/moonheekim0118) | [꼬재](https://github.com/kkojae91) | [봄](https://github.com/JangBomi) | [써머](https://github.com/hyewoncc) | [리차드](https://github.com/HJ-Rich) | [연로그](https://github.com/yeon-06) | | ||
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | | ||
| <img src="https://avatars.githubusercontent.com/u/61469664?v=4" width=200px alt="_"/> | <img src="https://avatars.githubusercontent.com/u/68001045?v=4" width=200px alt="_"/> | <img src="https://avatars.githubusercontent.com/u/55357130?v=4" width=200px alt="_"/> | <img src="https://avatars.githubusercontent.com/u/80666066?v=4" width=200px alt="_"> | <img src="https://avatars.githubusercontent.com/u/62681566?v=4" width=200px alt="_"> | <img src="https://avatars.githubusercontent.com/u/53105735?v=4" width=200px alt="_"> | | ||
| ✨ 프론트엔드 | ✨ 프론트엔드 | 💫 백엔드 | 💫 백엔드 | 💫 백엔드 | 💫 백엔드 | | ||
|
||
|
||
## 😎 API 명세 | ||
https://documenter.getpostman.com/view/13826399/UzJESeDr | ||
|
||
## 😎 스토리북 | ||
https://62e64dc73aafd7bc9338ba73-fihzwjkqkx.chromatic.com | ||
|
||
## 그 외 | ||
|
||
- [줍줍 팀문화 보러가기](https://richard7.notion.site/db4a276903ab477a8db6591d4413f873) | ||
|
||
<div align=center> | ||
<img width="492" alt="스크린샷 2022-09-30 오후 5 31 24" src="https://user-images.githubusercontent.com/80666066/193769096-9162414f-16ff-4c74-878f-5661b0f671cc.png"> | ||
<h2> 사라지는 Slack 메세지, 우리가 주워줄게! </h2> | ||
https://jupjup.site/ | ||
<br> | ||
<br> | ||
<strong>줍줍</strong>은 연결된 슬랙 워크스페이스 메시지를 실시간 백업하여 | ||
<br> | ||
무료 워크스페이스라도 잠길 걱정 없이 언제든 볼 수 있게 해주는 서비스입니다 | ||
<br> | ||
|
||
</div> | ||
|
||
## 📎 바로가기 | ||
|
||
- 📚 [API 문서](https://dev.jupjup.site/docs) | ||
- 🎁 [스토리북](https://62e64dc73aafd7bc9338ba73-fihzwjkqkx.chromatic.com) | ||
- 🐹 [팀문화](https://selective-archeology-e38.notion.site/858f167439b94c9caee71ab177bce08e) | ||
- 🌎 [깃헙 위키](https://github.com/woowacourse-teams/2022-pickpick/wiki) | ||
|
||
<br> | ||
|
||
## 팀원 소개 👩🏻💻🧑🏻💻 | ||
|
||
| [🐈⬛ 호프](https://github.com/moonheekim0118) | [👍 꼬재](https://github.com/kkojae91) | [🌱 봄](https://github.com/JangBomi) | [🏝 써머](https://github.com/hyewoncc) | [🪁 연로그](https://github.com/yeon-06) | | ||
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | | ||
| <a href="https://github.com/moonheekim0118"> <img src="https://avatars.githubusercontent.com/u/61469664?v=4" width=200px alt="_"/> </a> | <a href="https://github.com/kkojae91"> <img src="https://avatars.githubusercontent.com/u/68001045?v=4" width=200px alt="_"/> </a> | <a href="https://github.com/JangBomi"> <img src="https://avatars.githubusercontent.com/u/55357130?v=4" width=200px alt="_"/> </a> | <a href="https://github.com/hyewoncc"> <img src="https://avatars.githubusercontent.com/u/80666066?v=4" width=200px alt="_"/> </a> | <a href="https://github.com/yeon-06"> <img src="https://avatars.githubusercontent.com/u/53105735?v=4" width=200px alt="_"> | | ||
| 프론트엔드 | 프론트엔드 | 백엔드 | 백엔드 | 백엔드 | |
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
85 changes: 35 additions & 50 deletions
85
backend/src/main/java/com/pickpick/auth/application/AuthService.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 |
---|---|---|
@@ -1,87 +1,72 @@ | ||
package com.pickpick.auth.application; | ||
|
||
import com.pickpick.auth.application.dto.WorkspaceInfoDto; | ||
import com.pickpick.auth.support.JwtTokenProvider; | ||
import com.pickpick.auth.ui.dto.LoginResponse; | ||
import com.pickpick.config.SlackProperties; | ||
import com.pickpick.exception.SlackApiCallException; | ||
import com.pickpick.exception.member.MemberNotFoundException; | ||
import com.pickpick.channel.domain.Channel; | ||
import com.pickpick.channel.domain.ChannelRepository; | ||
import com.pickpick.member.domain.Member; | ||
import com.pickpick.member.domain.MemberRepository; | ||
import com.slack.api.methods.MethodsClient; | ||
import com.slack.api.methods.SlackApiException; | ||
import com.slack.api.methods.request.oauth.OAuthV2AccessRequest; | ||
import com.slack.api.methods.request.users.UsersIdentityRequest; | ||
import java.io.IOException; | ||
import javax.transaction.Transactional; | ||
import com.pickpick.support.ExternalClient; | ||
import com.pickpick.workspace.domain.Workspace; | ||
import com.pickpick.workspace.domain.WorkspaceRepository; | ||
import java.util.List; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@Transactional(readOnly = true) | ||
public class AuthService { | ||
|
||
private final MemberRepository members; | ||
private final MethodsClient slackClient; | ||
private final WorkspaceRepository workspaces; | ||
private final ChannelRepository channels; | ||
private final ExternalClient slackClient; | ||
private final JwtTokenProvider jwtTokenProvider; | ||
private final SlackProperties slackProperties; | ||
|
||
public AuthService(final MemberRepository members, final MethodsClient slackClient, | ||
final JwtTokenProvider jwtTokenProvider, final SlackProperties slackProperties) { | ||
public AuthService(final MemberRepository members, final WorkspaceRepository workspaces, | ||
final ChannelRepository channels, final ExternalClient slackClient, | ||
final JwtTokenProvider jwtTokenProvider) { | ||
this.members = members; | ||
this.workspaces = workspaces; | ||
this.channels = channels; | ||
this.slackClient = slackClient; | ||
this.jwtTokenProvider = jwtTokenProvider; | ||
this.slackProperties = slackProperties; | ||
} | ||
|
||
public void verifyToken(final String token) { | ||
jwtTokenProvider.validateToken(token); | ||
} | ||
|
||
@Transactional | ||
public LoginResponse registerWorkspace(final String code) { | ||
WorkspaceInfoDto workspaceInfoDto = slackClient.callWorkspaceInfo(code); | ||
Workspace workspace = workspaces.save(workspaceInfoDto.toEntity()); | ||
|
||
List<Member> allWorkspaceMembers = slackClient.findMembersByWorkspace(workspace); | ||
members.saveAll(allWorkspaceMembers); | ||
|
||
List<Channel> allWorkspaceChannels = slackClient.findChannelsByWorkspace(workspace); | ||
channels.saveAll(allWorkspaceChannels); | ||
|
||
return login(code); | ||
} | ||
|
||
@Transactional | ||
public LoginResponse login(final String code) { | ||
String token = requestSlackToken(code); | ||
String memberSlackId = requestMemberSlackId(token); | ||
String userToken = slackClient.callUserToken(code); | ||
String memberSlackId = slackClient.callMemberSlackId(userToken); | ||
|
||
Member member = members.findBySlackId(memberSlackId) | ||
.orElseThrow(() -> new MemberNotFoundException(memberSlackId)); | ||
Member member = members.getBySlackId(memberSlackId); | ||
|
||
boolean isFirstLogin = member.isFirstLogin(); | ||
member.markLoggedIn(); | ||
member.firstLogin(userToken); | ||
|
||
return LoginResponse.builder() | ||
.token(jwtTokenProvider.createToken(String.valueOf(member.getId()))) | ||
.firstLogin(isFirstLogin) | ||
.build(); | ||
} | ||
|
||
private String requestSlackToken(final String code) { | ||
OAuthV2AccessRequest request = OAuthV2AccessRequest.builder() | ||
.clientId(slackProperties.getClientId()) | ||
.clientSecret(slackProperties.getClientSecret()) | ||
.redirectUri(slackProperties.getRedirectUrl()) | ||
.code(code) | ||
.build(); | ||
|
||
try { | ||
return slackClient.oauthV2Access(request) | ||
.getAuthedUser() | ||
.getAccessToken(); | ||
} catch (IOException | SlackApiException e) { | ||
throw new SlackApiCallException("oauthV2Access"); | ||
} | ||
} | ||
|
||
private String requestMemberSlackId(final String token) { | ||
UsersIdentityRequest request = UsersIdentityRequest.builder() | ||
.token(token) | ||
.build(); | ||
|
||
try { | ||
return slackClient.usersIdentity(request) | ||
.getUser() | ||
.getId(); | ||
} catch (IOException | SlackApiException e) { | ||
throw new SlackApiCallException("usersIdentity"); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
backend/src/main/java/com/pickpick/auth/application/dto/WorkspaceInfoDto.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,22 @@ | ||
package com.pickpick.auth.application.dto; | ||
|
||
import com.pickpick.workspace.domain.Workspace; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class WorkspaceInfoDto { | ||
|
||
private final String workspaceSlackId; | ||
private final String botToken; | ||
private final String botSlackId; | ||
|
||
public WorkspaceInfoDto(final String workspaceSlackId, final String botToken, final String botSlackId) { | ||
this.workspaceSlackId = workspaceSlackId; | ||
this.botToken = botToken; | ||
this.botSlackId = botSlackId; | ||
} | ||
|
||
public Workspace toEntity() { | ||
return new Workspace(workspaceSlackId, botToken, botSlackId); | ||
} | ||
} |
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
42 changes: 0 additions & 42 deletions
42
backend/src/main/java/com/pickpick/channel/application/ChannelCreateService.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.