-
Notifications
You must be signed in to change notification settings - Fork 280
added endpoint for generating and getting discord invite for user #1553
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b8816fc
added enpoint for generating and getting discord invite for user
vinayak-trivedi 799efb7
changes in middleware and controller method
vinayak-trivedi 2abbced
changed discordNewComersChannelId constant
vinayak-trivedi 5910297
tests for endpoint for getting discord link generated for user
vinayak-trivedi 36dac7c
tests for post API
vinayak-trivedi 43bb566
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-b…
vinayak-trivedi f5655a1
fix for failing tests
vinayak-trivedi 30f7781
fix for failing unit test
vinayak-trivedi c948307
types issue fixed
vinayak-trivedi 998f559
model tests
vinayak-trivedi 1ea7df4
did suggested changes
vinayak-trivedi 71446ad
invite get model test changes
vinayak-trivedi 1105698
removed the model test getInvite
vinayak-trivedi 99252d1
test description string change
vinayak-trivedi 2bfd652
Update test/integration/discordactions.test.js
vinayak-trivedi 7dde33f
sync dev to discord-invite-api
vinayak-trivedi c8e52fb
Merge branch 'discord-invite-api' of https://github.com/Real-Dev-Squa…
vinayak-trivedi 09a9eca
fix for failing tests
vinayak-trivedi 1ae3bef
fix for failing unit test
vinayak-trivedi 9f2870c
made suggested changes
vinayak-trivedi 4431f07
updated one model test and added one model test for getInvite model
vinayak-trivedi 5cae6df
Merge branch 'develop' into discord-invite-api
vinayak-trivedi 640a3b2
Merge branch 'develop' into discord-invite-api
prakashchoudhary07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,28 @@ | ||
| import { NextFunction } from "express"; | ||
| import { CustomRequest, CustomResponse } from "../types/global"; | ||
|
|
||
| const checkCanGenerateDiscordLink = async (req: CustomRequest, res: CustomResponse, next: NextFunction) => { | ||
| const { discordId, roles, id: userId, profileStatus } = req.userData; | ||
| const isSuperUser = roles.super_user; | ||
| const userIdInQuery = req.query.userId; | ||
|
|
||
| if (userIdInQuery && userIdInQuery !== userId && !isSuperUser) { | ||
| return res.boom.forbidden("User should be super user to generate link for other users"); | ||
| } | ||
|
|
||
| if (discordId) { | ||
| return res.boom.forbidden("Only users who have never joined discord can generate invite link"); | ||
| } | ||
|
|
||
| if (roles.archived) { | ||
| return res.boom.forbidden("Archived users cannot generate invite"); | ||
| } | ||
|
|
||
| if (!roles.maven && !roles.designer && !roles.product_manager && profileStatus !== "VERIFIED") { | ||
| return res.boom.forbidden("Only selected roles can generate discord link directly"); | ||
| } | ||
|
|
||
| return next(); | ||
| }; | ||
|
|
||
| module.exports = checkCanGenerateDiscordLink; |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.