Skip to content

Conversation

@nahowo
Copy link
Contributor

@nahowo nahowo commented Nov 10, 2024

Summary

  • 디스코드 봇 추가
    • DiscordController
    • DiscordService
    • JDAConfig

Description

  • slackService
    • 슬랙 봇 스케줄링 제거
  • discordController, discordService
    • 디스코드 봇 추가 로직 작성
    • 디스코드 DM 보내는 로직 작성
  • errorCode, resultCode, exception에 관련 내용 추가
  • JDAConfig 작성
  • BoardService
    • 게시물 제출 시 슬랙 알림 로직 제거

Screenshot

Test Checklist

  • 빌드를 다시 진행해 주세요(JDA).
  • 노션을 확인해서 디스코드 봇을 추가해주세요.

Summary by CodeRabbit

  • 신규 기능

    • Discord 및 Slack 연동 기능이 추가되어, 사용자가 Discord/Slack 인증 후 DM(다이렉트 메시지)을 받을 수 있습니다.
    • Discord 및 Slack으로 DM을 전송할 수 있는 API 엔드포인트가 추가되었습니다.
  • 버그 수정

    • 없음
  • 문서화

    • Swagger API 문서의 기본 URL이 /api/v2로 변경되었습니다.
  • 리팩터링

    • SNS 연동 관련 데이터 구조가 세분화되어, 토큰과 채널 정보를 각각의 필드로 분리하였습니다.
  • 기타

    • Discord/Slack 연동 관련 에러 및 성공 코드가 추가되었습니다.
    • Slack 및 Discord 관련 설정이 환경 변수로 관리됩니다.

@nahowo nahowo requested a review from dlwhsk0 November 10, 2024 13:57
@nahowo nahowo linked an issue Nov 10, 2024 that may be closed by this pull request
@nahowo nahowo self-assigned this Nov 10, 2024
@nahowo
Copy link
Contributor Author

nahowo commented Nov 12, 2024

24/11/12 21:47 추가사항

  • 기존 슬랙 봇 추가 로직 제거
  • 슬랙 봇 연결 로직 추가
    • 슬랙 유저 정보 가져와서 sns 엔티티로 저장
    • 사용자에게 DM 전송
  • Sns 도메인 수정
    • 슬랙의 bot token, user token, slack user id 등과 디스코드의 channel id, discord user id 등을 저장하기 어려워 기존 필드의 이름을 수정하고 몇몇 필드 추가

@nahowo nahowo marked this pull request as draft November 12, 2024 13:12
@nahowo nahowo marked this pull request as ready for review November 12, 2024 13:13
@nahowo nahowo marked this pull request as draft November 13, 2024 09:34
@nahowo nahowo marked this pull request as ready for review November 15, 2024 01:59
@nahowo nahowo changed the title feat: 디스코드 봇 추가 feat: 디스코드, 슬랙 봇 추가 Nov 15, 2024
@nahowo
Copy link
Contributor Author

nahowo commented Nov 15, 2024

11/15 16:12 변경사항

  • jwt 토큰 api 적용 PR 관련
    • slack, discord의 service, controller 계층에서 HttpServletRequest 제거, @ AuthenticationPrincipal 적용
  • slack, discord 디렉토리
    • 기존 sns 디렉토리 제거, controller, service 디렉토리로 각각 이동

Copy link
Member

@dlwhsk0 dlwhsk0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nahowo nahowo merged commit fc2512f into develop Dec 3, 2024
@nahowo nahowo deleted the feat/#91 branch December 3, 2024 06:05
@nahowo
Copy link
Contributor Author

nahowo commented Apr 17, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Apr 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Apr 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

이번 변경에서는 Slack 및 Discord와의 연동을 위한 백엔드 기능이 대폭 확장되었습니다. Slack과 Discord의 OAuth 인증, DM(Direct Message) 전송, 사용자 정보 저장 및 조회, 리마인더 메시지 발송 로직이 신규 서비스와 컨트롤러를 통해 구현되었습니다. SNS 관련 데이터 모델(Sns, SnsCreateRequest, SnsResponseDTO)이 Slack/Discord에 맞게 세분화되었으며, 관련 예외 및 결과 코드도 추가되었습니다. 기존 Slack 연동 로직은 새로운 구조로 대체되었고, Discord 연동을 위한 설정, 서비스, 예외, 컨트롤러가 새로 도입되었습니다. 일부 기존 클래스 및 파일이 삭제 또는 경로가 변경되었습니다.

Changes

