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
Open
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
44328ad
feat: add purpose field in generate discord invite for user with feat…
devdeadviz Oct 18, 2024
ddfc548
feat: add functionality to be able to create n times discord invites …
devdeadviz Oct 22, 2024
2eab530
Merge branch 'develop' into feat/add-purpose-in-discord-api
devdeadviz Oct 22, 2024
becf40e
feat: add unit tests for generateInviteForUser
devdeadviz Oct 25, 2024
9f7dc73
feat: add joi validation for generateInviteForUser function body
devdeadviz Oct 25, 2024
9545994
Merge branch 'develop' into feat/add-purpose-in-discord-api
Achintya-Chatterjee Oct 25, 2024
bdd12a3
Merge branch 'develop' into feat/add-purpose-in-discord-api
devdeadviz Oct 28, 2024
99a8364
Merge branch 'develop' into feat/add-purpose-in-discord-api
Achintya-Chatterjee Oct 29, 2024
ef00ad8
fix: add suggested changes
devdeadviz Oct 30, 2024
a3b15c4
feat(e2e): add integrations test for discord-actions invite api
devdeadviz Oct 30, 2024
84d0960
chore: remove creation of random id while storing discord invite to d…
devdeadviz Oct 30, 2024
3cc2444
refactor: getUserDiscordInvite query to fetch purpose when dev is true
devdeadviz Oct 30, 2024
5734b0c
Merge branch 'develop' into feat/add-purpose-in-discord-api
devdeadviz Nov 22, 2024
470399b
refactor: remove non needed else block
devdeadviz Nov 25, 2024
13f5a73
refactor: add status code in fetch invite api
devdeadviz Nov 26, 2024
f63f564
fix: dev condition to only work in truthy case
devdeadviz Nov 26, 2024
3c0a55f
Merge branch 'develop' into feat/add-purpose-in-discord-api
devdeadviz Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions controllers/discordactions.js
devdeadviz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
const nickNameUpdatedUsers = [];
let counter = 0;
for (let i = 0; i < usersToBeEffected.length; i++) {
const { discordId, username, first_name: firstName } = usersToBeEffected[i];

Check warning on line 289 in controllers/discordactions.js

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Variable Assigned to Object Injection Sink
try {
if (counter % 10 === 0 && counter !== 0) {
await new Promise((resolve) => setTimeout(resolve, 5500));
Expand All @@ -302,7 +302,7 @@
if (message) {
counter++;
totalNicknamesUpdated.count++;
nickNameUpdatedUsers.push(usersToBeEffected[i].id);

Check warning on line 305 in controllers/discordactions.js

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Generic Object Injection Sink
}
}
} catch (error) {
Expand Down Expand Up @@ -409,8 +409,9 @@

const generateInviteForUser = async (req, res) => {
try {
const { userId } = req.query;
const { userId, dev } = req.query;
const userIdForInvite = userId || req.userData.id;
let inviteLink = "";

const modelResponse = await discordRolesModel.getUserDiscordInvite(userIdForInvite);

Expand All @@ -437,14 +438,25 @@
const discordInviteResponse = await response.json();

const inviteCode = discordInviteResponse.data.code;
const inviteLink = `discord.gg/${inviteCode}`;
inviteLink = `discord.gg/${inviteCode}`;

await discordRolesModel.addInviteToInviteModel({ userId: userIdForInvite, inviteLink });
if (dev) {
const purpose = req.body.purpose;
await discordRolesModel.addInviteToInviteModel({ userId: userIdForInvite, inviteLink, purpose });

return res.status(201).json({
message: "invite generated successfully",
inviteLink,
});
return res.status(201).json({
message: "invite generated successfully",
inviteLink,
purpose,
});
} else {
await discordRolesModel.addInviteToInviteModel({ userId: userIdForInvite, inviteLink });

return res.status(201).json({
message: "invite generated successfully",
inviteLink,
});
}
devdeadviz marked this conversation as resolved.
Show resolved Hide resolved
} catch (err) {
logger.error(`Error in generating invite for user: ${err}`);
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
Expand Down
Loading