diff --git a/middlewares/checkCanGenerateDiscordLink.ts b/middlewares/checkCanGenerateDiscordLink.ts index c25535230..5f1693943 100644 --- a/middlewares/checkCanGenerateDiscordLink.ts +++ b/middlewares/checkCanGenerateDiscordLink.ts @@ -6,8 +6,6 @@ const checkCanGenerateDiscordLink = async (req: CustomRequest, res: CustomRespon const { id: userId, roles } = req.userData; const isSuperUser = roles.super_user; const userIdInQuery = req.query.userId; - const currentTime = Date.now(); - const cutoffTime = 1725147849000; // Todo will remove this Hotfix time for 31 August 2024 if (isSuperUser) { return next(); @@ -17,10 +15,6 @@ const checkCanGenerateDiscordLink = async (req: CustomRequest, res: CustomRespon return res.boom.forbidden("User should be super user to generate link for other users"); } - if (currentTime >= cutoffTime) { - return res.boom.forbidden("Discord invite link generation is not allowed after the cutoff time."); - } - try { const applications = await ApplicationModel.getUserApplications(userId); @@ -31,7 +25,7 @@ const checkCanGenerateDiscordLink = async (req: CustomRequest, res: CustomRespon const approvedApplication = applications.find((application: { status: string; }) => application.status === 'accepted'); if (!approvedApplication) { - return res.boom.forbidden("Only users with an approved application can generate a Discord invite link."); + return res.boom.forbidden("Only users with an accepted application can generate a Discord invite link."); } return next(); diff --git a/test/integration/discordactions.test.js b/test/integration/discordactions.test.js index 66632a125..7967c65ad 100644 --- a/test/integration/discordactions.test.js +++ b/test/integration/discordactions.test.js @@ -781,12 +781,6 @@ describe("Discord actions", function () { // <------ Will revisit this later https://github.com/Real-Dev-Squad/website-backend/issues/2078 ---> describe("POST /discord-actions/invite", function () { - let clock; - - beforeEach(function () { - clock = sinon.useFakeTimers(new Date("2024-08-31").getTime()); - }); - afterEach(function () { sinon.restore(); }); @@ -903,19 +897,6 @@ describe("Discord actions", function () { expect(res.body.inviteLink).to.be.equal("discord.gg/asdfdsfsd"); }); - it("should return 403 if current date is after 25 August 2024", async function () { - clock.tick(2 * 24 * 60 * 60 * 1000); // Move time forward to after 31 August 2024 - sinon.stub(ApplicationModel, "getUserApplications").resolves([{ status: "accepted" }]); - - const res = await chai - .request(app) - .post("/discord-actions/invite") - .set("cookie", `${cookieName}=${userAuthToken}`); - - expect(res).to.have.status(403); - expect(res.body.message).to.be.equal("Discord invite link generation is not allowed after the cutoff time."); - }); - it("should return 403 if user has no applications", async function () { sinon.stub(ApplicationModel, "getUserApplications").resolves([]); @@ -938,7 +919,7 @@ describe("Discord actions", function () { expect(res).to.have.status(403); expect(res.body.message).to.be.equal( - "Only users with an approved application can generate a Discord invite link." + "Only users with an accepted application can generate a Discord invite link." ); }); @@ -952,7 +933,7 @@ describe("Discord actions", function () { expect(res).to.have.status(403); expect(res.body.message).to.be.equal( - "Only users with an approved application can generate a Discord invite link." + "Only users with an accepted application can generate a Discord invite link." ); });