Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions middlewares/shortCircuit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NextFunction } from "express";
import { CustomRequest, CustomResponse } from "../types/global";

export const disableRoute = (_req: CustomRequest, res: CustomResponse, _next: NextFunction) => {
return res.boom.serverUnavailable(
"This route has been temporarily disabled. If you need assistance, please reach out to the team."
);
};
14 changes: 12 additions & 2 deletions routes/discordactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,24 @@
const { Services } = require("../constants/bot");
const { verifyCronJob } = require("../middlewares/authorizeBot");
const { authorizeAndAuthenticate } = require("../middlewares/authorizeUsersAndService");
const { disableRoute } = require("../middlewares/shortCircuit");
const router = express.Router();

router.post("/groups", authenticate, checkIsVerifiedDiscord, validateGroupRoleBody, createGroupRole);
router.get("/groups", authenticate, checkIsVerifiedDiscord, validateLazyLoadingParams, getPaginatedAllGroupRoles);
router.delete("/groups/:groupId", authenticate, checkIsVerifiedDiscord, authorizeRoles([SUPERUSER]), deleteGroupRole);
router.post("/roles", authenticate, checkIsVerifiedDiscord, validateMemberRoleBody, addGroupRoleToMember);
router.get("/invite", authenticate, getUserDiscordInvite);
router.post("/invite", authenticate, checkCanGenerateDiscordLink, generateInviteForUser);
/**
* Short-circuit the GET method for this endpoint
* Refer https://github.com/Real-Dev-Squad/todo-action-items/issues/269 for more details.
*/
router.get("/invite", disableRoute, authenticate, getUserDiscordInvite);
/**
* Short-circuit this POST method for this endpoint
* Refer https://github.com/Real-Dev-Squad/todo-action-items/issues/269 for more details.
*/
router.post("/invite", disableRoute, authenticate, checkCanGenerateDiscordLink, generateInviteForUser);

router.delete("/roles", authenticate, checkIsVerifiedDiscord, deleteRole);
router.get("/roles", authenticate, checkIsVerifiedDiscord, getGroupsRoleId);
router.patch(
Expand Down
6 changes: 4 additions & 2 deletions test/integration/discordactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,8 @@ describe("Discord actions", function () {
});
});

describe("GET /discord-actions/invite", function () {
// eslint-disable-next-line mocha/no-skipped-tests
describe.skip("GET /discord-actions/invite", function () {
it("should return the invite for the user if no userId is provided in the params and the invite exists", async function () {
await addInviteToInviteModel({ userId: superUserId, inviteLink: "discord.gg/apQYT7HB" });

Expand Down Expand Up @@ -994,7 +995,8 @@ describe("Discord actions", function () {
});

// <------ Will revisit this later https://github.com/Real-Dev-Squad/website-backend/issues/2078 --->
describe("POST /discord-actions/invite", function () {
// eslint-disable-next-line mocha/no-skipped-tests
describe.skip("POST /discord-actions/invite", function () {
afterEach(function () {
sinon.restore();
});
Expand Down
Loading