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

feat: add purpose field and make discord invite API be able to generate invites n times by superusers #2218

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

devdeadviz
Copy link

@devdeadviz devdeadviz commented Oct 18, 2024

Date: 19/10/2024

Developer Name: Kuldeep Gupta


Issue Ticket Number

This is a subtask for this issue Real-Dev-Squad/website-dashboard#867

Description

I have refactored the discord invite API to add a purpose field along with a feature flag and also, the superuser can create n times discord invites.

Design Doc Link: https://docs.google.com/document/d/1kGOpNMBlRLJ7gARYv1kCOUaE3b96G5Y212IN05igJkc/edit?tab=t.0#heading=h.f040sbx0way2

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1 Without a feature flag Screenshot 2024-10-19 at 2 25 57 AM

With a feature flag (When user doesn't have invite link already created.)
image

With a feature flag (When the user already has an invite link.)
image

Test Coverage

Unit Tests Screenshots

image

image

Integration Tests Screenshots Screenshot 2024-11-05 at 12 42 41 AM Screenshot 2024-11-05 at 12 39 50 AM

Additional Notes

@devdeadviz devdeadviz requested a review from vinit717 October 25, 2024 21:17
routes/discordactions.js Fixed Show fixed Hide fixed
@devdeadviz devdeadviz changed the title feat: add purpose field in generate discord invite for user with feat… feat: add purpose field and make discord invite API be able to generate invites n times by superusers Oct 25, 2024
controllers/discordactions.js Outdated Show resolved Hide resolved
middlewares/validators/discordactions.js Outdated Show resolved Hide resolved
@devdeadviz devdeadviz requested a review from vinit717 October 26, 2024 12:05
controllers/discordactions.js Outdated Show resolved Hide resolved
middlewares/validators/discordactions.js Outdated Show resolved Hide resolved
routes/discordactions.js Outdated Show resolved Hide resolved
controllers/discordactions.js Outdated Show resolved Hide resolved
test/unit/models/discordactions.test.js Outdated Show resolved Hide resolved
@devdeadviz devdeadviz requested a review from vinit717 October 30, 2024 18:15
@vinit717
Copy link
Member

vinit717 commented Nov 4, 2024

Please add proper test coverage of the file you changed

router.post("/invite", authenticate, checkCanGenerateDiscordLink, generateInviteForUser);
router.post(
"/invite",
authenticate,

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.
This route handler performs
authorization
, but is not rate-limited.
This route handler performs
authorization
, but is not rate-limited.
@devdeadviz
Copy link
Author

Please add proper test coverage of the file you changed

Done

@vinit717
Copy link
Member

vinit717 commented Nov 5, 2024

How are you passing the user ID in the query params?

@devdeadviz
Copy link
Author

How are you passing the user ID in the query params?

@vinit717 I am not sure if I get your question properly, but the id is getting passed in this way /discord-actions/invite?userId=id.

@vinit717
Copy link
Member

vinit717 commented Nov 5, 2024

How are you passing the user ID in the query params?

@vinit717 I am not sure if I get your question properly, but the id is getting passed in this way /discord-actions/invite?userId=id.

How does this API get the userID from frontend?

@devdeadviz
Copy link
Author

devdeadviz commented Nov 5, 2024

How are you passing the user ID in the query params?

@vinit717 I am not sure if I get your question properly, but the id is getting passed in this way /discord-actions/invite?userId=id.

How does this API get the userID from frontend?

We need to pass the userId in the query params and we can read it in the code in this way const { userId } = req.query and use it in the API wherever we want to.

@vinit717
Copy link
Member

vinit717 commented Nov 5, 2024

How are you passing the user ID in the query params?

@vinit717 I am not sure if I get your question properly, but the id is getting passed in this way /discord-actions/invite?userId=id.

How does this API get the userID from frontend?

We need to pass the userId in the query params and we can read it in the code in this way const { userId } = req.query and use it in the API wherever we want to.

How are you passing the userId? how did you know the userId and which userId to pass?

@devdeadviz
Copy link
Author

How are you passing the user ID in the query params?

@vinit717 I am not sure if I get your question properly, but the id is getting passed in this way /discord-actions/invite?userId=id.

How does this API get the userID from frontend?

We need to pass the userId in the query params and we can read it in the code in this way const { userId } = req.query and use it in the API wherever we want to.

How are you passing the userId? how did you know the userId and which userId to pass?

I guess now I got your exact question, so for now we are not passing the userId from frontend. Right now the userId is getting used from superUser token.

@devdeadviz devdeadviz requested a review from pankajjs November 26, 2024 13:18
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.

4 participants