파일/경로 그룹 변경 요약
build.gradle, application.yml Slack/Discord API 클라이언트 의존성 추가, Discord 봇 토큰 환경설정 추가
src/main/java/com/Alchive/backend/config/JDAConfig.java Discord JDA 클라이언트 Spring Bean 설정 클래스 추가
src/main/java/com/Alchive/backend/config/SwaggerConfig.java Swagger API 문서의 기본 URL을 v2로 변경
src/main/java/com/Alchive/backend/config/error/ErrorCode.java, .../exception/sns/InvalidGrantException.java, .../exception/sns/NoSuchDiscordUserException.java Discord 관련 오류 코드 및 예외 클래스 추가
src/main/java/com/Alchive/backend/config/jwt/JwtController.java, .../service/SnsService.java Lombok @Slf4j 어노테이션 추가
src/main/java/com/Alchive/backend/config/result/ResultCode.java Slack/Discord DM 성공 결과 코드 추가
src/main/java/com/Alchive/backend/controller/BoardController.java SlackService import 경로 변경
src/main/java/com/Alchive/backend/controller/DiscordController.java, .../SlackController.java Discord/Slack 연동 REST 컨트롤러 신규 추가
src/main/java/com/Alchive/backend/domain/sns/Sns.java, .../dto/request/SnsCreateRequest.java, .../dto/response/SnsResponseDTO.java SNS 토큰/채널 필드 세분화 및 관련 생성자/팩토리 메서드 수정
src/main/java/com/Alchive/backend/repository/BoardRepository.java 미해결 보드 조회 쿼리에 userId 조건 추가
src/main/java/com/Alchive/backend/repository/SnsReporitory.java userId와 SNS 카테고리로 SNS 정보 조회/존재여부 확인 메서드 추가
src/main/java/com/Alchive/backend/service/DiscordService.java, .../SlackService.java Discord/Slack OAuth, DM 전송, 리마인더 등 서비스 신규 구현
src/main/java/com/Alchive/backend/slack/SlackController.java, .../SlackService.java 기존 Slack 연동 컨트롤러/서비스 파일 삭제

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant Backend
    participant SlackAPI
    participant DiscordAPI

    %% Slack DM 연결 플로우
    User->>Frontend: Slack 인증 코드 발급
    Frontend->>Backend: /api/v2/slack/dm/open (code)
    Backend->>SlackAPI: OAuth 토큰 교환 (code)
    SlackAPI-->>Backend: bot_token, user_token, user_id 등
    Backend->>DB: SNS 정보 저장
    Backend->>SlackAPI: DM 전송 (bot_token, user_id, 메시지)
    Backend-->>Frontend: DM 전송 성공 응답

    %% Discord DM 연결 플로우
    User->>Frontend: Discord 인증 코드 발급
    Frontend->>Backend: /api/v2/discord/dm/open (code)
    Backend->>DiscordAPI: OAuth 토큰 교환 (code)
    DiscordAPI-->>Backend: access_token
    Backend->>DiscordAPI: 사용자 정보 조회 (access_token)
    DiscordAPI-->>Backend: discord_user_id
    Backend->>DiscordAPI: DM 채널 생성 (discord_user_id)
    DiscordAPI-->>Backend: channel_id
    Backend->>DB: SNS 정보 저장
    Backend->>DiscordAPI: DM 전송 (channel_id, 메시지)
    Backend-->>Frontend: DM 전송 성공 응답
Loading

Poem

🐰
슬랙과 디스코드에 DM을 쏘네,
봇 토큰, 유저 토큰, 채널까지 정리했지!
인증 코드 받아와서,
환영 인사 전송하고,
리마인더도 이제 자동이지!
토끼 개발자, 귀 쫑긋 세우고
SNS 연동, 오늘도 한 뼘 성장!

( ˘▽˘)っ🥕

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e52a4a and ebae369.

📒 Files selected for processing (22)
  • build.gradle (1 hunks)
  • src/main/java/com/Alchive/backend/config/JDAConfig.java (1 hunks)
  • src/main/java/com/Alchive/backend/config/SwaggerConfig.java (1 hunks)
  • src/main/java/com/Alchive/backend/config/error/ErrorCode.java (1 hunks)
  • src/main/java/com/Alchive/backend/config/error/exception/sns/InvalidGrantException.java (1 hunks)
  • src/main/java/com/Alchive/backend/config/error/exception/sns/NoSuchDiscordUserException.java (1 hunks)
  • src/main/java/com/Alchive/backend/config/jwt/JwtController.java (1 hunks)
  • src/main/java/com/Alchive/backend/config/result/ResultCode.java (1 hunks)
  • src/main/java/com/Alchive/backend/controller/BoardController.java (1 hunks)
  • src/main/java/com/Alchive/backend/controller/DiscordController.java (1 hunks)
  • src/main/java/com/Alchive/backend/controller/SlackController.java (1 hunks)
  • src/main/java/com/Alchive/backend/domain/sns/Sns.java (2 hunks)
  • src/main/java/com/Alchive/backend/dto/request/SnsCreateRequest.java (1 hunks)
  • src/main/java/com/Alchive/backend/dto/response/SnsResponseDTO.java (1 hunks)
  • src/main/java/com/Alchive/backend/repository/BoardRepository.java (1 hunks)
  • src/main/java/com/Alchive/backend/repository/SnsReporitory.java (2 hunks)
  • src/main/java/com/Alchive/backend/service/DiscordService.java (1 hunks)
  • src/main/java/com/Alchive/backend/service/SlackService.java (1 hunks)
  • src/main/java/com/Alchive/backend/service/SnsService.java (1 hunks)
  • src/main/java/com/Alchive/backend/slack/SlackController.java (0 hunks)
  • src/main/java/com/Alchive/backend/slack/SlackService.java (0 hunks)
  • src/main/resources/application.yml (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] 디스코드 & 슬랙 봇 추가

3 participants