Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release dev to master #363

Merged
merged 40 commits into from
Dec 3, 2024
Merged

Release dev to master #363

merged 40 commits into from
Dec 3, 2024

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Nov 23, 2024

swh00tw and others added 2 commits November 21, 2024 18:31
## Description

<!--- Describe your changes in detail -->
Each time this action run, it will request reviews from committers.
However, if the committers already approved, the request review
operation will overwrite the approved review from committers. This PR
fix this issue by checking the current review status before requesting
review.

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Notes

<!-- Other thing to say -->

## Test

<!--- Please describe in detail how you tested your changes locally. -->

## Screenshots (if appropriate):

<!--- Add screenshots of your changes here -->

## TODO

- [ ] Clear `console.log` or `console.error` for debug usage
- [ ] Update the documentation `recnet-docs` if needed
Copy link

vercel bot commented Nov 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
recnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 0:10am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
recnet-docs ⬜️ Ignored (Inspect) Visit Preview Dec 3, 2024 0:10am

## Description

This PR is the backend part of migrating slack app to the oath access
token, which will resolve the limitation of single workspace.

Doc:
https://www.notion.so/Slack-OAuth-flow-14551bd6607c80d08a13f56c04a81abd

What's included in this PR:

1. Add following API endpoints:

- `GET /users/subscriptions/slack/oauth`: ger user's slack workspace
name they installed
- `POST /users/subscriptions/slack/oauth`: Post code from FE to slack
API to exchange the access token, store information in DB
- `DELETE /users/subscriptions/slack/oauth`: delete the user's slack
information

2. Add back slack test API `POST /subscriptions/slack/test`
3. modify SlackTransporter logic to use the user's accessToken when
sending messages
4. Add new slack fields and delete slackEmail fields in user table


## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Notes

<!-- Other thing to say -->
1. AccessToken is encrypted in the storage and is decrypted before it
needs to be used. Encryption key is stored as an environment variable.
2. Backward compatible. If the user has subscribed Slack channel without
a user access token, we will use the one in env var.

## Test

<!--- Please describe in detail how you tested your changes locally. -->

1. Run local server
2. Pasting this URL in your browser (fill in the scope and client_id)

`https://slack.com/oauth/v2/authorize?scope={scope}&client_id={client_id}`
<img width="1464" alt="Screenshot 2024-11-24 at 9 24 53 PM"
src="https://github.com/user-attachments/assets/c771efc8-4e8c-490c-a984-dc81d20a4ae3">

3. Choose a workspace and click allow button, pull the code in the
callback request from devtools
<img width="736" alt="Screenshot 2024-11-24 at 9 26 05 PM"
src="https://github.com/user-attachments/assets/b5a9e8fa-c22b-45f9-9d3b-3cf490bd3e53">
4. Use the code to hit `POST /users/subscriptions/slack/oauth`
5. Hit `POST /subscriptions/slack/test` to see if you got the slack
message
6. Hit `GET /users/subscriptions/slack/oauth` and `DELETE
/users/subscriptions/slack/oauth` to see if it works correctly

## Screenshots (if appropriate):

<!--- Add screenshots of your changes here -->
N/A

## TODO

- [x] Clear `console.log` or `console.error` for debug usage
- [ ] Update the documentation `recnet-docs` if needed
- [ ] Update environment variables in staging and production env
- [ ] Add unit tests
- [ ] Add migration announcement with specific deadline
swh00tw and others added 10 commits November 25, 2024 19:00
## Description

<!--- Describe your changes in detail -->
There's a "false" prefix in slack template. Remove it.

![Screenshot 2024-11-26 at 10 16
25 PM](https://github.com/user-attachments/assets/76d56de7-a4a1-4e99-937d-45599a31d624)

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Notes

<!-- Other thing to say -->


## Test

<!--- Please describe in detail how you tested your changes locally. -->

## Screenshots (if appropriate):

<!--- Add screenshots of your changes here -->


## TODO

- [ ] Clear `console.log` or `console.error` for debug usage
- [ ] Update the documentation `recnet-docs` if needed
## Description

<!--- Describe your changes in detail -->
Finish slack oauth flow.

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

- #261 
- #64 

## Notes

<!-- Other thing to say -->


## Test

<!--- Please describe in detail how you tested your changes locally. -->
Before test, update `.env.local`
- `NEXT_PUBLIC_BASE_URL` should be `https://localhost:3000`
- Add `SLACK_APP_CLIENT_ID`
- Add `SLACK_OAUTH_APP_SCOPES` 
- Add`SLACK_OAUTH_REDIRECT_URI="/api/slack/oauth/callback"`

Run `nx dev:ssl recnet` and go to `https://localhost:3000`
- Go to setting and subscription tab -> Click the button to install
slack app to your workspace
- Should redirect you to slack page
- Should able to choose different workspace
- After clicking "Allow", should redirect back to frontend and see the
success message
- Go to setting again, should see the workspace name of where you
install the app


## Screenshots (if appropriate):

<!--- Add screenshots of your changes here -->
![Screenshot 2024-11-21 at 5 59
40 PM](https://github.com/user-attachments/assets/76d381f6-4dfd-49ee-976a-944b686a6d55)
![Screenshot 2024-11-21 at 5 59
50 PM](https://github.com/user-attachments/assets/092f53a1-81aa-4914-bebb-2ebc6f27f1d5)
![Screenshot 2024-11-21 at 6 00
07 PM](https://github.com/user-attachments/assets/cae362f9-58b8-4b0a-9f2a-ea4c1eb7dfc4)

## TODO

- [ ] Clear `console.log` or `console.error` for debug usage
- [ ] Update the documentation `recnet-docs` if needed
joannechen1223 and others added 3 commits December 2, 2024 18:38
## Description

<!--- Describe your changes in detail -->
Fix the issue of `bad_redirect_uri` in staging env. The root cause is
that if we specify the redirect_uri in the authorize and redirect stage,
we should also pass the redirect_uri with code to access information in
our backend service. Otherwise, if we setup multiple redirect URLs for
the app, it will always take the first redirect URL and oauth will fail.

Ref: https://api.slack.com/authentication/oauth-v2#asking

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->
N/A

## Notes

<!-- Other thing to say -->

## Test

<!--- Please describe in detail how you tested your changes locally. -->

## Screenshots (if appropriate):

<!--- Add screenshots of your changes here -->

## TODO

- [ ] Clear `console.log` or `console.error` for debug usage
- [ ] Update the documentation `recnet-docs` if needed
@github-actions github-actions bot requested a review from swh00tw December 3, 2024 00:03
@joannechen1223 joannechen1223 merged commit 8dca510 into master Dec 3, 2024
6 checks passed
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.

2 participants