Skip to content

Commit

Permalink
removes endpoint for getting emails
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarsh-scottlogic committed Feb 22, 2024
1 parent 7f9ffd7 commit e9410e9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 40 deletions.
13 changes: 1 addition & 12 deletions backend/src/controller/emailController.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import { Response } from 'express';

import { EmailClearRequest } from '@src/models/api/EmailClearRequest';
import { EmailGetRequest } from '@src/models/api/EmailGetRequest';
import { LEVEL_NAMES } from '@src/models/level';

function handleGetEmails(req: EmailGetRequest, res: Response) {
const level: number | undefined = req.query.level as number | undefined;
if (level !== undefined) {
res.send(req.session.levelState[level].sentEmails);
} else {
res.status(400);
res.send('Missing level');
}
}

function handleClearEmails(req: EmailClearRequest, res: Response) {
const level = req.body.level;
if (level !== undefined && level >= LEVEL_NAMES.LEVEL_1) {
Expand All @@ -26,4 +15,4 @@ function handleClearEmails(req: EmailClearRequest, res: Response) {
}
}

export { handleGetEmails, handleClearEmails };
export { handleClearEmails };
13 changes: 0 additions & 13 deletions backend/src/models/api/EmailGetRequest.ts

This file was deleted.

6 changes: 1 addition & 5 deletions backend/src/sessionRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import {
handleDefenceDeactivation,
handleResetSingleDefence,
} from './controller/defenceController';
import {
handleClearEmails,
handleGetEmails,
} from './controller/emailController';
import { handleClearEmails } from './controller/emailController';
import { handleLoadLevel } from './controller/levelController';
import {
handleConfigureModel,
Expand Down Expand Up @@ -105,7 +102,6 @@ router.post('/defence/configure', handleConfigureDefence);
router.post('/defence/resetConfig', handleResetSingleDefence);

// emails
router.get('/email/get', handleGetEmails);
router.post('/email/clear', handleClearEmails);

// chat
Expand Down
11 changes: 1 addition & 10 deletions frontend/src/service/emailService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { EmailInfo } from '@src/models/email';

import { sendRequest } from './backendService';

const PATH = 'email/';
Expand All @@ -15,11 +13,4 @@ async function clearEmails(level: number): Promise<boolean> {
return response.status === 200;
}

async function getSentEmails(level: number) {
const response = await sendRequest(`${PATH}get?level=${level}`, {
method: 'GET',
});
return (await response.json()) as EmailInfo[];
}

export { clearEmails, getSentEmails };
export { clearEmails };

0 comments on commit e9410e9

Please sign in to comment.