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
7 changes: 2 additions & 5 deletions src/v1/account-removal/account-removal.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import { RequestAccountRemovalDto } from './dto/request-account-removal.dto';
@ApiTags('account-removal')
@Controller({ path: 'account-removal', version: '1' })
export class AccountRemovalController {
constructor(
private readonly accountRemovalService: AccountRemovalService,
) {}
constructor(private readonly accountRemovalService: AccountRemovalService) {}

@Throttle({ default: { ttl: 60_000, limit: 10 } })
@Get('challenge')
Expand All @@ -38,8 +36,7 @@ export class AccountRemovalController {
@Post('request')
@HttpCode(HttpStatus.ACCEPTED)
@ApiOperation({
summary:
'Submit an account removal request (public; emails the operators)',
summary: 'Submit an account removal request (public; emails the operators)',
})
async submitRequest(
@Body() body: RequestAccountRemovalDto,
Expand Down
6 changes: 4 additions & 2 deletions src/v1/account-removal/account-removal.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import type { ConfigService } from '@nestjs/config';
import { AccountRemovalService } from './account-removal.service';

const sendMailMock = jest.fn();
const sendMailMock = jest.fn((_mail: unknown) => Promise.resolve());

jest.mock('nodemailer', () => ({
createTransport: jest.fn(() => ({ sendMail: sendMailMock })),
Expand Down Expand Up @@ -43,7 +43,9 @@ describe('AccountRemovalService', () => {
expect(Number.isInteger(a)).toBe(true);
expect(Number.isInteger(b)).toBe(true);

expect(() => service.verifyChallenge(a + b, challenge.token)).not.toThrow();
expect(() =>
service.verifyChallenge(a + b, challenge.token),
).not.toThrow();
});

it('rejects a wrong answer', () => {
Expand Down
10 changes: 2 additions & 8 deletions src/v1/account-removal/account-removal.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
createHmac,
randomInt,
timingSafeEqual,
} from 'crypto';
import { createHmac, randomInt, timingSafeEqual } from 'crypto';
import {
BadRequestException,
Injectable,
Expand Down Expand Up @@ -137,9 +133,7 @@ export class AccountRemovalService {
const user = this.configService.get<string>('SMTP_USER');
const pass = this.configService.get<string>('SMTP_PASS');
if (!host || !user || !pass) {
throw new ServiceUnavailableException(
'Email delivery is not configured',
);
throw new ServiceUnavailableException('Email delivery is not configured');
}
const port = Number(this.configService.get<string>('SMTP_PORT') ?? '465');

Expand Down
Loading