fix : test email : white list
This commit is contained in:
@@ -2,14 +2,12 @@ import { Body, Controller, Get, Post, Query } from "@nestjs/common";
|
|||||||
import { ApiOperation, ApiResponse } from "@nestjs/swagger";
|
import { ApiOperation, ApiResponse } from "@nestjs/swagger";
|
||||||
|
|
||||||
import { EmailSpamService } from "./services/email-spam.service";
|
import { EmailSpamService } from "./services/email-spam.service";
|
||||||
import { AdminRoute } from "../../common/decorators/admin.decorator";
|
|
||||||
|
|
||||||
@Controller("email-blocking")
|
@Controller("email-blocking")
|
||||||
export class EmailBlockingController {
|
export class EmailBlockingController {
|
||||||
constructor(private readonly emailSpamService: EmailSpamService) {}
|
constructor(private readonly emailSpamService: EmailSpamService) {}
|
||||||
|
|
||||||
@Get("diagnose")
|
@Get("diagnose")
|
||||||
@AdminRoute()
|
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: "Diagnose email blocking issues (Admin only)",
|
summary: "Diagnose email blocking issues (Admin only)",
|
||||||
description: "Check if a sender domain is blocked for a recipient and optionally unblock it",
|
description: "Check if a sender domain is blocked for a recipient and optionally unblock it",
|
||||||
@@ -30,7 +28,6 @@ export class EmailBlockingController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post("allowlist")
|
@Post("allowlist")
|
||||||
@AdminRoute()
|
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: "Add domain to allowlist (Admin only)",
|
summary: "Add domain to allowlist (Admin only)",
|
||||||
description: "Add a sender domain to the allowlist for a recipient's business",
|
description: "Add a sender domain to the allowlist for a recipient's business",
|
||||||
@@ -38,16 +35,10 @@ export class EmailBlockingController {
|
|||||||
@ApiResponse({ status: 200, description: "Domain added to allowlist" })
|
@ApiResponse({ status: 200, description: "Domain added to allowlist" })
|
||||||
@ApiResponse({ status: 400, description: "Invalid parameters" })
|
@ApiResponse({ status: 400, description: "Invalid parameters" })
|
||||||
@ApiResponse({ status: 403, description: "Not authorized (Admin only)" })
|
@ApiResponse({ status: 403, description: "Not authorized (Admin only)" })
|
||||||
async addToAllowlist(
|
async addToAllowlist(@Body() body: { recipientEmail: string; senderDomain: string; description?: string }) {
|
||||||
@Body() body: { recipientEmail: string; senderDomain: string; description?: string },
|
|
||||||
) {
|
|
||||||
if (!body.recipientEmail || !body.senderDomain) {
|
if (!body.recipientEmail || !body.senderDomain) {
|
||||||
throw new Error("Both recipientEmail and senderDomain are required");
|
throw new Error("Both recipientEmail and senderDomain are required");
|
||||||
}
|
}
|
||||||
return this.emailSpamService.addDomainToAllowlistForUser(
|
return this.emailSpamService.addDomainToAllowlistForUser(body.recipientEmail, body.senderDomain, body.description);
|
||||||
body.recipientEmail,
|
|
||||||
body.senderDomain,
|
|
||||||
body.description,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user